Holofan Projector Upstream from Nyano (#8352)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
33
Content.Server/Holosign/HolosignProjectorComponent.cs
Normal file
33
Content.Server/Holosign/HolosignProjectorComponent.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server.Holosign
|
||||
{
|
||||
[RegisterComponent]
|
||||
public sealed class HolosignProjectorComponent : Component
|
||||
{
|
||||
[ViewVariables]
|
||||
[DataField("maxCharges")]
|
||||
public int MaxCharges = 6;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("charges")]
|
||||
public int CurrentCharges = 6;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("signProto", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string SignProto = "HolosignWetFloor";
|
||||
|
||||
/// <summary>
|
||||
/// When the holosign was last used.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("lastUse")]
|
||||
public TimeSpan LastUsed = TimeSpan.Zero;
|
||||
|
||||
/// <summary>
|
||||
/// How long it takes for 1 charge to accumulate.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("rechargeTime")]
|
||||
public TimeSpan RechargeTime = TimeSpan.FromSeconds(30);
|
||||
}
|
||||
}
|
||||
57
Content.Server/Holosign/HolosignSystem.cs
Normal file
57
Content.Server/Holosign/HolosignSystem.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Server.Coordinates.Helpers;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Server.Holosign
|
||||
{
|
||||
public sealed class HolosignSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<HolosignProjectorComponent, UseInHandEvent>(OnUse);
|
||||
SubscribeLocalEvent<HolosignProjectorComponent, ExaminedEvent>(OnExamine);
|
||||
}
|
||||
|
||||
private int GetCharges(HolosignProjectorComponent component)
|
||||
{
|
||||
return component.CurrentCharges + (int) ((_timing.CurTime - component.LastUsed).TotalSeconds / component.RechargeTime.TotalSeconds);
|
||||
}
|
||||
|
||||
private void OnExamine(EntityUid uid, HolosignProjectorComponent component, ExaminedEvent args)
|
||||
{
|
||||
// TODO: This should probably be using an itemstatus
|
||||
// TODO: I'm too lazy to do this rn but it's literally copy-paste from emag.
|
||||
var timeRemaining = (component.LastUsed + component.RechargeTime * (component.MaxCharges - component.CurrentCharges) - _timing.CurTime).TotalSeconds % component.RechargeTime.TotalSeconds;
|
||||
var charges = GetCharges(component);
|
||||
|
||||
args.PushMarkup(Loc.GetString("emag-charges-remaining", ("charges", charges)));
|
||||
if (charges == component.MaxCharges)
|
||||
{
|
||||
args.PushMarkup(Loc.GetString("emag-max-charges"));
|
||||
return;
|
||||
}
|
||||
args.PushMarkup(Loc.GetString("emag-recharging", ("seconds", Math.Round(timeRemaining))));
|
||||
}
|
||||
|
||||
private void OnUse(EntityUid uid, HolosignProjectorComponent component, UseInHandEvent args)
|
||||
{
|
||||
if (component.CurrentCharges == 0 || args.Handled)
|
||||
return;
|
||||
|
||||
// TODO: Too tired to deal
|
||||
var holo = EntityManager.SpawnEntity(component.SignProto, Transform(args.User).Coordinates.SnapToGrid(EntityManager));
|
||||
Transform(holo).Anchored = true;
|
||||
|
||||
// Don't reset last use time if it's already accumulating.
|
||||
if (component.CurrentCharges == component.MaxCharges)
|
||||
component.LastUsed = _timing.CurTime;
|
||||
|
||||
component.CurrentCharges--;
|
||||
args.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,6 +87,7 @@
|
||||
- id: ClothingHeadHelmetAtmosFire
|
||||
- id: GasAnalyzer
|
||||
- id: MedkitOxygenFilled
|
||||
- id: HolofanProjector
|
||||
|
||||
- type: entity
|
||||
id: LockerEngineerFilled
|
||||
|
||||
@@ -15,5 +15,6 @@
|
||||
ClothingBeltJanitor: 2
|
||||
ClothingHeadsetService: 2
|
||||
ClothingOuterWinterJani: 2
|
||||
Holoprojector: 1
|
||||
emaggedInventory:
|
||||
ClothingUniformJumpskirtJanimaid: 2
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
- type: entity
|
||||
parent: BaseItem
|
||||
id: Holoprojector
|
||||
name: holographic sign projector
|
||||
description: A handy-dandy holographic projector that displays a janitorial sign.
|
||||
components:
|
||||
- type: HolosignProjector
|
||||
- type: Sprite
|
||||
sprite: Objects/Devices/Holoprojectors/custodial.rsi
|
||||
state: icon
|
||||
|
||||
- type: entity
|
||||
parent: Holoprojector
|
||||
id: HolofanProjector
|
||||
name: holofan projector
|
||||
description: Stop suicidal passengers from killing everyone during atmos emergencies.
|
||||
components:
|
||||
- type: HolosignProjector
|
||||
signProto: HoloFan
|
||||
rechargeTime: 120
|
||||
- type: Sprite
|
||||
sprite: Objects/Devices/Holoprojectors/atmos.rsi
|
||||
state: icon
|
||||
@@ -0,0 +1,33 @@
|
||||
- type: entity
|
||||
id: HolosignWetFloor
|
||||
name: wet floor sign
|
||||
description: The words flicker as if they mean nothing.
|
||||
components:
|
||||
- type: Physics
|
||||
bodyType: Static
|
||||
- type: Sprite
|
||||
sprite: Structures/Holo/wetfloor.rsi
|
||||
state: icon
|
||||
netsync: false
|
||||
- type: TimedDespawn
|
||||
lifetime: 30
|
||||
|
||||
- type: entity
|
||||
id: HoloFan
|
||||
parent: HolosignWetFloor
|
||||
name: holofan
|
||||
description: A barrier of hard light that blocks air, but nothing else.
|
||||
components:
|
||||
- type: Sprite
|
||||
sprite: Structures/Holo/holofan.rsi
|
||||
state: icon
|
||||
netsync: false
|
||||
- type: Fixtures
|
||||
fixtures:
|
||||
- shape:
|
||||
!type:PhysShapeAabb
|
||||
bounds: "-0.5,-0.5,0.5,0.5"
|
||||
- type: TimedDespawn
|
||||
lifetime: 180
|
||||
- type: Airtight
|
||||
noAirWhenFullyAirBlocked: false
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 736 B |
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"version": 1,
|
||||
"size": {
|
||||
"x": 32,
|
||||
"y": 32
|
||||
},
|
||||
"license": "CC-BY-SA-3.0",
|
||||
"copyright": "Taken from tgstation at https://github.com/tgstation/tgstation/commit/40d89d11ea4a5cb81d61dc1018b46f4e7d32c62a",
|
||||
"states": [
|
||||
{
|
||||
"name": "icon",
|
||||
"delays": [
|
||||
[
|
||||
0.3,
|
||||
0.3,
|
||||
0.3,
|
||||
0.3
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 714 B |
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"version": 1,
|
||||
"size": {
|
||||
"x": 32,
|
||||
"y": 32
|
||||
},
|
||||
"license": "CC-BY-SA-3.0",
|
||||
"copyright": "Taken from tgstation at https://github.com/tgstation/tgstation/commit/40d89d11ea4a5cb81d61dc1018b46f4e7d32c62a",
|
||||
"states": [
|
||||
{
|
||||
"name": "icon",
|
||||
"delays": [
|
||||
[
|
||||
0.3,
|
||||
0.3,
|
||||
0.3,
|
||||
0.3
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
Resources/Textures/Structures/Holo/holofan.rsi/icon.png
Normal file
BIN
Resources/Textures/Structures/Holo/holofan.rsi/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
30
Resources/Textures/Structures/Holo/holofan.rsi/meta.json
Normal file
30
Resources/Textures/Structures/Holo/holofan.rsi/meta.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"version": 1,
|
||||
"size": {
|
||||
"x": 32,
|
||||
"y": 32
|
||||
},
|
||||
"license": "CC-BY-SA-3.0",
|
||||
"copyright": "Taken from tgstation at https://github.com/tgstation/tgstation/commit/40d89d11ea4a5cb81d61dc1018b46f4e7d32c62a",
|
||||
"states": [
|
||||
{
|
||||
"name": "icon",
|
||||
"delays": [
|
||||
[
|
||||
0.3,
|
||||
0.3,
|
||||
0.3,
|
||||
0.3,
|
||||
0.3,
|
||||
0.3,
|
||||
0.3,
|
||||
0.3,
|
||||
0.3,
|
||||
0.3,
|
||||
0.3,
|
||||
0.3
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
Resources/Textures/Structures/Holo/wetfloor.rsi/icon.png
Normal file
BIN
Resources/Textures/Structures/Holo/wetfloor.rsi/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.3 KiB |
30
Resources/Textures/Structures/Holo/wetfloor.rsi/meta.json
Normal file
30
Resources/Textures/Structures/Holo/wetfloor.rsi/meta.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"version": 1,
|
||||
"size": {
|
||||
"x": 32,
|
||||
"y": 32
|
||||
},
|
||||
"license": "CC-BY-SA-3.0",
|
||||
"copyright": "Taken from tgstation at https://github.com/tgstation/tgstation/commit/40d89d11ea4a5cb81d61dc1018b46f4e7d32c62a",
|
||||
"states": [
|
||||
{
|
||||
"name": "icon",
|
||||
"delays": [
|
||||
[
|
||||
0.3,
|
||||
0.3,
|
||||
0.3,
|
||||
0.3,
|
||||
0.3,
|
||||
0.3,
|
||||
0.3,
|
||||
0.3,
|
||||
0.3,
|
||||
0.3,
|
||||
0.3,
|
||||
0.3
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user