Renames "OnSecondaryUse" to "OnAim" for more sense
adds new "OnHudUse" to separate normal and self use
This commit is contained in:
@@ -96,7 +96,7 @@
|
||||
<DockingPort IsHorizontal="true" DistanceTolerance="128,64" DockedDistance="64">
|
||||
<Sprite texture ="dockingport.png" sourcerect="127,0,112,144" depth="0.05" origin="0.5,0.5"/>
|
||||
<sound file="dockingport1.ogg" type="OnUse" range="1000.0"/>
|
||||
<sound file="dockingport2.ogg" type="OnSecondaryUse" range="1000.0"/>
|
||||
<sound file="dockingport2.ogg" type="OnAim" range="1000.0"/>
|
||||
</DockingPort>
|
||||
|
||||
<PowerTransfer/>
|
||||
@@ -127,7 +127,7 @@
|
||||
<DockingPort IsHorizontal="false" DistanceTolerance="64,128" DockedDistance="64">
|
||||
<Sprite texture ="dockingport.png" sourcerect="127,144,48,112" depth="0.05" origin="0.5,0.5"/>
|
||||
<sound file="dockingport1.ogg" type="OnUse" range="1000.0"/>
|
||||
<sound file="dockingport2.ogg" type="OnSecondaryUse" range="1000.0"/>
|
||||
<sound file="dockingport2.ogg" type="OnAim" range="1000.0"/>
|
||||
</DockingPort>
|
||||
|
||||
<fixrequirement name="Electrical repairs">
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace Barotrauma
|
||||
Character.AnimController.TargetDir = Direction.Left;
|
||||
}
|
||||
|
||||
if (Character.SelectedConstruction != null) Character.SelectedConstruction.SecondaryUse(deltaTime, Character);
|
||||
if (Character.SelectedConstruction != null) Character.SelectedConstruction.Aim(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].SecondaryUse(deltaTime, this);
|
||||
if (IsKeyDown(InputType.Aim) && selectedItems[i] != null) selectedItems[i].Aim(deltaTime, this);
|
||||
}
|
||||
|
||||
if (selectedConstruction != null)
|
||||
{
|
||||
if (IsKeyDown(InputType.Use)) selectedConstruction.Use(deltaTime, this);
|
||||
if (selectedConstruction != null && IsKeyDown(InputType.Aim)) selectedConstruction.SecondaryUse(deltaTime, this);
|
||||
if (selectedConstruction != null && IsKeyDown(InputType.Aim)) selectedConstruction.Aim(deltaTime, this);
|
||||
}
|
||||
|
||||
if (SelectedCharacter != null)
|
||||
|
||||
@@ -41,6 +41,7 @@ namespace Barotrauma
|
||||
private readonly float duration;
|
||||
|
||||
private readonly bool useItem;
|
||||
private readonly bool hudUseItem;
|
||||
|
||||
public readonly ActionType type;
|
||||
|
||||
@@ -166,9 +167,11 @@ 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);
|
||||
@@ -258,6 +261,13 @@ 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,6 +36,7 @@ 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)
|
||||
{
|
||||
@@ -46,10 +47,10 @@ namespace Barotrauma
|
||||
|
||||
if (GameMain.Server != null)
|
||||
{
|
||||
GameMain.Server.CreateEntityEvent(Items[slotIndex], new object[] { NetEntityEvent.Type.ApplyStatusEffect, ActionType.OnUse, character.ID });
|
||||
GameMain.Server.CreateEntityEvent(Items[slotIndex], new object[] { NetEntityEvent.Type.ApplyStatusEffect, ActionType.OnHudUse, character.ID });
|
||||
}
|
||||
|
||||
Items[slotIndex].ApplyStatusEffects(ActionType.OnUse, 1.0f, character);
|
||||
Items[slotIndex].ApplyStatusEffects(ActionType.OnHudUse, 1.0f, character);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ namespace Barotrauma.Items.Components
|
||||
dockingTarget.dockingDir = -dockingDir;
|
||||
|
||||
#if CLIENT
|
||||
PlaySound(ActionType.OnSecondaryUse, item.WorldPosition);
|
||||
PlaySound(ActionType.OnAim, item.WorldPosition);
|
||||
#endif
|
||||
|
||||
ConnectWireBetweenPorts();
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Barotrauma.Items.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void SecondaryUse(float deltaTime, Character character = null)
|
||||
public override void Aim(float deltaTime, Character character = null)
|
||||
{
|
||||
if (throwing) return;
|
||||
}
|
||||
|
||||
@@ -290,8 +290,15 @@ 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 SecondaryUse(float deltaTime, Character character = null) { }
|
||||
public virtual void Aim(float deltaTime, Character character = null) { }
|
||||
|
||||
//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 SecondaryUse(float deltaTime, Character character = null)
|
||||
public override void Aim(float deltaTime, Character character = null)
|
||||
{
|
||||
if (this.character == null || this.character != character || this.character.SelectedConstruction != item || !character.CanInteractWith(item))
|
||||
{
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
}
|
||||
|
||||
public override void SecondaryUse(float deltaTime, Character character = null)
|
||||
public override void Aim(float deltaTime, Character character = null)
|
||||
{
|
||||
if (reload > 0.0f) return;
|
||||
|
||||
|
||||
@@ -242,7 +242,7 @@ namespace Barotrauma.Items.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void SecondaryUse(float deltaTime, Character character = null)
|
||||
public override void Aim(float deltaTime, Character character = null)
|
||||
{
|
||||
if (nodes.Count > 1)
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Barotrauma
|
||||
{
|
||||
public enum ActionType
|
||||
{
|
||||
Always, OnPicked, OnUse, OnSecondaryUse,
|
||||
Always, OnPicked, OnUse, OnHudUse, OnAim,
|
||||
OnWearing, OnContaining, OnContained,
|
||||
OnActive, OnFailure, OnBroken,
|
||||
OnFire, InWater,
|
||||
@@ -800,6 +800,7 @@ namespace Barotrauma
|
||||
if (!ic.WasUsed)
|
||||
{
|
||||
ic.StopSounds(ActionType.OnUse);
|
||||
ic.StopSounds(ActionType.OnHudUse);
|
||||
}
|
||||
#endif
|
||||
ic.WasUsed = false;
|
||||
@@ -1165,12 +1166,38 @@ namespace Barotrauma
|
||||
if (remove) Remove();
|
||||
}
|
||||
|
||||
public void SecondaryUse(float deltaTime, Character character = null)
|
||||
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)
|
||||
{
|
||||
if (!ic.HasRequiredContainedItems(character == Character.Controlled)) continue;
|
||||
ic.SecondaryUse(deltaTime, character);
|
||||
ic.Aim(deltaTime, character);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user