Fixed railguns and depth charge tubes being directly usable by characters (= they could be launched simply by selecting them and left clicking, without the need to use a railgun controller). Closes #754

This commit is contained in:
Joonas Rikkonen
2018-08-30 10:42:25 +03:00
parent 105461beb3
commit 2b18a1265a
3 changed files with 20 additions and 6 deletions
@@ -9,11 +9,12 @@
<Sprite texture ="railgunetc.png" depth="0.01" sourcerect="64,180,47,76"/> <Sprite texture ="railgunetc.png" depth="0.01" sourcerect="64,180,47,76"/>
<Turret canbeselected = "true" linkable="true" barrelpos="23, 76" <Turret canbeselected="false" linkable="true" characterusable="false"
barrelpos="23, 76"
rotationlimits="90,90" rotationlimits="90,90"
powerconsumption="0.0"/> powerconsumption="0.0"/>
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]"> <ConnectionPanel selectkey="Action" canbeselected="true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/> <requireditem name="Screwdriver,Wire" type="Equipped"/>
<input name="trigger_in"/> <input name="trigger_in"/>
</ConnectionPanel> </ConnectionPanel>
@@ -10,7 +10,8 @@
<StaticBody width="80" radius="80"/> <StaticBody width="80" radius="80"/>
<Turret barrelsprite="railgunbarrel.png" canbeselected = "true" linkable="true" origin="0.5, 0.85" barrelpos="128, 128" <Turret barrelsprite="railgunbarrel.png" canbeselected="false" characterusable="false" linkable="true"
origin="0.5, 0.85" barrelpos="128, 128"
rotationlimits="180,360" rotationlimits="180,360"
powerconsumption="20000.0" powerconsumption="20000.0"
showchargeindicator="true" showchargeindicator="true"
@@ -155,6 +155,12 @@ namespace Barotrauma.Items.Components
} }
public override bool Use(float deltaTime, Character character = null) public override bool Use(float deltaTime, Character character = null)
{
if (!characterUsable && character != null) return false;
return TryLaunch(character);
}
private bool TryLaunch(Character character = null)
{ {
if (GameMain.Client != null) return false; if (GameMain.Client != null) return false;
@@ -413,6 +419,12 @@ namespace Barotrauma.Items.Components
break; break;
case "trigger_in": case "trigger_in":
item.Use((float)Timing.Step, sender); item.Use((float)Timing.Step, sender);
//triggering the Use method through item.Use will fail if the item is not characterusable and the signal was sent by a character
//so lets do it manually
if (!characterUsable && sender != null)
{
TryLaunch(sender);
}
break; break;
} }
} }