Лимит установки голографических барьеров. (#3437)
This commit is contained in:
parent
da8f9664a0
commit
a2ae334a94
4 changed files with 38 additions and 4 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@
|
|||
thresholds:
|
||||
- trigger:
|
||||
!type:DamageTrigger
|
||||
damage: 60
|
||||
damage: 250 # Sunrise - Edit
|
||||
behaviors:
|
||||
- !type:DoActsBehavior
|
||||
acts: [ "Destruction" ]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue