realised half way through that I don't even need a new action type, oops
This commit is contained in:
@@ -41,7 +41,6 @@ namespace Barotrauma
|
||||
private readonly float duration;
|
||||
|
||||
private readonly bool useItem;
|
||||
private readonly bool hudUseItem;
|
||||
|
||||
public readonly ActionType type;
|
||||
|
||||
@@ -167,11 +166,9 @@ namespace Barotrauma
|
||||
FireSize = subElement.GetAttributeFloat("size",10.0f);
|
||||
break;
|
||||
case "use":
|
||||
case "useitem":
|
||||
useItem = true;
|
||||
break;
|
||||
case "huduse":
|
||||
hudUseItem = true;
|
||||
break;
|
||||
case "requireditem":
|
||||
case "requireditems":
|
||||
RelatedItem newRequiredItem = RelatedItem.Load(subElement);
|
||||
@@ -261,13 +258,6 @@ namespace Barotrauma
|
||||
item.Use(deltaTime, targets.FirstOrDefault(t => t is Character) as Character);
|
||||
}
|
||||
}
|
||||
if (hudUseItem)
|
||||
{
|
||||
foreach (Item item in targets.FindAll(t => t is Item).Cast<Item>())
|
||||
{
|
||||
item.HudUse(deltaTime, targets.FirstOrDefault(t => t is Character) as Character);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (ISerializableEntity target in targets)
|
||||
{
|
||||
|
||||
@@ -36,7 +36,6 @@ namespace Barotrauma
|
||||
{
|
||||
if (Items[slotIndex] == null) return false;
|
||||
|
||||
//Isn't this useless? Client isn't handling status effects. Plus, this doesn't send the ActionType so it can be wrong even.
|
||||
#if CLIENT
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
@@ -47,10 +46,10 @@ namespace Barotrauma
|
||||
|
||||
if (GameMain.Server != null)
|
||||
{
|
||||
GameMain.Server.CreateEntityEvent(Items[slotIndex], new object[] { NetEntityEvent.Type.ApplyStatusEffect, ActionType.OnHudUse, character.ID });
|
||||
GameMain.Server.CreateEntityEvent(Items[slotIndex], new object[] { NetEntityEvent.Type.ApplyStatusEffect, ActionType.OnUse, character.ID });
|
||||
}
|
||||
|
||||
Items[slotIndex].ApplyStatusEffects(ActionType.OnHudUse, 1.0f, character);
|
||||
Items[slotIndex].ApplyStatusEffects(ActionType.OnUse, 1.0f, character);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -290,13 +290,6 @@ namespace Barotrauma.Items.Components
|
||||
return false;
|
||||
}
|
||||
|
||||
//called when the item is used via the HUD button
|
||||
//returns true if the item was used succesfully (not out of ammo, reloading, etc)
|
||||
public virtual bool HudUse(float deltaTime, Character character = null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//called when the item is equipped and right mouse button is pressed
|
||||
public virtual void Aim(float deltaTime, Character character = null) { }
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Barotrauma
|
||||
{
|
||||
public enum ActionType
|
||||
{
|
||||
Always, OnPicked, OnUse, OnHudUse, OnAim,
|
||||
Always, OnPicked, OnUse, OnAim,
|
||||
OnWearing, OnContaining, OnContained,
|
||||
OnActive, OnFailure, OnBroken,
|
||||
OnFire, InWater,
|
||||
@@ -800,7 +800,6 @@ namespace Barotrauma
|
||||
if (!ic.WasUsed)
|
||||
{
|
||||
ic.StopSounds(ActionType.OnUse);
|
||||
ic.StopSounds(ActionType.OnHudUse);
|
||||
}
|
||||
#endif
|
||||
ic.WasUsed = false;
|
||||
@@ -1166,33 +1165,6 @@ namespace Barotrauma
|
||||
if (remove) Remove();
|
||||
}
|
||||
|
||||
public void HudUse(float deltaTime, Character character = null)
|
||||
{
|
||||
if (condition == 0.0f) return;
|
||||
|
||||
bool remove = false;
|
||||
|
||||
foreach (ItemComponent ic in components)
|
||||
{
|
||||
if (!ic.HasRequiredContainedItems(character == Character.Controlled)) continue;
|
||||
if (ic.HudUse(deltaTime, character))
|
||||
{
|
||||
ic.WasUsed = true;
|
||||
|
||||
#if CLIENT
|
||||
ic.PlaySound(ActionType.OnHudUse, WorldPosition);
|
||||
#endif
|
||||
|
||||
ic.ApplyStatusEffects(ActionType.OnHudUse, deltaTime, character);
|
||||
|
||||
if (ic.DeleteOnUse) remove = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (remove) Remove();
|
||||
}
|
||||
|
||||
public void Aim(float deltaTime, Character character = null)
|
||||
{
|
||||
foreach (ItemComponent ic in components)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user