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

View File

@@ -197,7 +197,7 @@ namespace Barotrauma
{
get { return !IsUnconscious && Stun <= 0.0f && !isDead; }
}
public bool CanInteract
{
get { return AllowInput && IsHumanoid && !LockHands; }
@@ -303,11 +303,11 @@ namespace Barotrauma
get { return needsAir; }
set { needsAir = value; }
}
public float Oxygen
{
get { return oxygen; }
set
set
{
if (!MathUtils.IsValid(value)) return;
oxygen = MathHelper.Clamp(value, -100.0f, 100.0f);
@@ -331,7 +331,7 @@ namespace Barotrauma
{
if (GameMain.Client != null) return;
SetStun(value);
SetStun(value);
}
}
@@ -358,7 +358,7 @@ namespace Barotrauma
}
}
}
public float MaxHealth
{
get { return maxHealth; }
@@ -367,32 +367,32 @@ namespace Barotrauma
public float Bleeding
{
get { return bleeding; }
set
set
{
if (!MathUtils.IsValid(value)) return;
if (GameMain.Client != null) return;
float newBleeding = MathHelper.Clamp(value, 0.0f, 5.0f);
float newBleeding = MathHelper.Clamp(value, 0.0f, 5.0f);
if (newBleeding == bleeding) return;
bleeding = newBleeding;
if (GameMain.Server != null)
GameMain.Server.CreateEntityEvent(this, new object[] { NetEntityEvent.Type.Status });
}
}
public HuskInfection huskInfection;
public float HuskInfectionState
{
get
{
return huskInfection == null ? 0.0f : huskInfection.IncubationTimer;
get
{
return huskInfection == null ? 0.0f : huskInfection.IncubationTimer;
}
set
{
if (ConfigPath != humanConfigFile) return;
if (value <= 0.0f)
{
if (huskInfection != null)
@@ -448,7 +448,7 @@ namespace Barotrauma
get;
set;
}
public Item[] SelectedItems
{
get { return selectedItems; }
@@ -465,6 +465,12 @@ namespace Barotrauma
get { return focusedItem; }
}
public Item PickingItem
{
get;
set;
}
public virtual AIController AIController
{
get { return null; }

View File

@@ -13,7 +13,6 @@ namespace Barotrauma.Items.Components
private float pickTimer;
public List<InvSlotType> AllowedSlots
{
get { return allowedSlots; }
@@ -55,13 +54,15 @@ namespace Barotrauma.Items.Components
public override bool Pick(Character picker)
{
//return if someone is already trying to pick the item
if (pickTimer>0.0f) return false;
if (pickTimer > 0.0f) return false;
if (picker == null || picker.Inventory == null) return false;
if (PickingTime>0.0f)
if (PickingTime > 0.0f)
{
CoroutineManager.StartCoroutine(WaitForPick(picker, PickingTime));
if (picker.PickingItem == null)
{
CoroutineManager.StartCoroutine(WaitForPick(picker, PickingTime));
}
return false;
}
else
@@ -104,6 +105,8 @@ namespace Barotrauma.Items.Components
private IEnumerable<object> WaitForPick(Character picker, float requiredTime)
{
picker.PickingItem = item;
var leftHand = picker.AnimController.GetLimb(LimbType.LeftHand);
var rightHand = picker.AnimController.GetLimb(LimbType.RightHand);
@@ -151,7 +154,8 @@ namespace Barotrauma.Items.Components
private void StopPicking(Character picker)
{
picker.AnimController.Anim = AnimController.Animation.None;
pickTimer = 0.0f;
picker.PickingItem = null;
pickTimer = 0.0f;
}
protected void DropConnectedWires(Character character)