diff --git a/Content.Server/Holosign/HolosignProjectorComponent.cs b/Content.Server/Holosign/HolosignProjectorComponent.cs index bdc826f130..d0a5681937 100644 --- a/Content.Server/Holosign/HolosignProjectorComponent.cs +++ b/Content.Server/Holosign/HolosignProjectorComponent.cs @@ -15,5 +15,13 @@ namespace Content.Server.Holosign /// [ViewVariables(VVAccess.ReadWrite), DataField("chargeUse")] public float ChargeUse = 50f; + + // Sunrise - Start + /// + /// How many holosigns can be in one tile at once. + /// + [DataField] + public int CountPerTileLimit = 3; + // Sunrise - End } } diff --git a/Content.Server/Holosign/HolosignSystem.cs b/Content.Server/Holosign/HolosignSystem.cs index beb5e909c0..806e83f9e9 100644 --- a/Content.Server/Holosign/HolosignSystem.cs +++ b/Content.Server/Holosign/HolosignSystem.cs @@ -11,6 +11,7 @@ public sealed class HolosignSystem : EntitySystem { [Dependency] private readonly PowerCellSystem _powerCell = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; + private const float TileSearchRadius = 0.1f; // sunrise - add public override void Initialize() { @@ -40,14 +41,32 @@ public sealed class HolosignSystem : EntitySystem private void OnBeforeInteract(EntityUid uid, HolosignProjectorComponent component, BeforeRangedInteractEvent args) { - + // Sunrise - Start if (args.Handled || !args.CanReach // prevent placing out of range || HasComp(args.Target) // if it's a storage component like a bag, we ignore usage so it can be stored - || !_powerCell.TryUseCharge(uid, component.ChargeUse, user: args.User) // if no battery or no charge, doesn't work ) return; + var tileCoords = args.ClickLocation.SnapToGrid(EntityManager); + var mapCoords = _transform.ToMapCoordinates(tileCoords); + var lookup = EntityManager.System(); + + int count = 0; + foreach (var ent in lookup.GetEntitiesInRange(mapCoords, TileSearchRadius)) + { + if (MetaData(ent).EntityPrototype?.ID == component.SignProto) + { + count++; + if (count >= component.CountPerTileLimit) + return; + } + } + + if (!_powerCell.TryUseCharge(uid, component.ChargeUse, user: args.User)) + return; + // Sunrise - End + // places the holographic sign at the click location, snapped to grid. // overlapping of the same holo on one tile remains allowed to allow holofan refreshes var holoUid = Spawn(component.SignProto, args.ClickLocation.SnapToGrid(EntityManager)); diff --git a/Resources/Prototypes/Entities/Objects/Devices/holoprojectors.yml b/Resources/Prototypes/Entities/Objects/Devices/holoprojectors.yml index a7872fb18d..fffd5106c6 100644 --- a/Resources/Prototypes/Entities/Objects/Devices/holoprojectors.yml +++ b/Resources/Prototypes/Entities/Objects/Devices/holoprojectors.yml @@ -44,6 +44,7 @@ components: - type: HolosignProjector chargeUse: 240 + countPerTileLimit: 2 # Sunrise - Added - type: ItemSlots slots: cell_slot: @@ -62,6 +63,7 @@ - type: HolosignProjector signProto: HoloPeel chargeUse: 240 + countPerTileLimit: 2 # Sunrise - Added - type: Sprite sprite: Objects/Devices/Holoprojectors/peel.rsi state: icon @@ -82,6 +84,7 @@ - type: HolosignProjector signProto: HoloFan chargeUse: 120 + countPerTileLimit: 2 # Sunrise - Added - type: Sprite sprite: Objects/Devices/Holoprojectors/atmos.rsi state: icon @@ -128,7 +131,10 @@ components: - type: HolosignProjector signProto: HolosignForcefield - chargeUse: 120 + # Sunrise - Start + chargeUse: 350 + countPerTileLimit: 1 + # Sunrise - End - type: Sprite sprite: Objects/Devices/Holoprojectors/field.rsi state: icon @@ -157,6 +163,7 @@ - type: HolosignProjector signProto: HolosignSecurity chargeUse: 90 + countPerTileLimit: 2 # Sunrise - Added - type: Sprite sprite: Objects/Devices/Holoprojectors/security.rsi state: icon diff --git a/Resources/Prototypes/Entities/Structures/Holographic/projections.yml b/Resources/Prototypes/Entities/Structures/Holographic/projections.yml index 651f62fd66..d3e472042d 100644 --- a/Resources/Prototypes/Entities/Structures/Holographic/projections.yml +++ b/Resources/Prototypes/Entities/Structures/Holographic/projections.yml @@ -155,7 +155,7 @@ thresholds: - trigger: !type:DamageTrigger - damage: 60 + damage: 250 # Sunrise - Edit behaviors: - !type:DoActsBehavior acts: [ "Destruction" ]