From 8ccf29a2fcfbe7566a0831e010f699423ecbc2c5 Mon Sep 17 00:00:00 2001 From: ThereDrD0 <88589686+ThereDrD0@users.noreply.github.com> Date: Sat, 16 Mar 2024 18:30:57 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=B2=D0=B5=D1=82=D0=BE=D0=B2=D1=8B?= =?UTF-8?q?=D0=B5=20=D0=BF=D1=80=D0=B8=D0=BA=D0=BE=D0=BB=D1=8B=20(#200)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add: new visuals to health analyzer and new graphic funny light * fix: fix pointlight and analyzer visuals --- .../Lighting/PointLightBatteryComponent.cs | 8 +++++ .../Lighting/PointLightBatterySystem.cs | 30 ++++++++++++++++++ .../PowerCell/SharedPowerCellSystem.cs | 19 +++++++++-- .../Specific/Medical/healthanalyzer.yml | 20 ++++++++---- .../Medical/healthanalyzer.rsi/analyzer.png | Bin 1059 -> 0 bytes .../Medical/healthanalyzer.rsi/meta.json | 2 +- .../Medical/healthanalyzer.rsi/powered.png | Bin 0 -> 375 bytes 7 files changed, 70 insertions(+), 9 deletions(-) create mode 100644 Content.Server/_White/Lighting/PointLightBatteryComponent.cs create mode 100644 Content.Server/_White/Lighting/PointLightBatterySystem.cs delete mode 100644 Resources/Textures/Objects/Specific/Medical/healthanalyzer.rsi/analyzer.png create mode 100644 Resources/Textures/Objects/Specific/Medical/healthanalyzer.rsi/powered.png diff --git a/Content.Server/_White/Lighting/PointLightBatteryComponent.cs b/Content.Server/_White/Lighting/PointLightBatteryComponent.cs new file mode 100644 index 0000000000..7ad8c5c84c --- /dev/null +++ b/Content.Server/_White/Lighting/PointLightBatteryComponent.cs @@ -0,0 +1,8 @@ +namespace Content.Server._White.Lighting; + +[RegisterComponent] +public sealed partial class PointLightBatteryComponent : Component +{ + [DataField, ViewVariables(VVAccess.ReadWrite)] + public bool RequireBattery = true; +} diff --git a/Content.Server/_White/Lighting/PointLightBatterySystem.cs b/Content.Server/_White/Lighting/PointLightBatterySystem.cs new file mode 100644 index 0000000000..95a41c28c6 --- /dev/null +++ b/Content.Server/_White/Lighting/PointLightBatterySystem.cs @@ -0,0 +1,30 @@ +using Content.Shared.Lightning; +using Content.Shared.PowerCell; +using Content.Shared.PowerCell.Components; + +namespace Content.Server._White.Lighting; + +public sealed class PointLightBatterySystem : SharedLightningSystem +{ + [Dependency] private readonly SharedPointLightSystem _pointLightSystem = default!; + [Dependency] private readonly SharedPowerCellSystem _cell = default!; + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnBatteryLoose); + } + + private void OnBatteryLoose(EntityUid uid, PointLightBatteryComponent component, PowerCellChangedEvent args) + { + if (!component.RequireBattery) + return; + + if (!_pointLightSystem.TryGetLight(uid, out var pointLightComponent)) + return; + + var isBatteryCharged = _cell.HasDrawCharge(uid); + _pointLightSystem.SetEnabled(uid, isBatteryCharged && !args.Ejected, pointLightComponent); + + RaiseLocalEvent(uid, new PointLightToggleEvent(isBatteryCharged && !args.Ejected), true); + } +} diff --git a/Content.Shared/PowerCell/SharedPowerCellSystem.cs b/Content.Shared/PowerCell/SharedPowerCellSystem.cs index 508bfc85f0..dbf5baf42a 100644 --- a/Content.Shared/PowerCell/SharedPowerCellSystem.cs +++ b/Content.Shared/PowerCell/SharedPowerCellSystem.cs @@ -19,6 +19,7 @@ public abstract class SharedPowerCellSystem : EntitySystem SubscribeLocalEvent(OnCellInserted); SubscribeLocalEvent(OnCellRemoved); SubscribeLocalEvent(OnCellInsertAttempt); + SubscribeLocalEvent(OnPowerChanged); } private void OnRejuvenate(EntityUid uid, PowerCellSlotComponent component, RejuvenateEvent args) @@ -30,6 +31,16 @@ public abstract class SharedPowerCellSystem : EntitySystem RaiseLocalEvent(itemSlot.Item.Value, args); } + private void OnPowerChanged(EntityUid uid, PowerCellSlotComponent component, PowerCellChangedEvent _) + { + if (!component.Initialized) + return; + + var charged = HasDrawCharge(uid); + + _appearance.SetData(uid, PowerCellSlotVisuals.Enabled, charged); + } + private void OnCellInsertAttempt(EntityUid uid, PowerCellSlotComponent component, ContainerIsInsertingAttemptEvent args) { if (!component.Initialized) @@ -51,14 +62,18 @@ public abstract class SharedPowerCellSystem : EntitySystem if (args.Container.ID != component.CellSlotId) return; - _appearance.SetData(uid, PowerCellSlotVisuals.Enabled, true); - RaiseLocalEvent(uid, new PowerCellChangedEvent(false), false); + + var charged = HasDrawCharge(uid); + + _appearance.SetData(uid, PowerCellSlotVisuals.Enabled, charged); + RaiseLocalEvent(uid, new PowerCellChangedEvent(false)); } protected virtual void OnCellRemoved(EntityUid uid, PowerCellSlotComponent component, EntRemovedFromContainerMessage args) { if (args.Container.ID != component.CellSlotId) return; + _appearance.SetData(uid, PowerCellSlotVisuals.Enabled, false); RaiseLocalEvent(uid, new PowerCellChangedEvent(true), false); } diff --git a/Resources/Prototypes/Entities/Objects/Specific/Medical/healthanalyzer.yml b/Resources/Prototypes/Entities/Objects/Specific/Medical/healthanalyzer.yml index 64bd04569b..288099f9f1 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Medical/healthanalyzer.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Medical/healthanalyzer.yml @@ -8,11 +8,12 @@ sprite: Objects/Specific/Medical/healthanalyzer.rsi state: icon layers: - - state: icon - - state: analyzer - shader: unshaded + - map: [ "analyzerLayerBody" ] + state: icon visible: true - map: [ "enum.PowerDeviceVisualLayers.Powered" ] + - map: [ "analyzerLayerScreen" ] + state: powered + visible: false - type: Item storedRotation: -90 - type: ActivatableUI @@ -33,8 +34,8 @@ visuals: enum.PowerCellSlotVisuals.Enabled: enum.PowerDeviceVisualLayers.Powered: - True: { visible: true } - False: { visible: false } + True: { state: powered, visible: true, shader: unshaded } + False: { state: powered, visible: false } - type: GuideHelp guides: - Medical Doctor @@ -46,7 +47,14 @@ components: - type: PowerCellDraw drawRate: 1.2 #Calculated for 5 minutes on a small cell + - type: PowerCellSlot + cellSlotId: cell_slot - type: ActivatableUIRequiresPowerCell + - type: PointLightBattery + - type: PointLight + radius: 1.2 + energy: 0.5 + color: "#7FB6C0" - type: entity id: HandheldHealthAnalyzerEmpty diff --git a/Resources/Textures/Objects/Specific/Medical/healthanalyzer.rsi/analyzer.png b/Resources/Textures/Objects/Specific/Medical/healthanalyzer.rsi/analyzer.png deleted file mode 100644 index 3fbab3f112c1d2dffb80f16d93f83a3e57b20aae..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1059 zcmeAS@N?(olHy`uVBq!ia0vp^4M3d0!3HF+R#ka2FfhOJba4!+nDch7ceZe#M4SE5 zR&DdLhe|?@1|Ac{^e41(|8LOf(p&YwNxZB3(V^FBy8{5k%1l5Df#AaVo7~r#{v7@C zUgnA8>ecl*KiQe~+x}m-#(zfUwx*}s^xM_7h4$6_dvT3Vy7|cb&HoP^RBoK~`)=HZ z9rgJS%Bvl>+Y0`;8yE1`OcY2NT+WI78NT)IpY>|rSn9Tm*HmmQ-1$2(Ip^<6ZMVHI zif)SwPLwu3f86fd*VFn%6`MZYe|vb1&!4ito$U=X)3kTg{+-m(VN-3a{i;evJ??(* zZf%2^EPuZJ?c{b?YxVcn#na)!?1E_@FYn%W{UlS}?|(;FH$3`3W%6=;uh%D&BR|%6 zb)4Ae<$BK7ef^Q2J0n+Ke;s{$-t$zcHwORQ)@qf{>M#Cio)sGTV$I1vch=0Ay-#KC zH~sXwr(%Y){~uv3SW%SYJ;!Zv*i^s0dRtGf+~>%9ctPFM)%m~Nk1EtX4f}n6Md;k0 zrQ2`)*A_pYGVAx5c;=}VJ(E`bmfHI2TKu6EoWI>S-thT*N_Jn#!|QV&{*){E*DL05 z$?ui+C9!q)KNNnLt#{r(!_`?FGAolnNz^vlb$ zSLNe-&$m20f1Mu^r3lh>$%&soHvN9duCa4|9mAiON1lHEeCl|<`2JVw66yAT8C1Vt z<_{ z()!eK_noo79t&Mq_ualHj?XZ||B%CT#z|}o)SNe7h}2|NrhY zE&26j7X3B*>~606`_TMW%0KSg{0}PcMLhZZ`5V;9KNu1I1hW>Dh*-+UmqESNU_WMzzq3S@(MjC-(T;)^?ud-1sZja>l!q!yuaSvqo$bs zsC?pi{Ym#V?A3t1oSMP6O{-#b)0BFsY+nU>KvAu47$6nT%Qx29t z^q=*34akfYjurE+hx;aJ%gdWHuKUIL>D%#*y1y8|{640L9-aQwSxK}H*ErjfdJMe4Qflb>VN3%Yw zzbjz#?Xu-MX4bp~rVS>Q2}ZhqEA(>@tl(VAvEwmg7kke6|64xK`Pm@gbmIS~?%&L3 zxUKj7>8-YVXDVOO$W%Jx|K!ET&t)Hc)x@Z;!czO{&sRVBCydXSo&272dWyt|FHwE= Q3+QhKPgg&ebxsLQ09jR>)&Kwi literal 0 HcmV?d00001