Световые приколы (#200)
* add: new visuals to health analyzer and new graphic funny light * fix: fix pointlight and analyzer visuals
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
namespace Content.Server._White.Lighting;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class PointLightBatteryComponent : Component
|
||||
{
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool RequireBattery = true;
|
||||
}
|
||||
30
Content.Server/_White/Lighting/PointLightBatterySystem.cs
Normal file
30
Content.Server/_White/Lighting/PointLightBatterySystem.cs
Normal file
@@ -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<PointLightBatteryComponent, PowerCellChangedEvent>(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);
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ public abstract class SharedPowerCellSystem : EntitySystem
|
||||
SubscribeLocalEvent<PowerCellSlotComponent, EntInsertedIntoContainerMessage>(OnCellInserted);
|
||||
SubscribeLocalEvent<PowerCellSlotComponent, EntRemovedFromContainerMessage>(OnCellRemoved);
|
||||
SubscribeLocalEvent<PowerCellSlotComponent, ContainerIsInsertingAttemptEvent>(OnCellInsertAttempt);
|
||||
SubscribeLocalEvent<PowerCellSlotComponent, PowerCellChangedEvent>(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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.0 KiB |
@@ -8,7 +8,7 @@
|
||||
"copyright": "Taken from tgstation at commit https://github.com/tgstation/tgstation/commit/f07f847706d85b7cfa4b398e5175732212b69a63",
|
||||
"states": [
|
||||
{
|
||||
"name": "analyzer",
|
||||
"name": "powered",
|
||||
"delays": [
|
||||
[
|
||||
0.1,
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 375 B |
Reference in New Issue
Block a user