Restricted range cleanup (#22402)
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Numerics;
|
|||||||
using Content.Server.Gateway.Components;
|
using Content.Server.Gateway.Components;
|
||||||
using Content.Server.Parallax;
|
using Content.Server.Parallax;
|
||||||
using Content.Server.Procedural;
|
using Content.Server.Procedural;
|
||||||
|
using Content.Server.Salvage;
|
||||||
using Content.Shared.CCVar;
|
using Content.Shared.CCVar;
|
||||||
using Content.Shared.Dataset;
|
using Content.Shared.Dataset;
|
||||||
using Content.Shared.Movement.Components;
|
using Content.Shared.Movement.Components;
|
||||||
@@ -36,11 +37,10 @@ public sealed class GatewayGeneratorSystem : EntitySystem
|
|||||||
[Dependency] private readonly ITileDefinitionManager _tileDefManager = default!;
|
[Dependency] private readonly ITileDefinitionManager _tileDefManager = default!;
|
||||||
[Dependency] private readonly BiomeSystem _biome = default!;
|
[Dependency] private readonly BiomeSystem _biome = default!;
|
||||||
[Dependency] private readonly DungeonSystem _dungeon = default!;
|
[Dependency] private readonly DungeonSystem _dungeon = default!;
|
||||||
[Dependency] private readonly FixtureSystem _fixtures = default!;
|
|
||||||
[Dependency] private readonly GatewaySystem _gateway = default!;
|
[Dependency] private readonly GatewaySystem _gateway = default!;
|
||||||
[Dependency] private readonly MetaDataSystem _metadata = default!;
|
[Dependency] private readonly MetaDataSystem _metadata = default!;
|
||||||
|
[Dependency] private readonly RestrictedRangeSystem _restricted = default!;
|
||||||
[Dependency] private readonly SharedMapSystem _maps = default!;
|
[Dependency] private readonly SharedMapSystem _maps = default!;
|
||||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
|
||||||
|
|
||||||
[ValidatePrototypeId<DatasetPrototype>]
|
[ValidatePrototypeId<DatasetPrototype>]
|
||||||
private const string PlanetNames = "names_borer";
|
private const string PlanetNames = "names_borer";
|
||||||
@@ -120,8 +120,12 @@ public sealed class GatewayGeneratorSystem : EntitySystem
|
|||||||
_metadata.SetEntityName(mapUid, gatewayName);
|
_metadata.SetEntityName(mapUid, gatewayName);
|
||||||
|
|
||||||
var origin = new Vector2i(random.Next(-MaxOffset, MaxOffset), random.Next(-MaxOffset, MaxOffset));
|
var origin = new Vector2i(random.Next(-MaxOffset, MaxOffset), random.Next(-MaxOffset, MaxOffset));
|
||||||
var restriction = AddComp<RestrictedRangeComponent>(mapUid);
|
var restricted = new RestrictedRangeComponent
|
||||||
restriction.Origin = origin;
|
{
|
||||||
|
Origin = origin
|
||||||
|
};
|
||||||
|
AddComp(mapUid, restricted);
|
||||||
|
|
||||||
_biome.EnsurePlanet(mapUid, _protoManager.Index<BiomeTemplatePrototype>("Continental"), seed);
|
_biome.EnsurePlanet(mapUid, _protoManager.Index<BiomeTemplatePrototype>("Continental"), seed);
|
||||||
|
|
||||||
var grid = Comp<MapGridComponent>(mapUid);
|
var grid = Comp<MapGridComponent>(mapUid);
|
||||||
@@ -145,21 +149,6 @@ public sealed class GatewayGeneratorSystem : EntitySystem
|
|||||||
genDest.Seed = seed;
|
genDest.Seed = seed;
|
||||||
genDest.Generator = uid;
|
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.
|
// Create the gateway.
|
||||||
var gatewayUid = SpawnAtPosition(generator.Proto, originCoords);
|
var gatewayUid = SpawnAtPosition(generator.Proto, originCoords);
|
||||||
var gatewayComp = Comp<GatewayComponent>(gatewayUid);
|
var gatewayComp = Comp<GatewayComponent>(gatewayUid);
|
||||||
|
|||||||
@@ -1,8 +1,43 @@
|
|||||||
|
using System.Numerics;
|
||||||
|
using Content.Shared.Physics;
|
||||||
using Content.Shared.Salvage;
|
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;
|
namespace Content.Server.Salvage;
|
||||||
|
|
||||||
public sealed class RestrictedRangeSystem : SharedRestrictedRangeSystem
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Numerics;
|
||||||
using Content.Server.Administration;
|
using Content.Server.Administration;
|
||||||
using Content.Server.GameTicking;
|
using Content.Server.GameTicking;
|
||||||
using Content.Server.GameTicking.Events;
|
using Content.Server.GameTicking.Events;
|
||||||
using Content.Server.Parallax;
|
using Content.Server.Parallax;
|
||||||
|
using Content.Server.Salvage;
|
||||||
using Content.Server.Shuttles.Components;
|
using Content.Server.Shuttles.Components;
|
||||||
using Content.Server.Shuttles.Events;
|
using Content.Server.Shuttles.Events;
|
||||||
using Content.Server.Spawners.Components;
|
using Content.Server.Spawners.Components;
|
||||||
@@ -44,6 +46,7 @@ public sealed class ArrivalsSystem : EntitySystem
|
|||||||
[Dependency] private readonly BiomeSystem _biomes = default!;
|
[Dependency] private readonly BiomeSystem _biomes = default!;
|
||||||
[Dependency] private readonly GameTicker _ticker = default!;
|
[Dependency] private readonly GameTicker _ticker = default!;
|
||||||
[Dependency] private readonly MapLoaderSystem _loader = default!;
|
[Dependency] private readonly MapLoaderSystem _loader = default!;
|
||||||
|
[Dependency] private readonly RestrictedRangeSystem _restricted = default!;
|
||||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||||
[Dependency] private readonly ShuttleSystem _shuttles = default!;
|
[Dependency] private readonly ShuttleSystem _shuttles = default!;
|
||||||
[Dependency] private readonly StationSpawningSystem _stationSpawning = default!;
|
[Dependency] private readonly StationSpawningSystem _stationSpawning = default!;
|
||||||
@@ -429,9 +432,11 @@ public sealed class ArrivalsSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
var template = _random.Pick(_arrivalsBiomeOptions);
|
var template = _random.Pick(_arrivalsBiomeOptions);
|
||||||
_biomes.EnsurePlanet(mapUid, _protoManager.Index(template));
|
_biomes.EnsurePlanet(mapUid, _protoManager.Index(template));
|
||||||
var range = AddComp<RestrictedRangeComponent>(mapUid);
|
var restricted = new RestrictedRangeComponent
|
||||||
range.Range = 32f;
|
{
|
||||||
Dirty(mapUid, range);
|
Range = 32f
|
||||||
|
};
|
||||||
|
AddComp(mapUid, restricted);
|
||||||
}
|
}
|
||||||
|
|
||||||
_mapManager.DoMapInitialize(mapId);
|
_mapManager.DoMapInitialize(mapId);
|
||||||
|
|||||||
@@ -14,4 +14,7 @@ public sealed partial class RestrictedRangeComponent : Component
|
|||||||
|
|
||||||
[DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)]
|
[DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)]
|
||||||
public Vector2 Origin;
|
public Vector2 Origin;
|
||||||
|
|
||||||
|
[DataField]
|
||||||
|
public EntityUid BoundaryEntity;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user