Anti Anomaly zones (#23187)
* add * its work now * pipi * Update Content.Server/Anomaly/AnomalySystem.Generator.cs Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> * fix () --------- Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
This commit is contained in:
@@ -11,6 +11,8 @@ using Content.Shared.Physics;
|
|||||||
using Robust.Shared.Map.Components;
|
using Robust.Shared.Map.Components;
|
||||||
using Robust.Shared.Physics;
|
using Robust.Shared.Physics;
|
||||||
using Robust.Shared.Physics.Components;
|
using Robust.Shared.Physics.Components;
|
||||||
|
using Robust.Shared.Map;
|
||||||
|
using System.Numerics;
|
||||||
|
|
||||||
namespace Content.Server.Anomaly;
|
namespace Content.Server.Anomaly;
|
||||||
|
|
||||||
@@ -21,6 +23,9 @@ namespace Content.Server.Anomaly;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed partial class AnomalySystem
|
public sealed partial class AnomalySystem
|
||||||
{
|
{
|
||||||
|
|
||||||
|
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||||
|
|
||||||
private void InitializeGenerator()
|
private void InitializeGenerator()
|
||||||
{
|
{
|
||||||
SubscribeLocalEvent<AnomalyGeneratorComponent, BoundUIOpenedEvent>(OnGeneratorBUIOpened);
|
SubscribeLocalEvent<AnomalyGeneratorComponent, BoundUIOpenedEvent>(OnGeneratorBUIOpened);
|
||||||
@@ -128,6 +133,22 @@ public sealed partial class AnomalySystem
|
|||||||
if (!valid)
|
if (!valid)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// don't spawn in AntiAnomalyZones
|
||||||
|
var antiAnomalyZonesQueue = AllEntityQuery<AntiAnomalyZoneComponent>();
|
||||||
|
while (antiAnomalyZonesQueue.MoveNext(out var uid, out var zone))
|
||||||
|
{
|
||||||
|
var zoneTile = _transform.GetGridTilePositionOrDefault(uid, gridComp);
|
||||||
|
|
||||||
|
var delta = (zoneTile - tile);
|
||||||
|
if (delta.LengthSquared < zone.ZoneRadius * zone.ZoneRadius)
|
||||||
|
{
|
||||||
|
valid = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!valid)
|
||||||
|
continue;
|
||||||
|
|
||||||
targetCoords = gridComp.GridTileToLocal(tile);
|
targetCoords = gridComp.GridTileToLocal(tile);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
namespace Content.Server.Anomaly.Components;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// prohibits the possibility of anomalies appearing in the specified radius around the entity
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent, Access(typeof(AnomalySystem))]
|
||||||
|
public sealed partial class AntiAnomalyZoneComponent : Component
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// the radius in which anomalies cannot appear
|
||||||
|
/// </summary>
|
||||||
|
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public float ZoneRadius = 10;
|
||||||
|
}
|
||||||
33
Resources/Prototypes/Entities/Markers/anti_anomaly_zone.yml
Normal file
33
Resources/Prototypes/Entities/Markers/anti_anomaly_zone.yml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
- type: entity
|
||||||
|
name: anti anomaly zone
|
||||||
|
description: Anomalies will not be able to appear within a 10 block radius of this point.
|
||||||
|
id: AntiAnomalyZone
|
||||||
|
suffix: "range 10"
|
||||||
|
parent: MarkerBase
|
||||||
|
components:
|
||||||
|
- type: Sprite
|
||||||
|
sprite: Structures/Specific/Anomalies/ice_anom.rsi
|
||||||
|
layers:
|
||||||
|
- state: anom
|
||||||
|
- sprite: Markers/cross.rsi
|
||||||
|
state: pink
|
||||||
|
- type: AntiAnomalyZone
|
||||||
|
zoneRadius: 10
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
parent: AntiAnomalyZone
|
||||||
|
id: AntiAnomalyZone20
|
||||||
|
suffix: "range 20"
|
||||||
|
description: Anomalies will not be able to appear within a 20 block radius of this point.
|
||||||
|
components:
|
||||||
|
- type: AntiAnomalyZone
|
||||||
|
zoneRadius: 20
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
parent: AntiAnomalyZone
|
||||||
|
id: AntiAnomalyZone50
|
||||||
|
suffix: "range 50"
|
||||||
|
description: Anomalies will not be able to appear within a 50 block radius of this point.
|
||||||
|
components:
|
||||||
|
- type: AntiAnomalyZone
|
||||||
|
zoneRadius: 50
|
||||||
Reference in New Issue
Block a user