Лимит установки голографических барьеров. (#3437)

This commit is contained in:
Daniel 2025-12-25 18:39:38 +01:00 committed by GitHub
parent da8f9664a0
commit a2ae334a94
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 38 additions and 4 deletions

View file

@ -15,5 +15,13 @@ namespace Content.Server.Holosign
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("chargeUse")]
public float ChargeUse = 50f;
// Sunrise - Start
/// <summary>
/// How many holosigns can be in one tile at once.
/// </summary>
[DataField]
public int CountPerTileLimit = 3;
// Sunrise - End
}
}

View file

@ -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<StorageComponent>(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<EntityLookupSystem>();
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));

View file

@ -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

View file

@ -155,7 +155,7 @@
thresholds:
- trigger:
!type:DamageTrigger
damage: 60
damage: 250 # Sunrise - Edit
behaviors:
- !type:DoActsBehavior
acts: [ "Destruction" ]