roll back name change from "Aim" to "SecondaryUse"
Expand SecondaryUse to have similar properties to normal Use so it can apply SecondaryUse-related status effects Make Throwable great again
This commit is contained in:
@@ -128,7 +128,7 @@ namespace Barotrauma
|
||||
Character.AnimController.TargetDir = Direction.Left;
|
||||
}
|
||||
|
||||
if (Character.SelectedConstruction != null) Character.SelectedConstruction.Aim(deltaTime, Character);
|
||||
if (Character.SelectedConstruction != null) Character.SelectedConstruction.SecondaryUse(deltaTime, Character);
|
||||
|
||||
}
|
||||
else if (Math.Abs(Character.AnimController.TargetMovement.X) > 0.1f && !Character.AnimController.InWater)
|
||||
|
||||
@@ -932,13 +932,13 @@ namespace Barotrauma
|
||||
if (i == 1 && selectedItems[0] == selectedItems[1]) continue;
|
||||
|
||||
if (IsKeyDown(InputType.Use)) selectedItems[i].Use(deltaTime, this);
|
||||
if (IsKeyDown(InputType.Aim) && selectedItems[i] != null) selectedItems[i].Aim(deltaTime, this);
|
||||
if (IsKeyDown(InputType.Aim) && selectedItems[i] != null) selectedItems[i].SecondaryUse(deltaTime, this);
|
||||
}
|
||||
|
||||
if (selectedConstruction != null)
|
||||
{
|
||||
if (IsKeyDown(InputType.Use)) selectedConstruction.Use(deltaTime, this);
|
||||
if (selectedConstruction != null && IsKeyDown(InputType.Aim)) selectedConstruction.Aim(deltaTime, this);
|
||||
if (selectedConstruction != null && IsKeyDown(InputType.Aim)) selectedConstruction.SecondaryUse(deltaTime, this);
|
||||
}
|
||||
|
||||
if (SelectedCharacter != null)
|
||||
|
||||
@@ -255,7 +255,7 @@ namespace Barotrauma.Items.Components
|
||||
dockingTarget.dockingDir = -dockingDir;
|
||||
|
||||
#if CLIENT
|
||||
PlaySound(ActionType.OnAim, item.WorldPosition);
|
||||
PlaySound(ActionType.OnSecondaryUse, item.WorldPosition);
|
||||
#endif
|
||||
|
||||
ConnectWireBetweenPorts();
|
||||
|
||||
@@ -27,18 +27,13 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public override bool Use(float deltaTime, Character character = null)
|
||||
{
|
||||
if (character == null) return false;
|
||||
if (!character.IsKeyDown(InputType.Aim) || throwing) return false;
|
||||
|
||||
throwing = true;
|
||||
|
||||
IsActive = true;
|
||||
return true;
|
||||
return true; //We do the actual throwing in Aim because Use might be used by chems
|
||||
}
|
||||
|
||||
public override void Aim(float deltaTime, Character character = null)
|
||||
public override bool SecondaryUse(float deltaTime, Character character = null)
|
||||
{
|
||||
if (throwing) return;
|
||||
if (!throwing) return false; //This should only be triggered
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Drop(Character dropper)
|
||||
@@ -103,7 +98,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
Limb rightHand = ac.GetLimb(LimbType.RightHand);
|
||||
item.body.AngularVelocity = rightHand.body.AngularVelocity;
|
||||
|
||||
ApplyStatusEffects(ActionType.OnSecondaryUse, deltaTime, picker); //Stun grenades, flares, etc. all have their throw-related things handled in "onSecondaryUse"
|
||||
throwing = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,7 +291,10 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
|
||||
//called when the item is equipped and right mouse button is pressed
|
||||
public virtual void Aim(float deltaTime, Character character = null) { }
|
||||
public virtual bool SecondaryUse(float deltaTime, Character character = null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//called when the item is placed in a "limbslot"
|
||||
public virtual void Equip(Character character) { }
|
||||
|
||||
@@ -160,7 +160,7 @@ namespace Barotrauma.Items.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Aim(float deltaTime, Character character = null)
|
||||
public override bool SecondaryUse(float deltaTime, Character character = null)
|
||||
{
|
||||
if (this.character == null || this.character != character || this.character.SelectedConstruction != item || !character.CanInteractWith(item))
|
||||
{
|
||||
|
||||
@@ -118,9 +118,9 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
}
|
||||
|
||||
public override void Aim(float deltaTime, Character character = null)
|
||||
public override bool SecondaryUse(float deltaTime, Character character = null)
|
||||
{
|
||||
if (reload > 0.0f) return;
|
||||
if (reload > 0.0f) return false;
|
||||
|
||||
bool first = true;
|
||||
for (int i = 0; i < ropeBodies.Length - 1; i++)
|
||||
@@ -157,7 +157,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
//ropeBodies[i + 1].ApplyForce(dist / length * pullForce * 0.1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void NextSection(int i)
|
||||
|
||||
@@ -242,7 +242,7 @@ namespace Barotrauma.Items.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Aim(float deltaTime, Character character = null)
|
||||
public override bool SecondaryUse(float deltaTime, Character character = null)
|
||||
{
|
||||
if (nodes.Count > 1)
|
||||
{
|
||||
@@ -251,6 +251,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
|
||||
Drawable = IsActive || sections.Count > 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Pick(Character picker)
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Barotrauma
|
||||
{
|
||||
public enum ActionType
|
||||
{
|
||||
Always, OnPicked, OnUse, OnAim,
|
||||
Always, OnPicked, OnUse, OnSecondaryUse,
|
||||
OnWearing, OnContaining, OnContained,
|
||||
OnActive, OnFailure, OnBroken,
|
||||
OnFire, InWater,
|
||||
@@ -800,6 +800,7 @@ namespace Barotrauma
|
||||
if (!ic.WasUsed)
|
||||
{
|
||||
ic.StopSounds(ActionType.OnUse);
|
||||
ic.StopSounds(ActionType.OnSecondaryUse);
|
||||
}
|
||||
#endif
|
||||
ic.WasUsed = false;
|
||||
@@ -1165,12 +1166,30 @@ namespace Barotrauma
|
||||
if (remove) Remove();
|
||||
}
|
||||
|
||||
public void SecondaryUse(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;
|
||||
ic.Aim(deltaTime, character);
|
||||
if (ic.Use(deltaTime, character))
|
||||
{
|
||||
ic.WasUsed = true;
|
||||
|
||||
#if CLIENT
|
||||
ic.PlaySound(ActionType.OnSecondaryUse, WorldPosition);
|
||||
#endif
|
||||
|
||||
ic.ApplyStatusEffects(ActionType.OnSecondaryUse, deltaTime, character);
|
||||
|
||||
if (ic.DeleteOnUse) remove = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (remove) Remove();
|
||||
}
|
||||
|
||||
public List<ColoredText> GetHUDTexts(Character character)
|
||||
|
||||
Reference in New Issue
Block a user