Files
wwdpublic/Content.Shared/Overlays/Switchable/SwitchableOverlayComponent.cs
VMSolidus 4dfb82527c Fixes For Trait Netcode (#2379)
# Description

It turns out that traits that add or modify a shared component also need
to make sure that said component is Dirtied to the client. Also I
finally figured out what was going on with Thermal Vision.

# TODO

<details><summary><h1>Media</h1></summary>
<p>

Thermal vision is finally fixed:

https://github.com/user-attachments/assets/64aeea2f-39bf-40ec-8530-518194fbb0fc

</p>
</details>

# Changelog

🆑
- fix: Fixed Thermal Vision lasting only a single tick instead of the
full 2 seconds its intended to last.
- fix: Fixed traits not correctly updating the client on changes made to
the character.

(cherry picked from commit b57df8f877057403a7047199ed147c8372bad5a2)
2025-05-03 01:46:53 +03:00

58 lines
1.6 KiB
C#

using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
namespace Content.Shared.Overlays.Switchable;
public abstract partial class SwitchableOverlayComponent : BaseOverlayComponent
{
[DataField, AutoNetworkedField]
public virtual bool IsActive { get; set; }
[DataField]
public virtual bool DrawOverlay { get; set; } = true;
/// <summary>
/// Whether it should grant equipment enhanced vision or is it mob vision
/// </summary>
[DataField]
public virtual bool IsEquipment { get; set; }
/// <summary>
/// If it is greater than 0, overlay isn't toggled but pulsed instead
/// </summary>
[DataField]
public virtual float PulseTime { get; set; }
[ViewVariables(VVAccess.ReadOnly)]
public float PulseAccumulator;
[DataField]
public virtual float FlashDurationMultiplier { get; set; } = 1f; // ! goober
[DataField]
public virtual SoundSpecifier? ActivateSound { get; set; } =
new SoundPathSpecifier("/Audio/Items/Goggles/activate.ogg");
[DataField]
public virtual SoundSpecifier? DeactivateSound { get; set; } =
new SoundPathSpecifier("/Audio/Items/Goggles/deactivate.ogg");
[DataField]
public virtual string? ToggleAction { get; set; }
[ViewVariables]
public EntityUid? ToggleActionEntity;
}
[Serializable, NetSerializable]
public sealed class SwitchableVisionOverlayComponentState : IComponentState
{
public Color Color;
public bool IsActive;
public SoundSpecifier? ActivateSound;
public SoundSpecifier? DeactivateSound;
public EntProtoId? ToggleAction;
public float LightRadius;
}