AutoCompState + ItemToggle fixes (#23422)
* AutoCompState + ItemToggle fixes Fix a lot of the comp states that are never actually networked and also cleaned up ItemToggle events a bunch. ItemToggle will still need some future work for lights and sounds. * Also catch these
This commit is contained in:
@@ -5,6 +5,7 @@ using Content.Shared.Item;
|
|||||||
using Robust.Client.UserInterface;
|
using Robust.Client.UserInterface;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
|
using ItemToggleComponent = Content.Shared.Item.ItemToggle.Components.ItemToggleComponent;
|
||||||
|
|
||||||
namespace Content.Client.Tools.UI;
|
namespace Content.Client.Tools.UI;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
using Content.Shared.Weapons.Reflect;
|
|
||||||
|
|
||||||
namespace Content.Client.Weapons.Reflect;
|
|
||||||
|
|
||||||
public sealed class ReflectSystem : SharedReflectSystem
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -23,6 +23,7 @@ using Robust.Shared.Input;
|
|||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Map.Components;
|
using Robust.Shared.Map.Components;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
|
using ItemToggleComponent = Content.Shared.Item.ItemToggle.Components.ItemToggleComponent;
|
||||||
|
|
||||||
namespace Content.IntegrationTests.Tests.Interaction;
|
namespace Content.IntegrationTests.Tests.Interaction;
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using Content.Shared.Damage;
|
|||||||
using Content.Shared.Database;
|
using Content.Shared.Database;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Tools.Components;
|
using Content.Shared.Tools.Components;
|
||||||
|
using ItemToggleComponent = Content.Shared.Item.ItemToggle.Components.ItemToggleComponent;
|
||||||
|
|
||||||
namespace Content.Server.Damage.Systems
|
namespace Content.Server.Damage.Systems
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using Content.Shared.Eye.Blinding.Components;
|
|||||||
using Content.Shared.Eye.Blinding.Systems;
|
using Content.Shared.Eye.Blinding.Systems;
|
||||||
using Content.Shared.Tools.Components;
|
using Content.Shared.Tools.Components;
|
||||||
using Content.Shared.Item.ItemToggle;
|
using Content.Shared.Item.ItemToggle;
|
||||||
|
using Content.Shared.Item.ItemToggle.Components;
|
||||||
|
|
||||||
namespace Content.Server.Eye.Blinding.EyeProtection
|
namespace Content.Server.Eye.Blinding.EyeProtection
|
||||||
{
|
{
|
||||||
@@ -18,7 +19,7 @@ namespace Content.Server.Eye.Blinding.EyeProtection
|
|||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
SubscribeLocalEvent<RequiresEyeProtectionComponent, ToolUseAttemptEvent>(OnUseAttempt);
|
SubscribeLocalEvent<RequiresEyeProtectionComponent, ToolUseAttemptEvent>(OnUseAttempt);
|
||||||
SubscribeLocalEvent<RequiresEyeProtectionComponent, ItemToggleDoneEvent>(OnWelderToggled);
|
SubscribeLocalEvent<RequiresEyeProtectionComponent, ItemToggledEvent>(OnWelderToggled);
|
||||||
|
|
||||||
SubscribeLocalEvent<EyeProtectionComponent, GetEyeProtectionEvent>(OnGetProtection);
|
SubscribeLocalEvent<EyeProtectionComponent, GetEyeProtectionEvent>(OnGetProtection);
|
||||||
SubscribeLocalEvent<EyeProtectionComponent, InventoryRelayedEvent<GetEyeProtectionEvent>>(OnGetRelayedProtection);
|
SubscribeLocalEvent<EyeProtectionComponent, InventoryRelayedEvent<GetEyeProtectionEvent>>(OnGetRelayedProtection);
|
||||||
@@ -57,7 +58,7 @@ namespace Content.Server.Eye.Blinding.EyeProtection
|
|||||||
_statusEffectsSystem.TryAddStatusEffect(args.User, TemporaryBlindnessSystem.BlindingStatusEffect,
|
_statusEffectsSystem.TryAddStatusEffect(args.User, TemporaryBlindnessSystem.BlindingStatusEffect,
|
||||||
statusTimeSpan, false, TemporaryBlindnessSystem.BlindingStatusEffect);
|
statusTimeSpan, false, TemporaryBlindnessSystem.BlindingStatusEffect);
|
||||||
}
|
}
|
||||||
private void OnWelderToggled(EntityUid uid, RequiresEyeProtectionComponent component, ItemToggleDoneEvent args)
|
private void OnWelderToggled(EntityUid uid, RequiresEyeProtectionComponent component, ItemToggledEvent args)
|
||||||
{
|
{
|
||||||
component.Toggled = _itemToggle.IsActivated(uid);
|
component.Toggled = _itemToggle.IsActivated(uid);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ using Content.Shared.Item;
|
|||||||
using Content.Server.CombatMode.Disarm;
|
using Content.Server.CombatMode.Disarm;
|
||||||
using Content.Server.Kitchen.Components;
|
using Content.Server.Kitchen.Components;
|
||||||
using Content.Shared.Item.ItemToggle;
|
using Content.Shared.Item.ItemToggle;
|
||||||
|
using Content.Shared.Item.ItemToggle.Components;
|
||||||
|
using ItemToggleComponent = Content.Shared.Item.ItemToggle.Components.ItemToggleComponent;
|
||||||
|
|
||||||
namespace Content.Server.Item;
|
namespace Content.Server.Item;
|
||||||
|
|
||||||
@@ -11,10 +13,10 @@ public sealed class ItemToggleSystem : SharedItemToggleSystem
|
|||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
SubscribeLocalEvent<ItemToggleComponent, ItemToggleDoneEvent>(Toggle);
|
SubscribeLocalEvent<ItemToggleComponent, ItemToggledEvent>(Toggle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Toggle(EntityUid uid, ItemToggleComponent comp, ref ItemToggleDoneEvent args)
|
private void Toggle(EntityUid uid, ItemToggleComponent comp, ref ItemToggledEvent args)
|
||||||
{
|
{
|
||||||
if (args.Activated == true)
|
if (args.Activated == true)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ namespace Content.Server.Light.EntitySystems
|
|||||||
|
|
||||||
if (TryComp<ItemComponent>(ent, out var item))
|
if (TryComp<ItemComponent>(ent, out var item))
|
||||||
{
|
{
|
||||||
_item.SetHeldPrefix(ent, "unlit", item);
|
_item.SetHeldPrefix(ent, "unlit", component: item);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -96,7 +96,7 @@ namespace Content.Server.Light.EntitySystems
|
|||||||
{
|
{
|
||||||
if (TryComp<ItemComponent>(ent, out var item))
|
if (TryComp<ItemComponent>(ent, out var item))
|
||||||
{
|
{
|
||||||
_item.SetHeldPrefix(ent, "lit", item);
|
_item.SetHeldPrefix(ent, "lit", component: item);
|
||||||
}
|
}
|
||||||
|
|
||||||
component.CurrentState = ExpendableLightState.Lit;
|
component.CurrentState = ExpendableLightState.Lit;
|
||||||
@@ -163,7 +163,7 @@ namespace Content.Server.Light.EntitySystems
|
|||||||
{
|
{
|
||||||
if (TryComp<ItemComponent>(uid, out var item))
|
if (TryComp<ItemComponent>(uid, out var item))
|
||||||
{
|
{
|
||||||
_item.SetHeldPrefix(uid, "unlit", item);
|
_item.SetHeldPrefix(uid, "unlit", component: item);
|
||||||
}
|
}
|
||||||
|
|
||||||
component.CurrentState = ExpendableLightState.BrandNew;
|
component.CurrentState = ExpendableLightState.BrandNew;
|
||||||
|
|||||||
@@ -107,10 +107,10 @@ namespace Content.Server.Light.EntitySystems
|
|||||||
switch (component.CurrentState)
|
switch (component.CurrentState)
|
||||||
{
|
{
|
||||||
case SmokableState.Lit:
|
case SmokableState.Lit:
|
||||||
_item.SetHeldPrefix(uid, "lit", item);
|
_item.SetHeldPrefix(uid, "lit", component: item);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
_item.SetHeldPrefix(uid, "unlit", item);
|
_item.SetHeldPrefix(uid, "unlit", component: item);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using Content.Shared.Damage.Events;
|
|||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
using Content.Shared.Item;
|
using Content.Shared.Item;
|
||||||
using Content.Shared.Item.ItemToggle;
|
using Content.Shared.Item.ItemToggle;
|
||||||
|
using Content.Shared.Item.ItemToggle.Components;
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using Content.Shared.Stunnable;
|
using Content.Shared.Stunnable;
|
||||||
|
|
||||||
@@ -28,7 +29,7 @@ namespace Content.Server.Stunnable.Systems
|
|||||||
SubscribeLocalEvent<StunbatonComponent, SolutionContainerChangedEvent>(OnSolutionChange);
|
SubscribeLocalEvent<StunbatonComponent, SolutionContainerChangedEvent>(OnSolutionChange);
|
||||||
SubscribeLocalEvent<StunbatonComponent, StaminaDamageOnHitAttemptEvent>(OnStaminaHitAttempt);
|
SubscribeLocalEvent<StunbatonComponent, StaminaDamageOnHitAttemptEvent>(OnStaminaHitAttempt);
|
||||||
SubscribeLocalEvent<StunbatonComponent, ItemToggleActivateAttemptEvent>(TryTurnOn);
|
SubscribeLocalEvent<StunbatonComponent, ItemToggleActivateAttemptEvent>(TryTurnOn);
|
||||||
SubscribeLocalEvent<StunbatonComponent, ItemToggleDoneEvent>(ToggleDone);
|
SubscribeLocalEvent<StunbatonComponent, ItemToggledEvent>(ToggleDone);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnStaminaHitAttempt(Entity<StunbatonComponent> entity, ref StaminaDamageOnHitAttemptEvent args)
|
private void OnStaminaHitAttempt(Entity<StunbatonComponent> entity, ref StaminaDamageOnHitAttemptEvent args)
|
||||||
@@ -58,12 +59,12 @@ namespace Content.Server.Stunnable.Systems
|
|||||||
args.PushMarkup(chargeMessage);
|
args.PushMarkup(chargeMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ToggleDone(Entity<StunbatonComponent> entity, ref ItemToggleDoneEvent args)
|
private void ToggleDone(Entity<StunbatonComponent> entity, ref ItemToggledEvent args)
|
||||||
{
|
{
|
||||||
if (!TryComp<ItemComponent>(entity, out var item))
|
if (!TryComp<ItemComponent>(entity, out var item))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_item.SetHeldPrefix(entity.Owner, args.Activated ? "on" : "off", item);
|
_item.SetHeldPrefix(entity.Owner, args.Activated ? "on" : "off", component: item);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TryTurnOn(Entity<StunbatonComponent> entity, ref ItemToggleActivateAttemptEvent args)
|
private void TryTurnOn(Entity<StunbatonComponent> entity, ref ItemToggleActivateAttemptEvent args)
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ using Content.Shared.Item.ItemToggle;
|
|||||||
using Content.Shared.Tools.Components;
|
using Content.Shared.Tools.Components;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Content.Shared.Item.ItemToggle.Components;
|
||||||
|
|
||||||
namespace Content.Server.Tools
|
namespace Content.Server.Tools
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
using Content.Shared.Item;
|
|
||||||
using Content.Shared.Weapons.Reflect;
|
|
||||||
|
|
||||||
namespace Content.Server.Weapons.Reflect;
|
|
||||||
|
|
||||||
public sealed class ReflectSystem : SharedReflectSystem
|
|
||||||
{
|
|
||||||
public override void Initialize()
|
|
||||||
{
|
|
||||||
base.Initialize();
|
|
||||||
|
|
||||||
SubscribeLocalEvent<ReflectComponent, ItemToggleReflectUpdateEvent>(ToggleReflect);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ToggleReflect(EntityUid uid, ReflectComponent comp, ref ItemToggleReflectUpdateEvent args)
|
|
||||||
{
|
|
||||||
comp.Enabled = args.Activated;
|
|
||||||
Dirty(uid, comp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
|
|||||||
|
|
||||||
namespace Content.Shared.Clothing.Components;
|
namespace Content.Shared.Clothing.Components;
|
||||||
|
|
||||||
[RegisterComponent, NetworkedComponent]
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||||
public sealed partial class LoadoutComponent : Component
|
public sealed partial class LoadoutComponent : Component
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public abstract class SharedMagbootsSystem : EntitySystem
|
|||||||
|
|
||||||
if (TryComp<ItemComponent>(uid, out var item))
|
if (TryComp<ItemComponent>(uid, out var item))
|
||||||
{
|
{
|
||||||
_item.SetHeldPrefix(uid, magboots.On ? "on" : null, item);
|
_item.SetHeldPrefix(uid, magboots.On ? "on" : null, component: item);
|
||||||
_clothing.SetEquippedPrefix(uid, magboots.On ? "on" : null);
|
_clothing.SetEquippedPrefix(uid, magboots.On ? "on" : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
using Robust.Shared.GameStates;
|
||||||
|
|
||||||
namespace Content.Shared.ContainerHeld;
|
namespace Content.Shared.ContainerHeld;
|
||||||
|
|
||||||
[RegisterComponent]
|
[RegisterComponent, NetworkedComponent]
|
||||||
public sealed partial class ContainerHeldComponent: Component
|
public sealed partial class ContainerHeldComponent: Component
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public sealed class ContainerHeldSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnContainerModified(EntityUid uid, ContainerHeldComponent comp, ContainerModifiedMessage args)
|
private void OnContainerModified(EntityUid uid, ContainerHeldComponent comp, ContainerModifiedMessage args)
|
||||||
{
|
{
|
||||||
if (!(TryComp<StorageComponent>(uid, out var storage)
|
if (!(HasComp<StorageComponent>(uid)
|
||||||
&& TryComp<AppearanceComponent>(uid, out var appearance)
|
&& TryComp<AppearanceComponent>(uid, out var appearance)
|
||||||
&& TryComp<ItemComponent>(uid, out var item)))
|
&& TryComp<ItemComponent>(uid, out var item)))
|
||||||
{
|
{
|
||||||
@@ -31,12 +31,12 @@ public sealed class ContainerHeldSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
if (_storage.GetCumulativeItemAreas(uid) >= comp.Threshold)
|
if (_storage.GetCumulativeItemAreas(uid) >= comp.Threshold)
|
||||||
{
|
{
|
||||||
_item.SetHeldPrefix(uid, "full", item);
|
_item.SetHeldPrefix(uid, "full", component: item);
|
||||||
_appearance.SetData(uid, ToggleVisuals.Toggled, true, appearance);
|
_appearance.SetData(uid, ToggleVisuals.Toggled, true, appearance);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_item.SetHeldPrefix(uid, "empty", item);
|
_item.SetHeldPrefix(uid, "empty", component: item);
|
||||||
_appearance.SetData(uid, ToggleVisuals.Toggled, false, appearance);
|
_appearance.SetData(uid, ToggleVisuals.Toggled, false, appearance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ namespace Content.Shared.Item;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
[NetworkedComponent]
|
[NetworkedComponent]
|
||||||
[Access(typeof(SharedItemSystem))]
|
[Access(typeof(SharedItemSystem)), AutoGenerateComponentState(true)]
|
||||||
public sealed partial class ItemComponent : Component
|
public sealed partial class ItemComponent : Component
|
||||||
{
|
{
|
||||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
[DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
|
||||||
[Access(typeof(SharedItemSystem))]
|
[Access(typeof(SharedItemSystem))]
|
||||||
public ProtoId<ItemSizePrototype> Size = "Small";
|
public ProtoId<ItemSizePrototype> Size = "Small";
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ public sealed partial class ItemComponent : Component
|
|||||||
|
|
||||||
[Access(typeof(SharedItemSystem))]
|
[Access(typeof(SharedItemSystem))]
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
[DataField]
|
[DataField, AutoNetworkedField]
|
||||||
public string? HeldPrefix;
|
public string? HeldPrefix;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -56,19 +56,6 @@ public sealed partial class ItemComponent : Component
|
|||||||
public float StoredRotation = 0;
|
public float StoredRotation = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
|
||||||
public sealed class ItemComponentState : ComponentState
|
|
||||||
{
|
|
||||||
public ProtoId<ItemSizePrototype> Size { get; }
|
|
||||||
public string? HeldPrefix { get; }
|
|
||||||
|
|
||||||
public ItemComponentState(ProtoId<ItemSizePrototype> size, string? heldPrefix)
|
|
||||||
{
|
|
||||||
Size = size;
|
|
||||||
HeldPrefix = heldPrefix;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Raised when an item's visual state is changed. The event is directed at the entity that contains this item, so
|
/// Raised when an item's visual state is changed. The event is directed at the entity that contains this item, so
|
||||||
/// that it can properly update its hands or inventory sprites and GUI.
|
/// that it can properly update its hands or inventory sprites and GUI.
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
|
|
||||||
namespace Content.Shared.Item;
|
namespace Content.Shared.Item.ItemToggle.Components;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the active sound being played continuously with some items that are activated (ie e-sword hum).
|
/// Handles the active sound being played continuously with some items that are activated (ie e-sword hum).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent, NetworkedComponent]
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||||
public sealed partial class ItemToggleActiveSoundComponent : Component
|
public sealed partial class ItemToggleActiveSoundComponent : Component
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The continuous noise this item makes when it's activated (like an e-sword's hum). This loops.
|
/// The continuous noise this item makes when it's activated (like an e-sword's hum).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
|
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
|
||||||
public SoundSpecifier? ActiveSound;
|
public SoundSpecifier? ActiveSound;
|
||||||
@@ -18,17 +18,6 @@ public sealed partial class ItemToggleActiveSoundComponent : Component
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used when the item emits sound while active.
|
/// Used when the item emits sound while active.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
|
[ViewVariables(VVAccess.ReadWrite), DataField]
|
||||||
public EntityUid? PlayingStream;
|
public EntityUid? PlayingStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Raised in order to effect changes upon the ActiveSound of the entity.
|
|
||||||
/// </summary>
|
|
||||||
[ByRefEvent]
|
|
||||||
public record struct ItemToggleActiveSoundUpdateEvent(bool Activated, bool Predicted, EntityUid? User)
|
|
||||||
{
|
|
||||||
public bool Activated = Activated;
|
|
||||||
public bool Predicted = Predicted;
|
|
||||||
public EntityUid? User = User;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
|
|
||||||
namespace Content.Shared.Item;
|
namespace Content.Shared.Item.ItemToggle.Components;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles generic item toggles, like a welder turning on and off, or an e-sword.
|
/// Handles generic item toggles, like a welder turning on and off, or an e-sword.
|
||||||
@@ -54,7 +54,7 @@ public sealed partial class ItemToggleComponent : Component
|
|||||||
public record struct ItemToggleActivateAttemptEvent(EntityUid? User)
|
public record struct ItemToggleActivateAttemptEvent(EntityUid? User)
|
||||||
{
|
{
|
||||||
public bool Cancelled = false;
|
public bool Cancelled = false;
|
||||||
public EntityUid? User = User;
|
public readonly EntityUid? User = User;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -64,63 +64,34 @@ public record struct ItemToggleActivateAttemptEvent(EntityUid? User)
|
|||||||
public record struct ItemToggleDeactivateAttemptEvent(EntityUid? User)
|
public record struct ItemToggleDeactivateAttemptEvent(EntityUid? User)
|
||||||
{
|
{
|
||||||
public bool Cancelled = false;
|
public bool Cancelled = false;
|
||||||
public EntityUid? User = User;
|
public readonly EntityUid? User = User;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Raised directed on an entity any sort of toggle is complete.
|
/// Raised directed on an entity any sort of toggle is complete.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ByRefEvent]
|
[ByRefEvent]
|
||||||
public record struct ItemToggleDoneEvent(bool Activated, EntityUid? User)
|
public readonly record struct ItemToggledEvent(bool Predicted, bool Activated, EntityUid? User)
|
||||||
{
|
{
|
||||||
public bool Activated = Activated;
|
public readonly bool Predicted = Predicted;
|
||||||
public EntityUid? User = User;
|
public readonly bool Activated = Activated;
|
||||||
|
public readonly EntityUid? User = User;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Raised in order to play a toggle sound effect.
|
/// Raised directed on an entity when an itemtoggle is activated.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ByRefEvent]
|
[ByRefEvent]
|
||||||
public record struct ItemTogglePlayToggleSoundEvent(bool Activated, bool Predicted, EntityUid? User)
|
public readonly record struct ItemToggleActivatedEvent(EntityUid? User)
|
||||||
{
|
{
|
||||||
public bool Activated = Activated;
|
public readonly EntityUid? User = User;
|
||||||
public bool Predicted = Predicted;
|
|
||||||
public EntityUid? User = User;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Raised in order to play a failure to toggle sound effect.
|
/// Raised directed on an entity when an itemtoggle is deactivated.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ByRefEvent]
|
[ByRefEvent]
|
||||||
public record struct ItemTogglePlayFailSoundEvent(bool Predicted, EntityUid? User)
|
public readonly record struct ItemToggleDeactivatedEvent(EntityUid? User)
|
||||||
{
|
{
|
||||||
public bool Predicted = Predicted;
|
public readonly EntityUid? User = User;
|
||||||
public EntityUid? User = User;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Raised in order to effect changes upon the Light component of the entity.
|
|
||||||
/// </summary>
|
|
||||||
[ByRefEvent]
|
|
||||||
public record struct ItemToggleLightUpdateEvent(bool Activated)
|
|
||||||
{
|
|
||||||
public bool Activated = Activated;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Raised in order to effect changes upon the Appearance component of the entity.
|
|
||||||
/// </summary>
|
|
||||||
[ByRefEvent]
|
|
||||||
public record struct ItemToggleAppearanceUpdateEvent(bool Activated)
|
|
||||||
{
|
|
||||||
public bool Activated = Activated;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Raised in order to effect changes upon the Reflect component of the entity.
|
|
||||||
/// </summary>
|
|
||||||
[ByRefEvent]
|
|
||||||
public record struct ItemToggleReflectUpdateEvent(bool Activated)
|
|
||||||
{
|
|
||||||
public bool Activated = Activated;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
|
|
||||||
namespace Content.Shared.Item;
|
namespace Content.Shared.Item.ItemToggle.Components;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles whether the item is hot when toggled on.
|
/// Handles whether the item is hot when toggled on.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent, NetworkedComponent]
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||||
public sealed partial class ItemToggleHotComponent : Component
|
public sealed partial class ItemToggleHotComponent : Component
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using Robust.Shared.GameStates;
|
|
||||||
using Robust.Shared.Audio;
|
|
||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
|
using Robust.Shared.Audio;
|
||||||
|
using Robust.Shared.GameStates;
|
||||||
|
|
||||||
namespace Content.Shared.Item;
|
namespace Content.Shared.Item.ItemToggle.Components;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the changes to the melee weapon component when the item is toggled.
|
/// Handles the changes to the melee weapon component when the item is toggled.
|
||||||
@@ -10,7 +10,7 @@ namespace Content.Shared.Item;
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// You can change the damage, sound on hit, on swing, as well as hidden status while activated.
|
/// You can change the damage, sound on hit, on swing, as well as hidden status while activated.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[RegisterComponent, NetworkedComponent]
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||||
public sealed partial class ItemToggleMeleeWeaponComponent : Component
|
public sealed partial class ItemToggleMeleeWeaponComponent : Component
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -67,13 +67,3 @@ public sealed partial class ItemToggleMeleeWeaponComponent : Component
|
|||||||
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
|
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
|
||||||
public bool DeactivatedSecret = false;
|
public bool DeactivatedSecret = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Raised in order to effect changes upon the MeleeWeaponComponent of the entity.
|
|
||||||
/// </summary>
|
|
||||||
[ByRefEvent]
|
|
||||||
public record struct ItemToggleMeleeWeaponUpdateEvent(bool Activated)
|
|
||||||
{
|
|
||||||
public bool Activated = Activated;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
namespace Content.Shared.Item;
|
namespace Content.Shared.Item.ItemToggle.Components;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the changes to the item size when toggled.
|
/// Handles the changes to the item size when toggled.
|
||||||
@@ -9,7 +9,7 @@ namespace Content.Shared.Item;
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// You can change the size when activated or not. By default the sizes are copied from the item.
|
/// You can change the size when activated or not. By default the sizes are copied from the item.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[RegisterComponent, NetworkedComponent]
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||||
public sealed partial class ItemToggleSizeComponent : Component
|
public sealed partial class ItemToggleSizeComponent : Component
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -24,12 +24,3 @@ public sealed partial class ItemToggleSizeComponent : Component
|
|||||||
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
|
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
|
||||||
public ProtoId<ItemSizePrototype>? DeactivatedSize = null;
|
public ProtoId<ItemSizePrototype>? DeactivatedSize = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Raised in order to effect changes upon the MeleeWeaponComponent of the entity.
|
|
||||||
/// </summary>
|
|
||||||
[ByRefEvent]
|
|
||||||
public record struct ItemToggleSizeUpdateEvent(bool Activated)
|
|
||||||
{
|
|
||||||
public bool Activated = Activated;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
using Content.Shared.Interaction.Events;
|
using Content.Shared.Interaction.Events;
|
||||||
using Content.Shared.Toggleable;
|
using Content.Shared.Item.ItemToggle.Components;
|
||||||
using Content.Shared.Temperature;
|
using Content.Shared.Temperature;
|
||||||
|
using Content.Shared.Toggleable;
|
||||||
using Content.Shared.Wieldable;
|
using Content.Shared.Wieldable;
|
||||||
using Content.Shared.Wieldable.Components;
|
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.Audio.Systems;
|
using Robust.Shared.Audio.Systems;
|
||||||
using Robust.Shared.Prototypes;
|
|
||||||
using Robust.Shared.Network;
|
using Robust.Shared.Network;
|
||||||
|
|
||||||
namespace Content.Shared.Item.ItemToggle;
|
namespace Content.Shared.Item.ItemToggle;
|
||||||
@@ -29,12 +28,10 @@ public abstract class SharedItemToggleSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<ItemToggleComponent, ItemUnwieldedEvent>(TurnOffonUnwielded);
|
SubscribeLocalEvent<ItemToggleComponent, ItemUnwieldedEvent>(TurnOffonUnwielded);
|
||||||
SubscribeLocalEvent<ItemToggleComponent, ItemWieldedEvent>(TurnOnonWielded);
|
SubscribeLocalEvent<ItemToggleComponent, ItemWieldedEvent>(TurnOnonWielded);
|
||||||
SubscribeLocalEvent<ItemToggleComponent, UseInHandEvent>(OnUseInHand);
|
SubscribeLocalEvent<ItemToggleComponent, UseInHandEvent>(OnUseInHand);
|
||||||
|
|
||||||
SubscribeLocalEvent<ItemToggleHotComponent, IsHotEvent>(OnIsHotEvent);
|
SubscribeLocalEvent<ItemToggleHotComponent, IsHotEvent>(OnIsHotEvent);
|
||||||
SubscribeLocalEvent<ItemToggleActiveSoundComponent, ItemToggleActiveSoundUpdateEvent>(UpdateActiveSound);
|
|
||||||
SubscribeLocalEvent<AppearanceComponent, ItemToggleAppearanceUpdateEvent>(UpdateAppearance);
|
SubscribeLocalEvent<ItemToggleActiveSoundComponent, ItemToggledEvent>(UpdateActiveSound);
|
||||||
SubscribeLocalEvent<ItemToggleComponent, ItemToggleLightUpdateEvent>(UpdateLight);
|
|
||||||
SubscribeLocalEvent<ItemToggleComponent, ItemTogglePlayToggleSoundEvent>(PlayToggleSound);
|
|
||||||
SubscribeLocalEvent<ItemToggleComponent, ItemTogglePlayFailSoundEvent>(PlayFailToggleSound);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnUseInHand(EntityUid uid, ItemToggleComponent itemToggle, UseInHandEvent args)
|
private void OnUseInHand(EntityUid uid, ItemToggleComponent itemToggle, UseInHandEvent args)
|
||||||
@@ -81,9 +78,10 @@ public abstract class SharedItemToggleSystem : EntitySystem
|
|||||||
|
|
||||||
if (attempt.Cancelled)
|
if (attempt.Cancelled)
|
||||||
{
|
{
|
||||||
//Raises the event to play the failure to activate noise.
|
if (predicted)
|
||||||
var evPlayFailToggleSound = new ItemTogglePlayFailSoundEvent(Predicted: predicted, user);
|
_audio.PlayPredicted(itemToggle.SoundFailToActivate, uid, user);
|
||||||
RaiseLocalEvent(uid, ref evPlayFailToggleSound);
|
else
|
||||||
|
_audio.PlayPvs(itemToggle.SoundFailToActivate, uid);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -92,16 +90,7 @@ public abstract class SharedItemToggleSystem : EntitySystem
|
|||||||
if (predicted == false && _netManager.IsClient)
|
if (predicted == false && _netManager.IsClient)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Activate(uid, itemToggle);
|
Activate(uid, itemToggle, predicted, user);
|
||||||
|
|
||||||
var evPlayToggleSound = new ItemTogglePlayToggleSoundEvent(Activated: true, Predicted: predicted, user);
|
|
||||||
RaiseLocalEvent(uid, ref evPlayToggleSound);
|
|
||||||
|
|
||||||
var evActiveSound = new ItemToggleActiveSoundUpdateEvent(Activated: true, Predicted: predicted, user);
|
|
||||||
RaiseLocalEvent(uid, ref evActiveSound);
|
|
||||||
|
|
||||||
var toggleUsed = new ItemToggleDoneEvent(Activated: true, user);
|
|
||||||
RaiseLocalEvent(uid, ref toggleUsed);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -129,61 +118,78 @@ public abstract class SharedItemToggleSystem : EntitySystem
|
|||||||
if (predicted == false && _netManager.IsClient)
|
if (predicted == false && _netManager.IsClient)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Deactivate(uid, itemToggle);
|
Deactivate(uid, itemToggle, predicted, user);
|
||||||
|
|
||||||
var evPlayToggleSound = new ItemTogglePlayToggleSoundEvent(Activated: false, Predicted: predicted, user);
|
|
||||||
RaiseLocalEvent(uid, ref evPlayToggleSound);
|
|
||||||
|
|
||||||
var evActiveSound = new ItemToggleActiveSoundUpdateEvent(Activated: false, Predicted: predicted, user);
|
|
||||||
RaiseLocalEvent(uid, ref evActiveSound);
|
|
||||||
|
|
||||||
var toggleUsed = new ItemToggleDoneEvent(Activated: false, user);
|
|
||||||
RaiseLocalEvent(uid, ref toggleUsed);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
private void Activate(EntityUid uid, ItemToggleComponent itemToggle, bool predicted, EntityUid? user = null)
|
||||||
/// Used to make the actual changes to the item's components on activation.
|
|
||||||
/// </summary>
|
|
||||||
private void Activate(EntityUid uid, ItemToggleComponent itemToggle)
|
|
||||||
{
|
{
|
||||||
UpdateComponents(uid, itemToggle.Activated = true);
|
// TODO: Fix this hardcoding
|
||||||
|
TryComp(uid, out AppearanceComponent? appearance);
|
||||||
|
_appearance.SetData(uid, ToggleableLightVisuals.Enabled, true, appearance);
|
||||||
|
_appearance.SetData(uid, ToggleVisuals.Toggled, true, appearance);
|
||||||
|
|
||||||
|
if (_light.TryGetLight(uid, out var light))
|
||||||
|
{
|
||||||
|
_light.SetEnabled(uid, true, light);
|
||||||
|
}
|
||||||
|
|
||||||
|
SoundSpecifier? soundToPlay = itemToggle.SoundActivate;
|
||||||
|
|
||||||
|
if (soundToPlay == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (predicted)
|
||||||
|
_audio.PlayPredicted(soundToPlay, uid, user);
|
||||||
|
else
|
||||||
|
_audio.PlayPvs(soundToPlay, uid);
|
||||||
|
|
||||||
|
// END FIX HARDCODING
|
||||||
|
|
||||||
|
var toggleUsed = new ItemToggledEvent(predicted, Activated: true, user);
|
||||||
|
RaiseLocalEvent(uid, ref toggleUsed);
|
||||||
|
|
||||||
|
var activev = new ItemToggleActivatedEvent(user);
|
||||||
|
RaiseLocalEvent(uid, ref activev);
|
||||||
|
|
||||||
|
itemToggle.Activated = true;
|
||||||
Dirty(uid, itemToggle);
|
Dirty(uid, itemToggle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used to make the actual changes to the item's components on deactivation.
|
/// Used to make the actual changes to the item's components on deactivation.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void Deactivate(EntityUid uid, ItemToggleComponent itemToggle)
|
private void Deactivate(EntityUid uid, ItemToggleComponent itemToggle, bool predicted, EntityUid? user = null)
|
||||||
{
|
{
|
||||||
UpdateComponents(uid, itemToggle.Activated = false);
|
// TODO: Fix this hardcoding
|
||||||
|
TryComp(uid, out AppearanceComponent? appearance);
|
||||||
|
_appearance.SetData(uid, ToggleableLightVisuals.Enabled, false, appearance);
|
||||||
|
_appearance.SetData(uid, ToggleVisuals.Toggled, false, appearance);
|
||||||
|
|
||||||
|
if (_light.TryGetLight(uid, out var light))
|
||||||
|
{
|
||||||
|
_light.SetEnabled(uid, false, light);
|
||||||
|
}
|
||||||
|
|
||||||
|
var soundToPlay = itemToggle.SoundDeactivate;
|
||||||
|
|
||||||
|
if (predicted)
|
||||||
|
_audio.PlayPredicted(soundToPlay, uid, user);
|
||||||
|
else
|
||||||
|
_audio.PlayPvs(soundToPlay, uid);
|
||||||
|
|
||||||
|
// END FIX HARDCODING
|
||||||
|
|
||||||
|
var toggleUsed = new ItemToggledEvent(predicted, Activated: false, user);
|
||||||
|
RaiseLocalEvent(uid, ref toggleUsed);
|
||||||
|
|
||||||
|
var activev = new ItemToggleDeactivatedEvent(user);
|
||||||
|
RaiseLocalEvent(uid, ref activev);
|
||||||
|
|
||||||
|
itemToggle.Activated = false;
|
||||||
Dirty(uid, itemToggle);
|
Dirty(uid, itemToggle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Used to raise events to update components on toggle.
|
|
||||||
/// </summary>
|
|
||||||
private void UpdateComponents(EntityUid uid, bool activated)
|
|
||||||
{
|
|
||||||
var evSize = new ItemToggleSizeUpdateEvent(activated);
|
|
||||||
RaiseLocalEvent(uid, ref evSize);
|
|
||||||
|
|
||||||
var evMelee = new ItemToggleMeleeWeaponUpdateEvent(activated);
|
|
||||||
RaiseLocalEvent(uid, ref evMelee);
|
|
||||||
|
|
||||||
var evAppearance = new ItemToggleAppearanceUpdateEvent(activated);
|
|
||||||
RaiseLocalEvent(uid, ref evAppearance);
|
|
||||||
|
|
||||||
var evLight = new ItemToggleLightUpdateEvent(activated);
|
|
||||||
RaiseLocalEvent(uid, ref evLight);
|
|
||||||
|
|
||||||
var evReflect = new ItemToggleReflectUpdateEvent(activated);
|
|
||||||
RaiseLocalEvent(uid, ref evReflect);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used for items that require to be wielded in both hands to activate. For instance the dual energy sword will turn off if not wielded.
|
/// Used for items that require to be wielded in both hands to activate. For instance the dual energy sword will turn off if not wielded.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -219,30 +225,10 @@ public abstract class SharedItemToggleSystem : EntitySystem
|
|||||||
args.IsHot = IsActivated(uid);
|
args.IsHot = IsActivated(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Used to update item appearance.
|
|
||||||
/// </summary>
|
|
||||||
private void UpdateAppearance(EntityUid uid, AppearanceComponent appearance, ref ItemToggleAppearanceUpdateEvent args)
|
|
||||||
{
|
|
||||||
_appearance.SetData(uid, ToggleableLightVisuals.Enabled, args.Activated, appearance);
|
|
||||||
_appearance.SetData(uid, ToggleVisuals.Toggled, args.Activated, appearance);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Used to update light settings.
|
|
||||||
/// </summary>
|
|
||||||
private void UpdateLight(EntityUid uid, ItemToggleComponent comp, ref ItemToggleLightUpdateEvent args)
|
|
||||||
{
|
|
||||||
if (!_light.TryGetLight(uid, out var light))
|
|
||||||
return;
|
|
||||||
|
|
||||||
_light.SetEnabled(uid, args.Activated, light);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used to update the looping active sound linked to the entity.
|
/// Used to update the looping active sound linked to the entity.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void UpdateActiveSound(EntityUid uid, ItemToggleActiveSoundComponent activeSound, ref ItemToggleActiveSoundUpdateEvent args)
|
private void UpdateActiveSound(EntityUid uid, ItemToggleActiveSoundComponent activeSound, ref ItemToggledEvent args)
|
||||||
{
|
{
|
||||||
if (args.Activated)
|
if (args.Activated)
|
||||||
{
|
{
|
||||||
@@ -259,35 +245,4 @@ public abstract class SharedItemToggleSystem : EntitySystem
|
|||||||
activeSound.PlayingStream = _audio.Stop(activeSound.PlayingStream);
|
activeSound.PlayingStream = _audio.Stop(activeSound.PlayingStream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Used to play a toggle sound.
|
|
||||||
/// </summary>
|
|
||||||
private void PlayToggleSound(EntityUid uid, ItemToggleComponent itemToggle, ref ItemTogglePlayToggleSoundEvent args)
|
|
||||||
{
|
|
||||||
SoundSpecifier? soundToPlay;
|
|
||||||
if (args.Activated)
|
|
||||||
soundToPlay = itemToggle.SoundActivate;
|
|
||||||
else
|
|
||||||
soundToPlay = itemToggle.SoundDeactivate;
|
|
||||||
|
|
||||||
if (soundToPlay == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (args.Predicted)
|
|
||||||
_audio.PlayPredicted(soundToPlay, uid, args.User);
|
|
||||||
else
|
|
||||||
_audio.PlayPvs(soundToPlay, uid);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Used to play a failure to toggle sound.
|
|
||||||
/// </summary>
|
|
||||||
private void PlayFailToggleSound(EntityUid uid, ItemToggleComponent itemToggle, ref ItemTogglePlayFailSoundEvent args)
|
|
||||||
{
|
|
||||||
if (args.Predicted)
|
|
||||||
_audio.PlayPredicted(itemToggle.SoundFailToActivate, uid, args.User);
|
|
||||||
else
|
|
||||||
_audio.PlayPvs(itemToggle.SoundFailToActivate, uid);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using Content.Shared.Hands.EntitySystems;
|
|||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Verbs;
|
using Content.Shared.Verbs;
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
|
using Content.Shared.Item.ItemToggle.Components;
|
||||||
using Content.Shared.Storage;
|
using Content.Shared.Storage;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
@@ -21,14 +22,17 @@ public abstract class SharedItemSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
SubscribeLocalEvent<ItemComponent, GetVerbsEvent<InteractionVerb>>(AddPickupVerb);
|
SubscribeLocalEvent<ItemComponent, GetVerbsEvent<InteractionVerb>>(AddPickupVerb);
|
||||||
SubscribeLocalEvent<ItemComponent, InteractHandEvent>(OnHandInteract, before: new []{typeof(SharedItemSystem)});
|
SubscribeLocalEvent<ItemComponent, InteractHandEvent>(OnHandInteract);
|
||||||
|
SubscribeLocalEvent<ItemComponent, AfterAutoHandleStateEvent>(OnItemAutoState);
|
||||||
SubscribeLocalEvent<ItemComponent, ComponentGetState>(OnGetState);
|
|
||||||
SubscribeLocalEvent<ItemComponent, ComponentHandleState>(OnHandleState);
|
|
||||||
|
|
||||||
SubscribeLocalEvent<ItemComponent, ExaminedEvent>(OnExamine);
|
SubscribeLocalEvent<ItemComponent, ExaminedEvent>(OnExamine);
|
||||||
|
|
||||||
SubscribeLocalEvent<ItemToggleSizeComponent, ItemToggleSizeUpdateEvent>(OnItemToggle);
|
SubscribeLocalEvent<ItemToggleSizeComponent, ItemToggledEvent>(OnItemToggle);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnItemAutoState(EntityUid uid, ItemComponent component, ref AfterAutoHandleStateEvent args)
|
||||||
|
{
|
||||||
|
SetHeldPrefix(uid, component.HeldPrefix, force: true, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Public API
|
#region Public API
|
||||||
@@ -42,12 +46,12 @@ public abstract class SharedItemSystem : EntitySystem
|
|||||||
Dirty(uid, component);
|
Dirty(uid, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetHeldPrefix(EntityUid uid, string? heldPrefix, ItemComponent? component = null)
|
public void SetHeldPrefix(EntityUid uid, string? heldPrefix, bool force = false, ItemComponent? component = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref component, false))
|
if (!Resolve(uid, ref component, false))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (component.HeldPrefix == heldPrefix)
|
if (!force && component.HeldPrefix == heldPrefix)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
component.HeldPrefix = heldPrefix;
|
component.HeldPrefix = heldPrefix;
|
||||||
@@ -81,20 +85,6 @@ public abstract class SharedItemSystem : EntitySystem
|
|||||||
args.Handled = _handsSystem.TryPickup(args.User, uid, animateUser: false);
|
args.Handled = _handsSystem.TryPickup(args.User, uid, animateUser: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnHandleState(EntityUid uid, ItemComponent component, ref ComponentHandleState args)
|
|
||||||
{
|
|
||||||
if (args.Current is not ItemComponentState state)
|
|
||||||
return;
|
|
||||||
|
|
||||||
component.Size = state.Size;
|
|
||||||
SetHeldPrefix(uid, state.HeldPrefix, component);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnGetState(EntityUid uid, ItemComponent component, ref ComponentGetState args)
|
|
||||||
{
|
|
||||||
args.State = new ItemComponentState(component.Size, component.HeldPrefix);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void AddPickupVerb(EntityUid uid, ItemComponent component, GetVerbsEvent<InteractionVerb> args)
|
private void AddPickupVerb(EntityUid uid, ItemComponent component, GetVerbsEvent<InteractionVerb> args)
|
||||||
{
|
{
|
||||||
if (args.Hands == null ||
|
if (args.Hands == null ||
|
||||||
@@ -211,7 +201,7 @@ public abstract class SharedItemSystem : EntitySystem
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used to update the Item component on item toggle (specifically size).
|
/// Used to update the Item component on item toggle (specifically size).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void OnItemToggle(EntityUid uid, ItemToggleSizeComponent itemToggleSize, ItemToggleSizeUpdateEvent args)
|
private void OnItemToggle(EntityUid uid, ItemToggleSizeComponent itemToggleSize, ItemToggledEvent args)
|
||||||
{
|
{
|
||||||
if (!TryComp(uid, out ItemComponent? item))
|
if (!TryComp(uid, out ItemComponent? item))
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace Content.Shared.Ninja.Components;
|
|||||||
/// Component for ninja suit abilities and power consumption.
|
/// Component for ninja suit abilities and power consumption.
|
||||||
/// As an implementation detail, dashing with katana is a suit action which isn't ideal.
|
/// As an implementation detail, dashing with katana is a suit action which isn't ideal.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent, NetworkedComponent, Access(typeof(SharedNinjaSuitSystem))]
|
[RegisterComponent, NetworkedComponent, Access(typeof(SharedNinjaSuitSystem)), AutoGenerateComponentState]
|
||||||
public sealed partial class NinjaSuitComponent : Component
|
public sealed partial class NinjaSuitComponent : Component
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace Content.Shared.Sericulture;
|
|||||||
/// Should be applied to any mob that you want to be able to produce any material with an action and the cost of hunger.
|
/// Should be applied to any mob that you want to be able to produce any material with an action and the cost of hunger.
|
||||||
/// TODO: Probably adjust this to utilize organs?
|
/// TODO: Probably adjust this to utilize organs?
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent, NetworkedComponent, Access(typeof(SharedSericultureSystem))]
|
[RegisterComponent, NetworkedComponent, Access(typeof(SharedSericultureSystem)), AutoGenerateComponentState]
|
||||||
public sealed partial class SericultureComponent : Component
|
public sealed partial class SericultureComponent : Component
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace Content.Shared.Teleportation.Components;
|
|||||||
/// Marks an entity as being a 'portal' which teleports entities sent through it to linked entities.
|
/// Marks an entity as being a 'portal' which teleports entities sent through it to linked entities.
|
||||||
/// Relies on <see cref="LinkedEntityComponent"/> being set up.
|
/// Relies on <see cref="LinkedEntityComponent"/> being set up.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent, NetworkedComponent]
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||||
public sealed partial class PortalComponent : Component
|
public sealed partial class PortalComponent : Component
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ using Content.Shared.Hands.Components;
|
|||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Inventory;
|
using Content.Shared.Inventory;
|
||||||
using Content.Shared.Item;
|
using Content.Shared.Item;
|
||||||
|
using Content.Shared.Item.ItemToggle.Components;
|
||||||
using Content.Shared.Physics;
|
using Content.Shared.Physics;
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using Content.Shared.Weapons.Melee.Components;
|
using Content.Shared.Weapons.Melee.Components;
|
||||||
@@ -29,6 +30,7 @@ using Robust.Shared.Player;
|
|||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
using Robust.Shared.Toolshed.Syntax;
|
using Robust.Shared.Toolshed.Syntax;
|
||||||
|
using ItemToggleMeleeWeaponComponent = Content.Shared.Item.ItemToggle.Components.ItemToggleMeleeWeaponComponent;
|
||||||
|
|
||||||
namespace Content.Shared.Weapons.Melee;
|
namespace Content.Shared.Weapons.Melee;
|
||||||
|
|
||||||
@@ -74,7 +76,7 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<BonusMeleeDamageComponent, GetHeavyDamageModifierEvent>(OnGetBonusHeavyDamageModifier);
|
SubscribeLocalEvent<BonusMeleeDamageComponent, GetHeavyDamageModifierEvent>(OnGetBonusHeavyDamageModifier);
|
||||||
SubscribeLocalEvent<BonusMeleeAttackRateComponent, GetMeleeAttackRateEvent>(OnGetBonusMeleeAttackRate);
|
SubscribeLocalEvent<BonusMeleeAttackRateComponent, GetMeleeAttackRateEvent>(OnGetBonusMeleeAttackRate);
|
||||||
|
|
||||||
SubscribeLocalEvent<ItemToggleMeleeWeaponComponent, ItemToggleMeleeWeaponUpdateEvent>(OnItemToggle);
|
SubscribeLocalEvent<ItemToggleMeleeWeaponComponent, ItemToggledEvent>(OnItemToggle);
|
||||||
|
|
||||||
SubscribeAllEvent<HeavyAttackEvent>(OnHeavyAttack);
|
SubscribeAllEvent<HeavyAttackEvent>(OnHeavyAttack);
|
||||||
SubscribeAllEvent<LightAttackEvent>(OnLightAttack);
|
SubscribeAllEvent<LightAttackEvent>(OnLightAttack);
|
||||||
@@ -864,7 +866,7 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used to update the MeleeWeapon component on item toggle.
|
/// Used to update the MeleeWeapon component on item toggle.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void OnItemToggle(EntityUid uid, ItemToggleMeleeWeaponComponent itemToggleMelee, ItemToggleMeleeWeaponUpdateEvent args)
|
private void OnItemToggle(EntityUid uid, ItemToggleMeleeWeaponComponent itemToggleMelee, ItemToggledEvent args)
|
||||||
{
|
{
|
||||||
if (!TryComp(uid, out MeleeWeaponComponent? meleeWeapon))
|
if (!TryComp(uid, out MeleeWeaponComponent? meleeWeapon))
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using Content.Shared.Database;
|
|||||||
using Content.Shared.Hands;
|
using Content.Shared.Hands;
|
||||||
using Content.Shared.Inventory;
|
using Content.Shared.Inventory;
|
||||||
using Content.Shared.Inventory.Events;
|
using Content.Shared.Inventory.Events;
|
||||||
|
using Content.Shared.Item.ItemToggle.Components;
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using Content.Shared.Projectiles;
|
using Content.Shared.Projectiles;
|
||||||
using Content.Shared.Weapons.Ranged.Components;
|
using Content.Shared.Weapons.Ranged.Components;
|
||||||
@@ -23,7 +24,7 @@ namespace Content.Shared.Weapons.Reflect;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// This handles reflecting projectiles and hitscan shots.
|
/// This handles reflecting projectiles and hitscan shots.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class SharedReflectSystem : EntitySystem
|
public sealed class ReflectSystem : EntitySystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly INetManager _netManager = default!;
|
[Dependency] private readonly INetManager _netManager = default!;
|
||||||
[Dependency] private readonly IRobustRandom _random = default!;
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
@@ -41,13 +42,14 @@ public abstract class SharedReflectSystem : EntitySystem
|
|||||||
|
|
||||||
SubscribeLocalEvent<ReflectComponent, ProjectileReflectAttemptEvent>(OnReflectCollide);
|
SubscribeLocalEvent<ReflectComponent, ProjectileReflectAttemptEvent>(OnReflectCollide);
|
||||||
SubscribeLocalEvent<ReflectComponent, HitScanReflectAttemptEvent>(OnReflectHitscan);
|
SubscribeLocalEvent<ReflectComponent, HitScanReflectAttemptEvent>(OnReflectHitscan);
|
||||||
SubscribeLocalEvent<ReflectUserComponent, ProjectileReflectAttemptEvent>(OnReflectUserCollide);
|
|
||||||
SubscribeLocalEvent<ReflectUserComponent, HitScanReflectAttemptEvent>(OnReflectUserHitscan);
|
|
||||||
|
|
||||||
SubscribeLocalEvent<ReflectComponent, GotEquippedEvent>(OnReflectEquipped);
|
SubscribeLocalEvent<ReflectComponent, GotEquippedEvent>(OnReflectEquipped);
|
||||||
SubscribeLocalEvent<ReflectComponent, GotUnequippedEvent>(OnReflectUnequipped);
|
SubscribeLocalEvent<ReflectComponent, GotUnequippedEvent>(OnReflectUnequipped);
|
||||||
SubscribeLocalEvent<ReflectComponent, GotEquippedHandEvent>(OnReflectHandEquipped);
|
SubscribeLocalEvent<ReflectComponent, GotEquippedHandEvent>(OnReflectHandEquipped);
|
||||||
SubscribeLocalEvent<ReflectComponent, GotUnequippedHandEvent>(OnReflectHandUnequipped);
|
SubscribeLocalEvent<ReflectComponent, GotUnequippedHandEvent>(OnReflectHandUnequipped);
|
||||||
|
SubscribeLocalEvent<ReflectComponent, ItemToggledEvent>(OnToggleReflect);
|
||||||
|
|
||||||
|
SubscribeLocalEvent<ReflectUserComponent, ProjectileReflectAttemptEvent>(OnReflectUserCollide);
|
||||||
|
SubscribeLocalEvent<ReflectUserComponent, HitScanReflectAttemptEvent>(OnReflectUserHitscan);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnReflectUserHitscan(EntityUid uid, ReflectUserComponent component, ref HitScanReflectAttemptEvent args)
|
private void OnReflectUserHitscan(EntityUid uid, ReflectUserComponent component, ref HitScanReflectAttemptEvent args)
|
||||||
@@ -209,6 +211,12 @@ public abstract class SharedReflectSystem : EntitySystem
|
|||||||
RefreshReflectUser(args.User);
|
RefreshReflectUser(args.User);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnToggleReflect(EntityUid uid, ReflectComponent comp, ref ItemToggledEvent args)
|
||||||
|
{
|
||||||
|
comp.Enabled = args.Activated;
|
||||||
|
Dirty(uid, comp);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Refreshes whether someone has reflection potential so we can raise directed events on them.
|
/// Refreshes whether someone has reflection potential so we can raise directed events on them.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -177,7 +177,7 @@ public sealed class WieldableSystem : EntitySystem
|
|||||||
if (TryComp<ItemComponent>(used, out var item))
|
if (TryComp<ItemComponent>(used, out var item))
|
||||||
{
|
{
|
||||||
component.OldInhandPrefix = item.HeldPrefix;
|
component.OldInhandPrefix = item.HeldPrefix;
|
||||||
_itemSystem.SetHeldPrefix(used, component.WieldedInhandPrefix, item);
|
_itemSystem.SetHeldPrefix(used, component.WieldedInhandPrefix, component: item);
|
||||||
}
|
}
|
||||||
|
|
||||||
component.Wielded = true;
|
component.Wielded = true;
|
||||||
@@ -229,7 +229,7 @@ public sealed class WieldableSystem : EntitySystem
|
|||||||
|
|
||||||
if (TryComp<ItemComponent>(uid, out var item))
|
if (TryComp<ItemComponent>(uid, out var item))
|
||||||
{
|
{
|
||||||
_itemSystem.SetHeldPrefix(uid, component.OldInhandPrefix, item);
|
_itemSystem.SetHeldPrefix(uid, component.OldInhandPrefix, component: item);
|
||||||
}
|
}
|
||||||
|
|
||||||
component.Wielded = false;
|
component.Wielded = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user