using Content.Server.Gateway.Components;
using Content.Server.Parallax;
using Content.Server.Procedural;
+using Content.Server.Salvage;
using Content.Shared.CCVar;
using Content.Shared.Dataset;
using Content.Shared.Movement.Components;
[Dependency] private readonly ITileDefinitionManager _tileDefManager = default!;
[Dependency] private readonly BiomeSystem _biome = default!;
[Dependency] private readonly DungeonSystem _dungeon = default!;
- [Dependency] private readonly FixtureSystem _fixtures = default!;
[Dependency] private readonly GatewaySystem _gateway = default!;
[Dependency] private readonly MetaDataSystem _metadata = default!;
+ [Dependency] private readonly RestrictedRangeSystem _restricted = default!;
[Dependency] private readonly SharedMapSystem _maps = default!;
- [Dependency] private readonly SharedPhysicsSystem _physics = default!;
[ValidatePrototypeId<DatasetPrototype>]
private const string PlanetNames = "names_borer";
_metadata.SetEntityName(mapUid, gatewayName);
var origin = new Vector2i(random.Next(-MaxOffset, MaxOffset), random.Next(-MaxOffset, MaxOffset));
- var restriction = AddComp<RestrictedRangeComponent>(mapUid);
- restriction.Origin = origin;
+ var restricted = new RestrictedRangeComponent
+ {
+ Origin = origin
+ };
+ AddComp(mapUid, restricted);
+
_biome.EnsurePlanet(mapUid, _protoManager.Index<BiomeTemplatePrototype>("Continental"), seed);
var grid = Comp<MapGridComponent>(mapUid);
genDest.Seed = seed;
genDest.Generator = uid;
- // Enclose the area
- var boundaryUid = Spawn(null, originCoords);
- var boundaryPhysics = AddComp<PhysicsComponent>(boundaryUid);
- var cShape = new ChainShape();
- // Don't need it to be a perfect circle, just need it to be loosely accurate.
- cShape.CreateLoop(Vector2.Zero, restriction.Range + 1f, false, count: 4);
- _fixtures.TryCreateFixture(
- boundaryUid,
- cShape,
- "boundary",
- collisionLayer: (int) (CollisionGroup.HighImpassable | CollisionGroup.Impassable | CollisionGroup.LowImpassable),
- body: boundaryPhysics);
- _physics.WakeBody(boundaryUid, body: boundaryPhysics);
- AddComp<BoundaryComponent>(boundaryUid);
-
// Create the gateway.
var gatewayUid = SpawnAtPosition(generator.Proto, originCoords);
var gatewayComp = Comp<GatewayComponent>(gatewayUid);
+using System.Numerics;
+using Content.Shared.Physics;
using Content.Shared.Salvage;
+using Robust.Shared.Map;
+using Robust.Shared.Physics.Collision.Shapes;
+using Robust.Shared.Physics.Components;
+using Robust.Shared.Physics.Systems;
namespace Content.Server.Salvage;
public sealed class RestrictedRangeSystem : SharedRestrictedRangeSystem
{
+ [Dependency] private readonly FixtureSystem _fixtures = default!;
+ [Dependency] private readonly SharedPhysicsSystem _physics = default!;
+ public override void Initialize()
+ {
+ base.Initialize();
+ SubscribeLocalEvent<RestrictedRangeComponent, MapInitEvent>(OnRestrictedMapInit);
+ }
+
+ private void OnRestrictedMapInit(EntityUid uid, RestrictedRangeComponent component, MapInitEvent args)
+ {
+ component.BoundaryEntity = CreateBoundary(new EntityCoordinates(uid, component.Origin), component.Range);
+ }
+
+ public EntityUid CreateBoundary(EntityCoordinates coordinates, float range)
+ {
+ var boundaryUid = Spawn(null, coordinates);
+ var boundaryPhysics = AddComp<PhysicsComponent>(boundaryUid);
+ var cShape = new ChainShape();
+ // Don't need it to be a perfect circle, just need it to be loosely accurate.
+ cShape.CreateLoop(Vector2.Zero, range + 0.25f, false, count: 4);
+ _fixtures.TryCreateFixture(
+ boundaryUid,
+ cShape,
+ "boundary",
+ collisionLayer: (int) (CollisionGroup.HighImpassable | CollisionGroup.Impassable | CollisionGroup.LowImpassable),
+ body: boundaryPhysics);
+ _physics.WakeBody(boundaryUid, body: boundaryPhysics);
+ return boundaryUid;
+ }
}
using System.Linq;
+using System.Numerics;
using Content.Server.Administration;
using Content.Server.GameTicking;
using Content.Server.GameTicking.Events;
using Content.Server.Parallax;
+using Content.Server.Salvage;
using Content.Server.Shuttles.Components;
using Content.Server.Shuttles.Events;
using Content.Server.Spawners.Components;
[Dependency] private readonly BiomeSystem _biomes = default!;
[Dependency] private readonly GameTicker _ticker = default!;
[Dependency] private readonly MapLoaderSystem _loader = default!;
+ [Dependency] private readonly RestrictedRangeSystem _restricted = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly ShuttleSystem _shuttles = default!;
[Dependency] private readonly StationSpawningSystem _stationSpawning = default!;
{
var template = _random.Pick(_arrivalsBiomeOptions);
_biomes.EnsurePlanet(mapUid, _protoManager.Index(template));
- var range = AddComp<RestrictedRangeComponent>(mapUid);
- range.Range = 32f;
- Dirty(mapUid, range);
+ var restricted = new RestrictedRangeComponent
+ {
+ Range = 32f
+ };
+ AddComp(mapUid, restricted);
}
_mapManager.DoMapInitialize(mapId);
[DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)]
public Vector2 Origin;
+
+ [DataField]
+ public EntityUid BoundaryEntity;
}