diff --git a/Content.Shared/_Sunrise/Eye/NightVision/Components/NightVisionDeviceComponent.cs b/Content.Shared/_Sunrise/Eye/NightVision/Components/NightVisionDeviceComponent.cs index ecf7f8e39e..cfc9ea1f19 100644 --- a/Content.Shared/_Sunrise/Eye/NightVision/Components/NightVisionDeviceComponent.cs +++ b/Content.Shared/_Sunrise/Eye/NightVision/Components/NightVisionDeviceComponent.cs @@ -9,7 +9,7 @@ namespace Content.Shared._Sunrise.Eye.NightVision.Components; [RegisterComponent, NetworkedComponent] -[AutoGenerateComponentState] +[AutoGenerateComponentState(fieldDeltas: true)] public sealed partial class NightVisionDeviceComponent : Component { [DataField("toggleAction", customTypeSerializer: typeof(PrototypeIdSerializer))] @@ -20,9 +20,9 @@ public sealed partial class NightVisionDeviceComponent : Component [DataField("requiredSlot"), AutoNetworkedField] public SlotFlags RequiredFlags = SlotFlags.EYES; - + [DataField("isPowered"), AutoNetworkedField] - public bool isPowered = false; + public bool IsPowered; [DataField] [AutoNetworkedField] diff --git a/Content.Shared/_Sunrise/Eye/NightVision/Systems/NightVisionDeviceSystem.cs b/Content.Shared/_Sunrise/Eye/NightVision/Systems/NightVisionDeviceSystem.cs index 9e51306308..febd3103a6 100644 --- a/Content.Shared/_Sunrise/Eye/NightVision/Systems/NightVisionDeviceSystem.cs +++ b/Content.Shared/_Sunrise/Eye/NightVision/Systems/NightVisionDeviceSystem.cs @@ -2,28 +2,21 @@ using Content.Shared._Sunrise.Eye.NightVision.Components; using Content.Shared.PowerCell; using Content.Shared.Inventory; using Content.Shared.Actions; -using Content.Shared.Inventory.Events; using Content.Shared.Toggleable; -using Content.Shared.PowerCell; using Content.Shared.PowerCell.Components; using Content.Shared.Popups; using Content.Shared.Containers.ItemSlots; -using Content.Shared.Examine; using Robust.Shared.Audio.Systems; using Robust.Shared.Network; -using Robust.Shared.GameObjects; -using Robust.Shared.GameStates; using JetBrains.Annotations; namespace Content.Shared._Sunrise.Eye.NightVision.Systems; public sealed class NightVisionDeviceSystem : EntitySystem { - [Dependency] private readonly SharedPowerCellSystem _powerCell = default!; [Dependency] private readonly SharedActionsSystem _actionsSystem = default!; [Dependency] private readonly SharedAudioSystem _audioSystem = default!; [Dependency] private readonly INetManager _net = default!; - [Dependency] private readonly SharedPointLightSystem _light = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly SharedPopupSystem _popup = default!; [Dependency] private readonly SharedPowerCellSystem _cell = default!; @@ -32,10 +25,10 @@ public sealed class NightVisionDeviceSystem : EntitySystem public override void Initialize() { base.Initialize(); - + SubscribeLocalEvent>(OnNVDTrySee); SubscribeLocalEvent(OnNightVisionDeviceUpdateVisuals); - + SubscribeLocalEvent(OnPowerCellChanged); SubscribeLocalEvent(OnPowerCellSlotEmpty); @@ -48,11 +41,11 @@ public sealed class NightVisionDeviceSystem : EntitySystem { if (!TryComp(uid, out var slot)) return false; - + if (!_itemSlots.TryGetSlot(uid, slot.CellSlotId, out var itemSlot)) return false; - return itemSlot.Item != null && _powerCell.HasDrawCharge(uid); + return itemSlot.Item != null && _cell.HasDrawCharge(uid); } private void OnNVDTrySee(EntityUid uid, NightVisionDeviceComponent component, InventoryRelayedEvent args) @@ -64,7 +57,7 @@ public sealed class NightVisionDeviceSystem : EntitySystem { var updVisEv = new AfterNvdUpdateVisualsEvent(); RaiseLocalEvent(uid, ref updVisEv); - + _appearance.SetData(uid, NVDVisuals.Light, component.Activated); } @@ -80,7 +73,7 @@ public sealed class NightVisionDeviceSystem : EntitySystem { _actionsSystem.RemoveAction(uid, component.ToggleActionEntity); } - + private void OnPowerCellSlotEmpty(Entity ent, ref PowerCellSlotEmptyEvent args) { if (ent.Comp.Activated) @@ -95,13 +88,13 @@ public sealed class NightVisionDeviceSystem : EntitySystem ForceDisable(ent); } } - + private void OnToggleAction(Entity ent, ref ToggleActionEvent args) { if (args.Handled) return; - - if (!HasPowerAndBattery(ent.Owner)) + + if (ent.Comp.IsPowered && !HasPowerAndBattery(ent.Owner)) { _popup.PopupClient(Loc.GetString("base-computer-ui-component-not-powered", ("machine", ent.Owner)), args.Performer, args.Performer); return; @@ -114,35 +107,32 @@ public sealed class NightVisionDeviceSystem : EntitySystem private void ForceDisable(Entity ent) { ent.Comp.Activated = false; - - if (!_light.TryGetLight(ent.Owner, out var light)) - return; - - var draw = Comp(ent.Owner); - _cell.SetDrawEnabled((ent.Owner, draw), false); - + var transform = Transform(ent.Owner); + + if (ent.Comp.IsPowered) + { + var draw = Comp(ent.Owner); + _cell.SetDrawEnabled((ent.Owner, draw), false); + } + _appearance.SetData(ent, ToggleableLightVisuals.Enabled, false); - _light.SetEnabled(ent.Owner, false, comp: light); - + var updVisEv = new NightVisionDeviceUpdateVisualsEvent(); RaiseLocalEvent(ent, ref updVisEv); - - if (TryComp(ent.Owner, out var transform)) - { - var equipped = transform.ParentUid; - var changeEv = new NightVisionDeviceToggledEvent(equipped); - RaiseLocalEvent(ent.Owner, ref changeEv); - } - + + var equipped = transform.ParentUid; + var changeEv = new NightVisionDeviceToggledEvent(equipped); + RaiseLocalEvent(ent.Owner, ref changeEv); + Dirty(ent); } - + public void Toggle(Entity ent) { - if (!HasPowerAndBattery(ent.Owner)) - return; - ent.Comp.Activated = !ent.Comp.Activated; + var transform = Transform(ent.Owner); + + DirtyField(ent.Owner, ent.Comp, nameof(NightVisionDeviceComponent.Activated)); if (_net.IsServer) { @@ -150,26 +140,22 @@ public sealed class NightVisionDeviceSystem : EntitySystem _audioSystem.PlayPvs(sound, ent.Owner); } - if (!_light.TryGetLight(ent.Owner, out var light)) - return; - - var draw = Comp(ent.Owner); - _cell.QueueUpdate((ent.Owner, draw)); - _cell.SetDrawEnabled((ent.Owner, draw), ent.Comp.Activated); + if (ent.Comp.IsPowered) + { + var draw = Comp(ent.Owner); + _cell.QueueUpdate((ent.Owner, draw)); + _cell.SetDrawEnabled((ent.Owner, draw), ent.Comp.Activated); + } _appearance.SetData(ent, ToggleableLightVisuals.Enabled, ent.Comp.Activated); - _light.SetEnabled(ent.Owner, ent.Comp.Activated, comp: light); var updVisEv = new NightVisionDeviceUpdateVisualsEvent(); RaiseLocalEvent(ent, ref updVisEv); - if (TryComp(ent.Owner, out var transform)) - { - var equipped = transform.ParentUid; - var changeEv = new NightVisionDeviceToggledEvent(equipped); - RaiseLocalEvent(ent.Owner, ref changeEv); - } - + var equipped = transform.ParentUid; + var changeEv = new NightVisionDeviceToggledEvent(equipped); + RaiseLocalEvent(ent.Owner, ref changeEv); + Dirty(ent); } } diff --git a/Resources/Changelog/ChangelogSunrise.yml b/Resources/Changelog/ChangelogSunrise.yml index 611bb2160a..3869229292 100644 --- a/Resources/Changelog/ChangelogSunrise.yml +++ b/Resources/Changelog/ChangelogSunrise.yml @@ -8406,3 +8406,11 @@ type: Fix id: 590 time: '2024-12-21T17:14:41.804322+00:00' +- author: VigersRay + changes: + - message: "\u0418\u0441\u043F\u0440\u0430\u0432\u043B\u0435\u043D \u041F\u041D\u0412\ + \ \u043A\u043E\u0441\u043C\u0438\u0447\u0435\u0441\u043A\u043E\u0433\u043E \u043D\ + \u0438\u043D\u0434\u0437\u0438." + type: Fix + id: 591 + time: '2024-12-21T22:51:25.923364+00:00' diff --git a/Resources/Prototypes/Entities/Clothing/Eyes/glasses.yml b/Resources/Prototypes/Entities/Clothing/Eyes/glasses.yml index db27b7eff0..c125891d5b 100644 --- a/Resources/Prototypes/Entities/Clothing/Eyes/glasses.yml +++ b/Resources/Prototypes/Entities/Clothing/Eyes/glasses.yml @@ -255,7 +255,7 @@ coverage: EYES - type: entity - parent: [ClothingEyesBase, BaseMajorContraband] + parent: [ClothingEyesBase, BaseMajorContraband, PowerCellSlotSmallItem] # Sunrise-Edit id: ClothingEyesVisorNinja name: ninja visor description: An advanced visor protecting a ninja's eyes from flashing lights. @@ -265,6 +265,12 @@ - type: Clothing sprite: Clothing/Eyes/Glasses/ninjavisor.rsi - type: FlashImmunity - - type: NightVisionDevice #Sunrise - night visions + # Sunrise-Start + - type: NightVisionDevice + isPowered: true displayColor: "#44b855" displayShader: NVDDisplay + - type: PowerCellDraw + drawRate: 0 + useRate: 20 + # Sunrise-End diff --git a/Resources/Prototypes/Entities/Clothing/Head/hardsuit-helmets.yml b/Resources/Prototypes/Entities/Clothing/Head/hardsuit-helmets.yml index 3034e91289..49c6505598 100644 --- a/Resources/Prototypes/Entities/Clothing/Head/hardsuit-helmets.yml +++ b/Resources/Prototypes/Entities/Clothing/Head/hardsuit-helmets.yml @@ -83,13 +83,8 @@ - type: PressureProtection highPressureMultiplier: 0.1 lowPressureMultiplier: 1000 - # Sunrise-Start - type: EyeProtection - type: FlashImmunity -# - type: NightVisionDevice -# displayColor: "#ebeb00" -# displayShader: NVDDisplay - # Sunrise-End #Spationaut Hardsuit - type: entity @@ -405,9 +400,6 @@ Slash: 0.9 Piercing: 0.9 Heat: 0.9 -# - type: NightVisionDevice Sunrise - night vision -# displayColor: "#44b855" -# displayShader: NVDDisplay #Syndicate Elite Hardsuit - type: entity @@ -437,9 +429,6 @@ Slash: 0.9 Piercing: 0.9 Heat: 0.9 -# - type: NightVisionDevice Sunrise - night vision -# displayColor: "#44b855" -# displayShader: NVDDisplay #Syndicate Commander Hardsuit - type: entity @@ -464,9 +453,6 @@ Slash: 0.9 Piercing: 0.9 Heat: 0.9 -# - type: NightVisionDevice Sunrise - night vision -# displayColor: "#44b855" -# displayShader: NVDDisplay #Cybersun Juggernaut Hardsuit - type: entity @@ -491,9 +477,6 @@ Slash: 0.9 Piercing: 0.9 Heat: 0.9 -# - type: NightVisionDevice Sunrise - night vision -# displayColor: "#44b855" -# displayShader: NVDDisplay #Wizard Hardsuit - type: entity diff --git a/Resources/Prototypes/Entities/Clothing/Masks/masks.yml b/Resources/Prototypes/Entities/Clothing/Masks/masks.yml index 8e223751a4..dbf0931109 100644 --- a/Resources/Prototypes/Entities/Clothing/Masks/masks.yml +++ b/Resources/Prototypes/Entities/Clothing/Masks/masks.yml @@ -451,9 +451,6 @@ Slash: 0.80 Piercing: 0.90 Heat: 0.90 - - type: NightVisionDevice #Sunrise - night vision - displayColor: "#44b855" - displayShader: NVDDisplay - type: entity parent: ClothingMaskBase diff --git a/Resources/Prototypes/_Sunrise/Entities/Clothing/Eyes/glasses.yml b/Resources/Prototypes/_Sunrise/Entities/Clothing/Eyes/glasses.yml index 367a695e3d..eee5ecc83f 100644 --- a/Resources/Prototypes/_Sunrise/Entities/Clothing/Eyes/glasses.yml +++ b/Resources/Prototypes/_Sunrise/Entities/Clothing/Eyes/glasses.yml @@ -87,15 +87,5 @@ components: - type: ShowSyndicateIcons - type: NightVisionDevice - isPowered: true displayColor: "#ff6e6e" displayShader: NVDDisplay - - type: PowerCellDraw - drawRate: 0 - useRate: 20 - - type: PointLight - color: red - enabled: false - autoRot: true - radius: 0.5 - energy: 0.5 diff --git a/Resources/Prototypes/_Sunrise/Entities/Clothing/Eyes/night_vision_device.yml b/Resources/Prototypes/_Sunrise/Entities/Clothing/Eyes/night_vision_device.yml index 10f16f24a6..a76c1502a6 100644 --- a/Resources/Prototypes/_Sunrise/Entities/Clothing/Eyes/night_vision_device.yml +++ b/Resources/Prototypes/_Sunrise/Entities/Clothing/Eyes/night_vision_device.yml @@ -24,12 +24,6 @@ - state: equipped-EYES-unshaded shader: unshaded slots: [ Eyes ] - - type: PointLight - color: green - enabled: false - autoRot: true - radius: 0.5 - energy: 0.5 - type: Appearance - type: NightVisionDevice isPowered: true @@ -40,7 +34,7 @@ useRate: 20 - type: entity - parent: [ClothingEyesNVD,ShowSecurityIcons] + parent: [ClothingEyesNVD, ShowSecurityIcons] id: ClothingEyesNVDSyndicate suffix: syndicate components: diff --git a/Resources/Prototypes/_Sunrise/Entities/Clothing/Head/hardsuit-helmets.yml b/Resources/Prototypes/_Sunrise/Entities/Clothing/Head/hardsuit-helmets.yml index c866a0629d..5ecb6ae995 100644 --- a/Resources/Prototypes/_Sunrise/Entities/Clothing/Head/hardsuit-helmets.yml +++ b/Resources/Prototypes/_Sunrise/Entities/Clothing/Head/hardsuit-helmets.yml @@ -161,9 +161,6 @@ lowPressureMultiplier: 1000 - type: EyeProtection - type: FlashImmunity -# - type: NightVisionDevice -# displayColor: "#ebeb00" -# displayShader: NVDDisplay #Для ивентов