Skip to content

Commit

Permalink
Hook into station init and Barge implementation for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheackraze committed Jan 19, 2025
1 parent e7a7e5c commit 8314886
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Content.Server.Station.Components;

/// <summary>
/// Rename all holopads on a station when station name changes.
/// Only holopads with "Ship or POI" will be affected.
/// </summary>
[RegisterComponent]
public sealed partial class StationRenameHolopadsComponent : Component
{

}
55 changes: 55 additions & 0 deletions Content.Server/_NF/Station/Systems/StationRenameHolopadsSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using Content.Server.Station.Components;
using Content.Server.Station.Events;
using Content.Shared.Fax.Components;
using Content.Shared.Holopad;
using Content.Shared.Labels.Components;

namespace Content.Server.Station.Systems;

public sealed class StationRenameHolopadsSystem : EntitySystem
{
[Dependency] private readonly StationSystem _stationSystem = default!;

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<StationRenameHolopadsComponent, StationPostInitEvent>(OnPostInit);
}

private void OnPostInit(EntityUid uid, StationRenameHolopadsComponent component, ref StationPostInitEvent args)
{
SyncHolopadsNames(uid);
}

private void SyncHolopadsNames(EntityUid stationUid)
{
// update all holopads that belong to this station grid
var query = EntityQueryEnumerator<HolopadComponent>();
while (query.MoveNext(out var uid, out var pad))
{
if (!pad.UseStationName)
continue;

var padStationUid = _stationSystem.GetOwningStation(uid);
if (padStationUid != stationUid)
continue;

var padName = "";

if (!string.IsNullOrEmpty(pad.StationNamePrefix))
{
padName += pad.StationNamePrefix + " ";
}

padName += Name(padStationUid.Value);

if (!string.IsNullOrEmpty(pad.StationNameSuffix))
{
padName += " " + pad.StationNameSuffix;
}

var padLabel = EnsureComp<LabelComponent>(uid);
padLabel.CurrentLabel = padName;
}
}
}
21 changes: 21 additions & 0 deletions Content.Shared/Holopad/HolopadComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,27 @@ public sealed partial class HolopadComponent : Component
/// </summary>
[DataField]
public float ControlLockoutCoolDown { get; private set; } = 180f;

/// <summary>
/// Frontier - If true, will sync pad name with a station name.
/// </summary>
[ViewVariables]
[DataField]
public bool UseStationName { get; set; }

/// <summary>
/// Frontier - If added with UseStationName will add a Prefix to the name
/// </summary>
[ViewVariables]
[DataField]
public string? StationNamePrefix { get; set; } = null;

/// <summary>
/// Frontier - If added with UseStationName will add a suffix to the name
/// </summary>
[ViewVariables]
[DataField]
public string? StationNameSuffix { get; set; } = null;
}

#region: Event messages
Expand Down
41 changes: 24 additions & 17 deletions Resources/Maps/_NF/Shuttles/barge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3584,6 +3584,29 @@ entities:
rot: -1.5707963267948966 rad
pos: 2.5,-15.5
parent: 70
- proto: NFHolopadShip
entities:
- uid: 126
components:
- type: Transform
pos: 1.5,-11.5
parent: 70
- type: Fixtures
fixtures:
fix1:
shape: !type:PhysShapeCircle
radius: 0.33275002
position: 0,0
mask:
- Impassable
- LowImpassable
layer:
- LowImpassable
density: 1
hard: False
restitution: 0
friction: 0.4
- type: ScaleVisuals
- proto: NitrogenCanister
entities:
- uid: 46
Expand Down Expand Up @@ -3647,17 +3670,6 @@ entities:
- type: Transform
pos: 1.5,-17.5
parent: 70
- type: FuelGenerator
on: False
- type: Physics
bodyType: Static
- proto: PowerCellRecharger
entities:
- uid: 126
components:
- type: Transform
pos: 1.5,-11.5
parent: 70
- proto: Poweredlight
entities:
- uid: 245
Expand Down Expand Up @@ -4363,11 +4375,6 @@ entities:
rot: -1.5707963267948966 rad
pos: 0.5,-11.5
parent: 70
- uid: 541
components:
- type: Transform
pos: 1.5,-11.5
parent: 70
- uid: 542
components:
- type: Transform
Expand Down Expand Up @@ -4934,7 +4941,7 @@ entities:
- type: Transform
pos: -4.5,4.5
parent: 70
- proto: WarpPointShip
- proto: WarpPoint
entities:
- uid: 599
components:
Expand Down
22 changes: 22 additions & 0 deletions Resources/Prototypes/_NF/Entities/Structures/Machines/holopad.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
- type: entity
name: long-range holopad
description: "An experimental floor-mounted device for projecting holographic images via bluespace."
parent: Holopad
id: NFHolopadShip
suffix: Ship
components:
- type: Telephone
ringTone: /Audio/Machines/double_ring.ogg #change me to something funny
listeningRange: 3
speakerVolume: Speak
transmissionRange: Map
compatibleRanges:
- Grid
- Map
- Unlimited
ignoreTelephonesOnSameGrid: true
- type: Holopad
hologramProtoId: HolopadHologram
useStationName: true
- type: AccessReader
access: [ [ "HeadOfSecurity" ] ]

0 comments on commit 8314886

Please sign in to comment.