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:
metalgearsloth
2024-01-03 17:24:02 +11:00
committed by GitHub
parent 2548156eae
commit 2166958bd0
29 changed files with 160 additions and 294 deletions

View File

@@ -1,16 +1,16 @@
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
namespace Content.Shared.Item;
namespace Content.Shared.Item.ItemToggle.Components;
/// <summary>
/// Handles the active sound being played continuously with some items that are activated (ie e-sword hum).
/// </summary>
[RegisterComponent, NetworkedComponent]
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class ItemToggleActiveSoundComponent : Component
{
/// <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>
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
public SoundSpecifier? ActiveSound;
@@ -18,17 +18,6 @@ public sealed partial class ItemToggleActiveSoundComponent : Component
/// <summary>
/// Used when the item emits sound while active.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
[ViewVariables(VVAccess.ReadWrite), DataField]
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;
}

View File

@@ -1,7 +1,7 @@
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
namespace Content.Shared.Item;
namespace Content.Shared.Item.ItemToggle.Components;
/// <summary>
/// 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 bool Cancelled = false;
public EntityUid? User = User;
public readonly EntityUid? User = User;
}
/// <summary>
@@ -64,63 +64,34 @@ public record struct ItemToggleActivateAttemptEvent(EntityUid? User)
public record struct ItemToggleDeactivateAttemptEvent(EntityUid? User)
{
public bool Cancelled = false;
public EntityUid? User = User;
public readonly EntityUid? User = User;
}
/// <summary>
/// Raised directed on an entity any sort of toggle is complete.
/// </summary>
[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 EntityUid? User = User;
public readonly bool Predicted = Predicted;
public readonly bool Activated = Activated;
public readonly EntityUid? User = User;
}
/// <summary>
/// Raised in order to play a toggle sound effect.
/// Raised directed on an entity when an itemtoggle is activated.
/// </summary>
[ByRefEvent]
public record struct ItemTogglePlayToggleSoundEvent(bool Activated, bool Predicted, EntityUid? User)
public readonly record struct ItemToggleActivatedEvent(EntityUid? User)
{
public bool Activated = Activated;
public bool Predicted = Predicted;
public EntityUid? User = User;
public readonly EntityUid? User = User;
}
/// <summary>
/// Raised in order to play a failure to toggle sound effect.
/// Raised directed on an entity when an itemtoggle is deactivated.
/// </summary>
[ByRefEvent]
public record struct ItemTogglePlayFailSoundEvent(bool Predicted, EntityUid? User)
public readonly record struct ItemToggleDeactivatedEvent(EntityUid? User)
{
public bool Predicted = Predicted;
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;
public readonly EntityUid? User = User;
}

View File

@@ -1,11 +1,11 @@
using Robust.Shared.GameStates;
namespace Content.Shared.Item;
namespace Content.Shared.Item.ItemToggle.Components;
/// <summary>
/// Handles whether the item is hot when toggled on.
/// Handles whether the item is hot when toggled on.
/// </summary>
[RegisterComponent, NetworkedComponent]
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class ItemToggleHotComponent : Component
{
/// <summary>

View File

@@ -1,16 +1,16 @@
using Robust.Shared.GameStates;
using Robust.Shared.Audio;
using Content.Shared.Damage;
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
namespace Content.Shared.Item;
namespace Content.Shared.Item.ItemToggle.Components;
/// <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.
/// </summary>
/// <remarks>
/// You can change the damage, sound on hit, on swing, as well as hidden status while activated.
/// </remarks>
[RegisterComponent, NetworkedComponent]
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class ItemToggleMeleeWeaponComponent : Component
{
/// <summary>
@@ -67,13 +67,3 @@ public sealed partial class ItemToggleMeleeWeaponComponent : Component
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
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;
}

View File

@@ -1,15 +1,15 @@
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
namespace Content.Shared.Item;
namespace Content.Shared.Item.ItemToggle.Components;
/// <summary>
/// Handles the changes to the item size when toggled.
/// Handles the changes to the item size when toggled.
/// </summary>
/// <remarks>
/// You can change the size when activated or not. By default the sizes are copied from the item.
/// </remarks>
[RegisterComponent, NetworkedComponent]
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class ItemToggleSizeComponent : Component
{
/// <summary>
@@ -24,12 +24,3 @@ public sealed partial class ItemToggleSizeComponent : Component
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
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;
}