Fix being able to use invalid verbs as a ghost (#1157)
* Add CanInteract check to 18 verbs * Add more caninteract checks to verbs without it Storage toggle open, ammo box dump, bolt open and close, revolver spin and magazine open and close
This commit is contained in:
@@ -219,23 +219,23 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
|||||||
{
|
{
|
||||||
protected override void GetData(IEntity user, SolutionComponent component, VerbData data)
|
protected override void GetData(IEntity user, SolutionComponent component, VerbData data)
|
||||||
{
|
{
|
||||||
if (user.TryGetComponent<HandsComponent>(out var hands))
|
if (!ActionBlockerSystem.CanInteract(user) ||
|
||||||
|
!user.TryGetComponent<HandsComponent>(out var hands) ||
|
||||||
|
hands.GetActiveHand == null ||
|
||||||
|
!hands.GetActiveHand.Owner.TryGetComponent<SolutionComponent>(out var solution))
|
||||||
{
|
{
|
||||||
if (hands.GetActiveHand != null)
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
{
|
return;
|
||||||
if (hands.GetActiveHand.Owner.TryGetComponent<SolutionComponent>(out var solution))
|
}
|
||||||
{
|
|
||||||
if ((solution.Capabilities & SolutionCaps.PourOut) != 0 &&
|
|
||||||
(component.Capabilities & SolutionCaps.PourIn) != 0)
|
|
||||||
{
|
|
||||||
var heldEntityName = hands.GetActiveHand.Owner?.Prototype?.Name ?? "<Item>";
|
|
||||||
var myName = component.Owner.Prototype?.Name ?? "<Item>";
|
|
||||||
|
|
||||||
data.Text= $"Transfer liquid from [{heldEntityName}] to [{myName}].";
|
if ((solution.Capabilities & SolutionCaps.PourOut) != 0 &&
|
||||||
return;
|
(component.Capabilities & SolutionCaps.PourIn) != 0)
|
||||||
}
|
{
|
||||||
}
|
var heldEntityName = hands.GetActiveHand.Owner?.Prototype?.Name ?? "<Item>";
|
||||||
}
|
var myName = component.Owner.Prototype?.Name ?? "<Item>";
|
||||||
|
|
||||||
|
data.Text= $"Transfer liquid from [{heldEntityName}] to [{myName}].";
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
data.Visibility = VerbVisibility.Invisible;
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
@@ -318,23 +318,23 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
|||||||
{
|
{
|
||||||
protected override void GetData(IEntity user, SolutionComponent component, VerbData data)
|
protected override void GetData(IEntity user, SolutionComponent component, VerbData data)
|
||||||
{
|
{
|
||||||
if (user.TryGetComponent<HandsComponent>(out var hands))
|
if (!ActionBlockerSystem.CanInteract(user) ||
|
||||||
|
!user.TryGetComponent<HandsComponent>(out var hands) ||
|
||||||
|
hands.GetActiveHand == null ||
|
||||||
|
!hands.GetActiveHand.Owner.TryGetComponent<SolutionComponent>(out var solution))
|
||||||
{
|
{
|
||||||
if (hands.GetActiveHand != null)
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
{
|
return;
|
||||||
if (hands.GetActiveHand.Owner.TryGetComponent<SolutionComponent>(out var solution))
|
}
|
||||||
{
|
|
||||||
if ((solution.Capabilities & SolutionCaps.PourIn) != 0 &&
|
|
||||||
(component.Capabilities & SolutionCaps.PourOut) != 0)
|
|
||||||
{
|
|
||||||
var heldEntityName = hands.GetActiveHand.Owner?.Prototype?.Name ?? "<Item>";
|
|
||||||
var myName = component.Owner.Prototype?.Name ?? "<Item>";
|
|
||||||
|
|
||||||
data.Text = $"Transfer liquid from [{myName}] to [{heldEntityName}].";
|
if ((solution.Capabilities & SolutionCaps.PourIn) != 0 &&
|
||||||
return;
|
(component.Capabilities & SolutionCaps.PourOut) != 0)
|
||||||
}
|
{
|
||||||
}
|
var heldEntityName = hands.GetActiveHand.Owner?.Prototype?.Name ?? "<Item>";
|
||||||
}
|
var myName = component.Owner.Prototype?.Name ?? "<Item>";
|
||||||
|
|
||||||
|
data.Text = $"Transfer liquid from [{myName}] to [{heldEntityName}].";
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
data.Visibility = VerbVisibility.Invisible;
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using Content.Server.GameObjects.Components.Chemistry;
|
using Content.Server.GameObjects.Components.Chemistry;
|
||||||
|
using Content.Server.GameObjects.EntitySystems;
|
||||||
using Content.Shared.Chemistry;
|
using Content.Shared.Chemistry;
|
||||||
using Content.Shared.GameObjects;
|
using Content.Shared.GameObjects;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
@@ -21,7 +22,8 @@ namespace Content.Server.GameObjects.Components.Fluids
|
|||||||
{
|
{
|
||||||
protected override void GetData(IEntity user, CanSpillComponent component, VerbData data)
|
protected override void GetData(IEntity user, CanSpillComponent component, VerbData data)
|
||||||
{
|
{
|
||||||
if (!component.Owner.TryGetComponent(out SolutionComponent solutionComponent))
|
if (!ActionBlockerSystem.CanInteract(user) ||
|
||||||
|
!component.Owner.TryGetComponent(out SolutionComponent solutionComponent))
|
||||||
{
|
{
|
||||||
data.Visibility = VerbVisibility.Invisible;
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -240,6 +240,12 @@ namespace Content.Server.GameObjects.Components.Interactable
|
|||||||
{
|
{
|
||||||
protected override void GetData(IEntity user, HandheldLightComponent component, VerbData data)
|
protected override void GetData(IEntity user, HandheldLightComponent component, VerbData data)
|
||||||
{
|
{
|
||||||
|
if (!ActionBlockerSystem.CanInteract(user))
|
||||||
|
{
|
||||||
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (component.Cell == null)
|
if (component.Cell == null)
|
||||||
{
|
{
|
||||||
data.Text = "Eject cell (cell missing)";
|
data.Text = "Eject cell (cell missing)";
|
||||||
|
|||||||
@@ -338,8 +338,13 @@ namespace Content.Server.GameObjects.Components
|
|||||||
{
|
{
|
||||||
protected override void GetData(IEntity user, EntityStorageComponent component, VerbData data)
|
protected override void GetData(IEntity user, EntityStorageComponent component, VerbData data)
|
||||||
{
|
{
|
||||||
component.OpenVerbGetData(user, component, data);
|
if (!ActionBlockerSystem.CanInteract(user))
|
||||||
|
{
|
||||||
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
component.OpenVerbGetData(user, component, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -351,6 +356,12 @@ namespace Content.Server.GameObjects.Components
|
|||||||
|
|
||||||
protected virtual void OpenVerbGetData(IEntity user, EntityStorageComponent component, VerbData data)
|
protected virtual void OpenVerbGetData(IEntity user, EntityStorageComponent component, VerbData data)
|
||||||
{
|
{
|
||||||
|
if (!ActionBlockerSystem.CanInteract(user))
|
||||||
|
{
|
||||||
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (IsWeldedShut)
|
if (IsWeldedShut)
|
||||||
{
|
{
|
||||||
data.Visibility = VerbVisibility.Disabled;
|
data.Visibility = VerbVisibility.Disabled;
|
||||||
|
|||||||
@@ -116,7 +116,9 @@ namespace Content.Server.GameObjects
|
|||||||
{
|
{
|
||||||
protected override void GetData(IEntity user, ItemComponent component, VerbData data)
|
protected override void GetData(IEntity user, ItemComponent component, VerbData data)
|
||||||
{
|
{
|
||||||
if (ContainerHelpers.IsInContainer(component.Owner) || !component.CanPickup(user))
|
if (!ActionBlockerSystem.CanInteract(user) ||
|
||||||
|
ContainerHelpers.IsInContainer(component.Owner) ||
|
||||||
|
!component.CanPickup(user))
|
||||||
{
|
{
|
||||||
data.Visibility = VerbVisibility.Invisible;
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
|
|||||||
{
|
{
|
||||||
protected override void GetData(IEntity user, SecureEntityStorageComponent component, VerbData data)
|
protected override void GetData(IEntity user, SecureEntityStorageComponent component, VerbData data)
|
||||||
{
|
{
|
||||||
if (component.Open)
|
if (!ActionBlockerSystem.CanInteract(user) || component.Open)
|
||||||
{
|
{
|
||||||
data.Visibility = VerbVisibility.Invisible;
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -133,6 +133,12 @@ namespace Content.Server.GameObjects.Components.Medical
|
|||||||
{
|
{
|
||||||
protected override void GetData(IEntity user, MedicalScannerComponent component, VerbData data)
|
protected override void GetData(IEntity user, MedicalScannerComponent component, VerbData data)
|
||||||
{
|
{
|
||||||
|
if (!ActionBlockerSystem.CanInteract(user))
|
||||||
|
{
|
||||||
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
data.Text = "Enter";
|
data.Text = "Enter";
|
||||||
data.Visibility = component.IsOccupied ? VerbVisibility.Invisible : VerbVisibility.Visible;
|
data.Visibility = component.IsOccupied ? VerbVisibility.Invisible : VerbVisibility.Visible;
|
||||||
}
|
}
|
||||||
@@ -148,6 +154,12 @@ namespace Content.Server.GameObjects.Components.Medical
|
|||||||
{
|
{
|
||||||
protected override void GetData(IEntity user, MedicalScannerComponent component, VerbData data)
|
protected override void GetData(IEntity user, MedicalScannerComponent component, VerbData data)
|
||||||
{
|
{
|
||||||
|
if (!ActionBlockerSystem.CanInteract(user))
|
||||||
|
{
|
||||||
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
data.Text = "Eject";
|
data.Text = "Eject";
|
||||||
data.Visibility = component.IsOccupied ? VerbVisibility.Visible : VerbVisibility.Invisible;
|
data.Visibility = component.IsOccupied ? VerbVisibility.Visible : VerbVisibility.Invisible;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -250,6 +250,12 @@ namespace Content.Server.GameObjects.Components.PDA
|
|||||||
{
|
{
|
||||||
protected override void GetData(IEntity user, PDAComponent component, VerbData data)
|
protected override void GetData(IEntity user, PDAComponent component, VerbData data)
|
||||||
{
|
{
|
||||||
|
if (!ActionBlockerSystem.CanInteract(user))
|
||||||
|
{
|
||||||
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
data.Text = Loc.GetString("Eject ID");
|
data.Text = Loc.GetString("Eject ID");
|
||||||
data.Visibility = component.IdSlotEmpty ? VerbVisibility.Invisible : VerbVisibility.Visible;
|
data.Visibility = component.IdSlotEmpty ? VerbVisibility.Invisible : VerbVisibility.Visible;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,12 @@ namespace Content.Server.GameObjects.Components.Power.Chargers
|
|||||||
{
|
{
|
||||||
protected override void GetData(IEntity user, PowerCellChargerComponent component, VerbData data)
|
protected override void GetData(IEntity user, PowerCellChargerComponent component, VerbData data)
|
||||||
{
|
{
|
||||||
|
if (!ActionBlockerSystem.CanInteract(user))
|
||||||
|
{
|
||||||
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!user.TryGetComponent(out HandsComponent handsComponent))
|
if (!user.TryGetComponent(out HandsComponent handsComponent))
|
||||||
{
|
{
|
||||||
data.Visibility = VerbVisibility.Invisible;
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
@@ -99,6 +105,12 @@ namespace Content.Server.GameObjects.Components.Power.Chargers
|
|||||||
{
|
{
|
||||||
protected override void GetData(IEntity user, PowerCellChargerComponent component, VerbData data)
|
protected override void GetData(IEntity user, PowerCellChargerComponent component, VerbData data)
|
||||||
{
|
{
|
||||||
|
if (!ActionBlockerSystem.CanInteract(user))
|
||||||
|
{
|
||||||
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (component._container.ContainedEntity == null)
|
if (component._container.ContainedEntity == null)
|
||||||
{
|
{
|
||||||
data.Text = "Eject";
|
data.Text = "Eject";
|
||||||
|
|||||||
@@ -46,6 +46,12 @@ namespace Content.Server.GameObjects.Components.Power.Chargers
|
|||||||
{
|
{
|
||||||
protected override void GetData(IEntity user, WeaponCapacitorChargerComponent component, VerbData data)
|
protected override void GetData(IEntity user, WeaponCapacitorChargerComponent component, VerbData data)
|
||||||
{
|
{
|
||||||
|
if (!ActionBlockerSystem.CanInteract(user))
|
||||||
|
{
|
||||||
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!user.TryGetComponent(out HandsComponent handsComponent))
|
if (!user.TryGetComponent(out HandsComponent handsComponent))
|
||||||
{
|
{
|
||||||
data.Visibility = VerbVisibility.Invisible;
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
@@ -89,6 +95,12 @@ namespace Content.Server.GameObjects.Components.Power.Chargers
|
|||||||
{
|
{
|
||||||
protected override void GetData(IEntity user, WeaponCapacitorChargerComponent component, VerbData data)
|
protected override void GetData(IEntity user, WeaponCapacitorChargerComponent component, VerbData data)
|
||||||
{
|
{
|
||||||
|
if (!ActionBlockerSystem.CanInteract(user))
|
||||||
|
{
|
||||||
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (component._container.ContainedEntity == null)
|
if (component._container.ContainedEntity == null)
|
||||||
{
|
{
|
||||||
data.Visibility = VerbVisibility.Disabled;
|
data.Visibility = VerbVisibility.Disabled;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Content.Server.GameObjects.EntitySystems;
|
||||||
using Content.Server.Interfaces;
|
using Content.Server.Interfaces;
|
||||||
using Content.Shared.GameObjects;
|
using Content.Shared.GameObjects;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
@@ -37,6 +38,12 @@ namespace Content.Server.GameObjects.Components
|
|||||||
{
|
{
|
||||||
protected override void GetData(IEntity user, RotatableComponent component, VerbData data)
|
protected override void GetData(IEntity user, RotatableComponent component, VerbData data)
|
||||||
{
|
{
|
||||||
|
if (!ActionBlockerSystem.CanInteract(user))
|
||||||
|
{
|
||||||
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
data.CategoryData = VerbCategories.Rotate;
|
data.CategoryData = VerbCategories.Rotate;
|
||||||
data.Text = "Rotate clockwise";
|
data.Text = "Rotate clockwise";
|
||||||
data.IconTexture = "/Textures/UserInterface/VerbIcons/rotate_cw.svg.96dpi.png";
|
data.IconTexture = "/Textures/UserInterface/VerbIcons/rotate_cw.svg.96dpi.png";
|
||||||
@@ -53,6 +60,12 @@ namespace Content.Server.GameObjects.Components
|
|||||||
{
|
{
|
||||||
protected override void GetData(IEntity user, RotatableComponent component, VerbData data)
|
protected override void GetData(IEntity user, RotatableComponent component, VerbData data)
|
||||||
{
|
{
|
||||||
|
if (!ActionBlockerSystem.CanInteract(user))
|
||||||
|
{
|
||||||
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
data.CategoryData = VerbCategories.Rotate;
|
data.CategoryData = VerbCategories.Rotate;
|
||||||
data.Text = "Rotate counter-clockwise";
|
data.Text = "Rotate counter-clockwise";
|
||||||
data.IconTexture = "/Textures/UserInterface/VerbIcons/rotate_ccw.svg.96dpi.png";
|
data.IconTexture = "/Textures/UserInterface/VerbIcons/rotate_ccw.svg.96dpi.png";
|
||||||
|
|||||||
@@ -252,6 +252,12 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
|
|||||||
{
|
{
|
||||||
protected override void GetData(IEntity user, StunbatonComponent component, VerbData data)
|
protected override void GetData(IEntity user, StunbatonComponent component, VerbData data)
|
||||||
{
|
{
|
||||||
|
if (!ActionBlockerSystem.CanInteract(user))
|
||||||
|
{
|
||||||
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (component.Cell == null)
|
if (component.Cell == null)
|
||||||
{
|
{
|
||||||
data.Text = "Eject cell (cell missing)";
|
data.Text = "Eject cell (cell missing)";
|
||||||
|
|||||||
@@ -63,9 +63,9 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition
|
|||||||
_ammoContainer.Insert(entity);
|
_ammoContainer.Insert(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IMapInit.MapInit()
|
void IMapInit.MapInit()
|
||||||
{
|
{
|
||||||
_unspawnedCount += _capacity;
|
_unspawnedCount += _capacity;
|
||||||
@@ -117,7 +117,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition
|
|||||||
Owner.PopupMessage(user, Loc.GetString("No room"));
|
Owner.PopupMessage(user, Loc.GetString("No room"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_spawnedAmmo.Push(entity);
|
_spawnedAmmo.Push(entity);
|
||||||
_ammoContainer.Insert(entity);
|
_ammoContainer.Insert(entity);
|
||||||
UpdateAppearance();
|
UpdateAppearance();
|
||||||
@@ -136,7 +136,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition
|
|||||||
for (var i = 0; i < Math.Max(10, rangedMagazine.ShotsLeft); i++)
|
for (var i = 0; i < Math.Max(10, rangedMagazine.ShotsLeft); i++)
|
||||||
{
|
{
|
||||||
var ammo = rangedMagazine.TakeAmmo();
|
var ammo = rangedMagazine.TakeAmmo();
|
||||||
|
|
||||||
if (!TryInsertAmmo(eventArgs.User, ammo))
|
if (!TryInsertAmmo(eventArgs.User, ammo))
|
||||||
{
|
{
|
||||||
rangedMagazine.TryInsertAmmo(eventArgs.User, ammo);
|
rangedMagazine.TryInsertAmmo(eventArgs.User, ammo);
|
||||||
@@ -146,7 +146,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,7 +175,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition
|
|||||||
{
|
{
|
||||||
var ejectCount = Math.Min(count, Capacity);
|
var ejectCount = Math.Min(count, Capacity);
|
||||||
var ejectAmmo = new List<IEntity>(ejectCount);
|
var ejectAmmo = new List<IEntity>(ejectCount);
|
||||||
|
|
||||||
for (var i = 0; i < Math.Min(count, Capacity); i++)
|
for (var i = 0; i < Math.Min(count, Capacity); i++)
|
||||||
{
|
{
|
||||||
var ammo = TakeAmmo();
|
var ammo = TakeAmmo();
|
||||||
@@ -200,13 +200,19 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition
|
|||||||
{
|
{
|
||||||
return TryUse(eventArgs.User);
|
return TryUse(eventArgs.User);
|
||||||
}
|
}
|
||||||
|
|
||||||
// So if you have 200 rounds in a box and that suddenly creates 200 entities you're not having a fun time
|
// So if you have 200 rounds in a box and that suddenly creates 200 entities you're not having a fun time
|
||||||
[Verb]
|
[Verb]
|
||||||
private sealed class DumpVerb : Verb<AmmoBoxComponent>
|
private sealed class DumpVerb : Verb<AmmoBoxComponent>
|
||||||
{
|
{
|
||||||
protected override void GetData(IEntity user, AmmoBoxComponent component, VerbData data)
|
protected override void GetData(IEntity user, AmmoBoxComponent component, VerbData data)
|
||||||
{
|
{
|
||||||
|
if (!ActionBlockerSystem.CanInteract(user))
|
||||||
|
{
|
||||||
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
data.Text = Loc.GetString("Dump 10");
|
data.Text = Loc.GetString("Dump 10");
|
||||||
data.Visibility = component.AmmoLeft > 0 ? VerbVisibility.Visible : VerbVisibility.Disabled;
|
data.Visibility = component.AmmoLeft > 0 ? VerbVisibility.Visible : VerbVisibility.Disabled;
|
||||||
}
|
}
|
||||||
@@ -217,4 +223,4 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
{
|
{
|
||||||
// Originally I had this logic shared with PumpBarrel and used a couple of variables to control things
|
// Originally I had this logic shared with PumpBarrel and used a couple of variables to control things
|
||||||
// but it felt a lot messier to play around with, especially when adding verbs
|
// but it felt a lot messier to play around with, especially when adding verbs
|
||||||
|
|
||||||
public override string Name => "BoltActionBarrel";
|
public override string Name => "BoltActionBarrel";
|
||||||
|
|
||||||
public override int ShotsLeft
|
public override int ShotsLeft
|
||||||
@@ -62,7 +62,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
}
|
}
|
||||||
|
|
||||||
var soundSystem = EntitySystem.Get<AudioSystem>();
|
var soundSystem = EntitySystem.Get<AudioSystem>();
|
||||||
|
|
||||||
if (value)
|
if (value)
|
||||||
{
|
{
|
||||||
if (_soundBoltOpen != null)
|
if (_soundBoltOpen != null)
|
||||||
@@ -77,7 +77,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
soundSystem.PlayAtCoords(_soundBoltClosed, Owner.Transform.GridPosition, AudioParams.Default.WithVolume(-2));
|
soundSystem.PlayAtCoords(_soundBoltClosed, Owner.Transform.GridPosition, AudioParams.Default.WithVolume(-2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_boltOpen = value;
|
_boltOpen = value;
|
||||||
UpdateAppearance();
|
UpdateAppearance();
|
||||||
}
|
}
|
||||||
@@ -105,7 +105,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
serializer.DataField(ref _soundBoltClosed, "soundBoltClosed", "/Audio/Guns/Bolt/rifle_bolt_closed.ogg");
|
serializer.DataField(ref _soundBoltClosed, "soundBoltClosed", "/Audio/Guns/Bolt/rifle_bolt_closed.ogg");
|
||||||
serializer.DataField(ref _soundInsert, "soundInsert", "/Audio/Guns/MagIn/bullet_insert.ogg");
|
serializer.DataField(ref _soundInsert, "soundInsert", "/Audio/Guns/MagIn/bullet_insert.ogg");
|
||||||
}
|
}
|
||||||
|
|
||||||
void IMapInit.MapInit()
|
void IMapInit.MapInit()
|
||||||
{
|
{
|
||||||
if (_fillPrototype != null)
|
if (_fillPrototype != null)
|
||||||
@@ -137,7 +137,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
{
|
{
|
||||||
_appearanceComponent = appearanceComponent;
|
_appearanceComponent = appearanceComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
_appearanceComponent?.SetData(MagazineBarrelVisuals.MagLoaded, true);
|
_appearanceComponent?.SetData(MagazineBarrelVisuals.MagLoaded, true);
|
||||||
UpdateAppearance();
|
UpdateAppearance();
|
||||||
}
|
}
|
||||||
@@ -183,7 +183,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
var ammoComponent = chamberedEntity.GetComponent<AmmoComponent>();
|
var ammoComponent = chamberedEntity.GetComponent<AmmoComponent>();
|
||||||
if (!ammoComponent.Caseless)
|
if (!ammoComponent.Caseless)
|
||||||
{
|
{
|
||||||
EjectCasing(chamberedEntity);
|
EjectCasing(chamberedEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,7 +216,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
EntitySystem.Get<AudioSystem>().PlayAtCoords(_soundCycle, Owner.Transform.GridPosition, AudioParams.Default.WithVolume(-2));
|
EntitySystem.Get<AudioSystem>().PlayAtCoords(_soundCycle, Owner.Transform.GridPosition, AudioParams.Default.WithVolume(-2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Dirty();
|
Dirty();
|
||||||
UpdateAppearance();
|
UpdateAppearance();
|
||||||
}
|
}
|
||||||
@@ -264,9 +264,9 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
UpdateAppearance();
|
UpdateAppearance();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Owner.PopupMessage(user, Loc.GetString("No room"));
|
Owner.PopupMessage(user, Loc.GetString("No room"));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,7 +279,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
// Dirty();
|
// Dirty();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cycle(true);
|
Cycle(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -288,12 +288,18 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
{
|
{
|
||||||
return TryInsertBullet(eventArgs.User, eventArgs.Using);
|
return TryInsertBullet(eventArgs.User, eventArgs.Using);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Verb]
|
[Verb]
|
||||||
private sealed class OpenBoltVerb : Verb<BoltActionBarrelComponent>
|
private sealed class OpenBoltVerb : Verb<BoltActionBarrelComponent>
|
||||||
{
|
{
|
||||||
protected override void GetData(IEntity user, BoltActionBarrelComponent component, VerbData data)
|
protected override void GetData(IEntity user, BoltActionBarrelComponent component, VerbData data)
|
||||||
{
|
{
|
||||||
|
if (!ActionBlockerSystem.CanInteract(user))
|
||||||
|
{
|
||||||
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
data.Text = Loc.GetString("Open bolt");
|
data.Text = Loc.GetString("Open bolt");
|
||||||
data.Visibility = component.BoltOpen ? VerbVisibility.Disabled : VerbVisibility.Visible;
|
data.Visibility = component.BoltOpen ? VerbVisibility.Disabled : VerbVisibility.Visible;
|
||||||
}
|
}
|
||||||
@@ -303,12 +309,18 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
component.BoltOpen = true;
|
component.BoltOpen = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Verb]
|
[Verb]
|
||||||
private sealed class CloseBoltVerb : Verb<BoltActionBarrelComponent>
|
private sealed class CloseBoltVerb : Verb<BoltActionBarrelComponent>
|
||||||
{
|
{
|
||||||
protected override void GetData(IEntity user, BoltActionBarrelComponent component, VerbData data)
|
protected override void GetData(IEntity user, BoltActionBarrelComponent component, VerbData data)
|
||||||
{
|
{
|
||||||
|
if (!ActionBlockerSystem.CanInteract(user))
|
||||||
|
{
|
||||||
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
data.Text = Loc.GetString("Close bolt");
|
data.Text = Loc.GetString("Close bolt");
|
||||||
data.Visibility = component.BoltOpen ? VerbVisibility.Visible : VerbVisibility.Disabled;
|
data.Visibility = component.BoltOpen ? VerbVisibility.Visible : VerbVisibility.Disabled;
|
||||||
}
|
}
|
||||||
@@ -319,4 +331,4 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -221,6 +221,12 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
{
|
{
|
||||||
protected override void GetData(IEntity user, RevolverBarrelComponent component, VerbData data)
|
protected override void GetData(IEntity user, RevolverBarrelComponent component, VerbData data)
|
||||||
{
|
{
|
||||||
|
if (!ActionBlockerSystem.CanInteract(user))
|
||||||
|
{
|
||||||
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
data.Text = Loc.GetString("Spin");
|
data.Text = Loc.GetString("Spin");
|
||||||
if (component.Capacity <= 1)
|
if (component.Capacity <= 1)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
{
|
{
|
||||||
public override string Name => "MagazineBarrel";
|
public override string Name => "MagazineBarrel";
|
||||||
public override uint? NetID => ContentNetIDs.MAGAZINE_BARREL;
|
public override uint? NetID => ContentNetIDs.MAGAZINE_BARREL;
|
||||||
|
|
||||||
private ContainerSlot _chamberContainer;
|
private ContainerSlot _chamberContainer;
|
||||||
[ViewVariables] public bool HasMagazine => _magazineContainer.ContainedEntity != null;
|
[ViewVariables] public bool HasMagazine => _magazineContainer.ContainedEntity != null;
|
||||||
private ContainerSlot _magazineContainer;
|
private ContainerSlot _magazineContainer;
|
||||||
@@ -118,11 +118,11 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
{
|
{
|
||||||
count = (rangedMagazineComponent.ShotsLeft, rangedMagazineComponent.Capacity);
|
count = (rangedMagazineComponent.ShotsLeft, rangedMagazineComponent.Capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new MagazineBarrelComponentState(
|
return new MagazineBarrelComponentState(
|
||||||
_chamberContainer.ContainedEntity != null,
|
_chamberContainer.ContainedEntity != null,
|
||||||
FireRateSelector,
|
FireRateSelector,
|
||||||
count,
|
count,
|
||||||
SoundGunshot);
|
SoundGunshot);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
{
|
{
|
||||||
_appearanceComponent = appearanceComponent;
|
_appearanceComponent = appearanceComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
_chamberContainer = ContainerManagerComponent.Ensure<ContainerSlot>($"{Name}-chamber", Owner);
|
_chamberContainer = ContainerManagerComponent.Ensure<ContainerSlot>($"{Name}-chamber", Owner);
|
||||||
_magazineContainer = ContainerManagerComponent.Ensure<ContainerSlot>($"{Name}-magazine", Owner);
|
_magazineContainer = ContainerManagerComponent.Ensure<ContainerSlot>($"{Name}-magazine", Owner);
|
||||||
}
|
}
|
||||||
@@ -194,7 +194,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
var ammoComponent = chamberEntity.GetComponent<AmmoComponent>();
|
var ammoComponent = chamberEntity.GetComponent<AmmoComponent>();
|
||||||
if (!ammoComponent.Caseless)
|
if (!ammoComponent.Caseless)
|
||||||
{
|
{
|
||||||
EjectCasing(chamberEntity);
|
EjectCasing(chamberEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,7 +207,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
// If you're really into gunporn you could put a sound here
|
// If you're really into gunporn you could put a sound here
|
||||||
_chamberContainer.Insert(nextRound);
|
_chamberContainer.Insert(nextRound);
|
||||||
}
|
}
|
||||||
|
|
||||||
var soundSystem = EntitySystem.Get<AudioSystem>();
|
var soundSystem = EntitySystem.Get<AudioSystem>();
|
||||||
|
|
||||||
if (_autoEjectMag && magazine != null && magazine.GetComponent<RangedMagazineComponent>().ShotsLeft == 0)
|
if (_autoEjectMag && magazine != null && magazine.GetComponent<RangedMagazineComponent>().ShotsLeft == 0)
|
||||||
@@ -245,7 +245,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
soundSystem.PlayAtCoords(_soundRack, Owner.Transform.GridPosition, AudioParams.Default.WithVolume(-2));
|
soundSystem.PlayAtCoords(_soundRack, Owner.Transform.GridPosition, AudioParams.Default.WithVolume(-2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Dirty();
|
Dirty();
|
||||||
UpdateAppearance();
|
UpdateAppearance();
|
||||||
}
|
}
|
||||||
@@ -310,7 +310,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
{
|
{
|
||||||
handsComponent.PutInHandOrDrop(mag.GetComponent<ItemComponent>());
|
handsComponent.PutInHandOrDrop(mag.GetComponent<ItemComponent>());
|
||||||
}
|
}
|
||||||
|
|
||||||
Dirty();
|
Dirty();
|
||||||
UpdateAppearance();
|
UpdateAppearance();
|
||||||
}
|
}
|
||||||
@@ -385,12 +385,18 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Verb]
|
[Verb]
|
||||||
private sealed class EjectMagazineVerb : Verb<ServerMagazineBarrelComponent>
|
private sealed class EjectMagazineVerb : Verb<ServerMagazineBarrelComponent>
|
||||||
{
|
{
|
||||||
protected override void GetData(IEntity user, ServerMagazineBarrelComponent component, VerbData data)
|
protected override void GetData(IEntity user, ServerMagazineBarrelComponent component, VerbData data)
|
||||||
{
|
{
|
||||||
|
if (!ActionBlockerSystem.CanInteract(user))
|
||||||
|
{
|
||||||
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
data.Text = Loc.GetString("Eject magazine");
|
data.Text = Loc.GetString("Eject magazine");
|
||||||
if (component.MagNeedsOpenBolt)
|
if (component.MagNeedsOpenBolt)
|
||||||
{
|
{
|
||||||
@@ -408,12 +414,18 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
component.RemoveMagazine(user);
|
component.RemoveMagazine(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Verb]
|
[Verb]
|
||||||
private sealed class OpenBoltVerb : Verb<ServerMagazineBarrelComponent>
|
private sealed class OpenBoltVerb : Verb<ServerMagazineBarrelComponent>
|
||||||
{
|
{
|
||||||
protected override void GetData(IEntity user, ServerMagazineBarrelComponent component, VerbData data)
|
protected override void GetData(IEntity user, ServerMagazineBarrelComponent component, VerbData data)
|
||||||
{
|
{
|
||||||
|
if (!ActionBlockerSystem.CanInteract(user))
|
||||||
|
{
|
||||||
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
data.Text = Loc.GetString("Open bolt");
|
data.Text = Loc.GetString("Open bolt");
|
||||||
data.Visibility = component.BoltOpen ? VerbVisibility.Disabled : VerbVisibility.Visible;
|
data.Visibility = component.BoltOpen ? VerbVisibility.Disabled : VerbVisibility.Visible;
|
||||||
}
|
}
|
||||||
@@ -423,12 +435,18 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
component.ToggleBolt();
|
component.ToggleBolt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Verb]
|
[Verb]
|
||||||
private sealed class CloseBoltVerb : Verb<ServerMagazineBarrelComponent>
|
private sealed class CloseBoltVerb : Verb<ServerMagazineBarrelComponent>
|
||||||
{
|
{
|
||||||
protected override void GetData(IEntity user, ServerMagazineBarrelComponent component, VerbData data)
|
protected override void GetData(IEntity user, ServerMagazineBarrelComponent component, VerbData data)
|
||||||
{
|
{
|
||||||
|
if (!ActionBlockerSystem.CanInteract(user))
|
||||||
|
{
|
||||||
|
data.Visibility = VerbVisibility.Invisible;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
data.Text = Loc.GetString("Close bolt");
|
data.Text = Loc.GetString("Close bolt");
|
||||||
data.Visibility = component.BoltOpen ? VerbVisibility.Visible : VerbVisibility.Disabled;
|
data.Visibility = component.BoltOpen ? VerbVisibility.Visible : VerbVisibility.Disabled;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user