From 55dd58579fbdfaaef7779510200efe309d73d373 Mon Sep 17 00:00:00 2001 From: Alex Noir Date: Sun, 10 Dec 2017 15:56:34 +0300 Subject: [PATCH] I DID IT HOLY SHIT I GONE AND DONE IT OnSecondaryUse is what throwing uses for doing things SPECIFICALLY on throw. This way, you can theoretically have grenades on which you'll have to pull the pin before throwing. This also lets flares be used without the need to throw them. did i mention my brain hurts --- .../BarotraumaShared/Content/Items/Door/doors.xml | 4 ++-- .../Content/Items/Weapons/weapons.xml | 4 ++-- .../Source/Items/Components/Holdable/Throwable.cs | 14 ++++++++++++-- .../Source/Items/Components/Machines/Controller.cs | 8 +++++--- Barotrauma/BarotraumaShared/Source/Items/Item.cs | 2 +- 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Content/Items/Door/doors.xml b/Barotrauma/BarotraumaShared/Content/Items/Door/doors.xml index 5a9ee8cf4..120365d6c 100644 --- a/Barotrauma/BarotraumaShared/Content/Items/Door/doors.xml +++ b/Barotrauma/BarotraumaShared/Content/Items/Door/doors.xml @@ -96,7 +96,7 @@ - + @@ -127,7 +127,7 @@ - + diff --git a/Barotrauma/BarotraumaShared/Content/Items/Weapons/weapons.xml b/Barotrauma/BarotraumaShared/Content/Items/Weapons/weapons.xml index 454ed82e2..37854344d 100644 --- a/Barotrauma/BarotraumaShared/Content/Items/Weapons/weapons.xml +++ b/Barotrauma/BarotraumaShared/Content/Items/Weapons/weapons.xml @@ -117,7 +117,7 @@ - + @@ -134,7 +134,7 @@ - + diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Throwable.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Throwable.cs index bf5cc7835..968ece938 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Throwable.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Throwable.cs @@ -11,6 +11,7 @@ namespace Barotrauma.Items.Components float throwPos; bool throwing; + bool throwDone; [Serialize(1.0f, false)] public float ThrowForce @@ -32,7 +33,8 @@ namespace Barotrauma.Items.Components public override bool SecondaryUse(float deltaTime, Character character = null) { - if (!throwing) return false; //This should only be triggered + if (!throwDone) return false; //This should only be triggered in update + throwDone = false; return true; } @@ -52,7 +54,14 @@ namespace Barotrauma.Items.Components public override void Update(float deltaTime, Camera cam) { if (!item.body.Enabled) return; - if (!picker.HasSelectedItem(item)) IsActive = false; + if (!picker.HasSelectedItem(item)) + { + IsActive = false; + return; + } + + if (picker.IsKeyDown(InputType.Aim) && picker.IsKeyHit(InputType.Use)) + throwing = true; if (!picker.IsKeyDown(InputType.Aim) && !throwing) throwPos = 0.0f; @@ -98,6 +107,7 @@ namespace Barotrauma.Items.Components Limb rightHand = ac.GetLimb(LimbType.RightHand); item.body.AngularVelocity = rightHand.body.AngularVelocity; + throwDone = true; ApplyStatusEffects(ActionType.OnSecondaryUse, deltaTime, picker); //Stun grenades, flares, etc. all have their throw-related things handled in "onSecondaryUse" throwing = false; } diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Controller.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Controller.cs index ae4b7dde7..3dbd1799a 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Controller.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Controller.cs @@ -165,15 +165,15 @@ namespace Barotrauma.Items.Components if (this.character == null || this.character != character || this.character.SelectedConstruction != item || !character.CanInteractWith(item)) { character = null; - return; + return false; } - if (character == null) return; + if (character == null) return false; Entity focusTarget = GetFocusTarget(); if (focusTarget == null) { item.SendSignal(0, XMLExtensions.Vector2ToString(character.CursorWorldPosition), "position_out", character); - return; + return false; } character.ViewTarget = focusTarget; @@ -191,6 +191,8 @@ namespace Barotrauma.Items.Components { item.SendSignal(0, XMLExtensions.Vector2ToString(character.CursorWorldPosition), "position_out", character); } + + return true; } private Item GetFocusTarget() diff --git a/Barotrauma/BarotraumaShared/Source/Items/Item.cs b/Barotrauma/BarotraumaShared/Source/Items/Item.cs index 822a6ffe7..d6c4d2aad 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Item.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Item.cs @@ -1175,7 +1175,7 @@ namespace Barotrauma foreach (ItemComponent ic in components) { if (!ic.HasRequiredContainedItems(character == Character.Controlled)) continue; - if (ic.Use(deltaTime, character)) + if (ic.SecondaryUse(deltaTime, character)) { ic.WasUsed = true;