Characters can only have one picking timer active at a time. Closes #179

This commit is contained in:
Joonas Rikkonen
2017-12-21 22:31:48 +02:00
parent 4db708335a
commit 7c37ba0955
2 changed files with 30 additions and 20 deletions
@@ -465,6 +465,12 @@ namespace Barotrauma
get { return focusedItem; } get { return focusedItem; }
} }
public Item PickingItem
{
get;
set;
}
public virtual AIController AIController public virtual AIController AIController
{ {
get { return null; } get { return null; }
@@ -13,7 +13,6 @@ namespace Barotrauma.Items.Components
private float pickTimer; private float pickTimer;
public List<InvSlotType> AllowedSlots public List<InvSlotType> AllowedSlots
{ {
get { return allowedSlots; } get { return allowedSlots; }
@@ -59,9 +58,11 @@ namespace Barotrauma.Items.Components
if (picker == null || picker.Inventory == null) return false; if (picker == null || picker.Inventory == null) return false;
if (PickingTime > 0.0f) if (PickingTime > 0.0f)
{
if (picker.PickingItem == null)
{ {
CoroutineManager.StartCoroutine(WaitForPick(picker, PickingTime)); CoroutineManager.StartCoroutine(WaitForPick(picker, PickingTime));
}
return false; return false;
} }
else else
@@ -104,6 +105,8 @@ namespace Barotrauma.Items.Components
private IEnumerable<object> WaitForPick(Character picker, float requiredTime) private IEnumerable<object> WaitForPick(Character picker, float requiredTime)
{ {
picker.PickingItem = item;
var leftHand = picker.AnimController.GetLimb(LimbType.LeftHand); var leftHand = picker.AnimController.GetLimb(LimbType.LeftHand);
var rightHand = picker.AnimController.GetLimb(LimbType.RightHand); var rightHand = picker.AnimController.GetLimb(LimbType.RightHand);
@@ -151,6 +154,7 @@ namespace Barotrauma.Items.Components
private void StopPicking(Character picker) private void StopPicking(Character picker)
{ {
picker.AnimController.Anim = AnimController.Animation.None; picker.AnimController.Anim = AnimController.Animation.None;
picker.PickingItem = null;
pickTimer = 0.0f; pickTimer = 0.0f;
} }