@@ -12,25 +12,23 @@ using Content.Server.Procedural;
|
||||
using Content.Server.Salvage.Expeditions;
|
||||
using Content.Server.Salvage.Expeditions.Structure;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Construction.EntitySystems;
|
||||
using Content.Shared.Dataset;
|
||||
using Content.Shared.Gravity;
|
||||
using Content.Shared.Parallax.Biomes;
|
||||
using Content.Shared.Parallax.Biomes.Markers;
|
||||
using Content.Shared.Physics;
|
||||
using Content.Shared.Procedural;
|
||||
using Content.Shared.Procedural.Loot;
|
||||
using Content.Shared.Random;
|
||||
using Content.Shared.Random.Helpers;
|
||||
using Content.Shared.Salvage;
|
||||
using Content.Shared.Salvage.Expeditions;
|
||||
using Content.Shared.Salvage.Expeditions.Modifiers;
|
||||
using Content.Shared.Storage;
|
||||
using Robust.Shared.Collections;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Noise;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Salvage;
|
||||
|
||||
@@ -40,7 +38,7 @@ public sealed class SpawnSalvageMissionJob : Job<bool>
|
||||
private readonly IGameTiming _timing;
|
||||
private readonly IMapManager _mapManager;
|
||||
private readonly IPrototypeManager _prototypeManager;
|
||||
private readonly ITileDefinitionManager _tileDefManager;
|
||||
private readonly AnchorableSystem _anchorable;
|
||||
private readonly BiomeSystem _biome;
|
||||
private readonly DungeonSystem _dungeon;
|
||||
private readonly SalvageSystem _salvage;
|
||||
@@ -54,7 +52,7 @@ public sealed class SpawnSalvageMissionJob : Job<bool>
|
||||
IGameTiming timing,
|
||||
IMapManager mapManager,
|
||||
IPrototypeManager protoManager,
|
||||
ITileDefinitionManager tileDefManager,
|
||||
AnchorableSystem anchorable,
|
||||
BiomeSystem biome,
|
||||
DungeonSystem dungeon,
|
||||
SalvageSystem salvage,
|
||||
@@ -66,7 +64,7 @@ public sealed class SpawnSalvageMissionJob : Job<bool>
|
||||
_timing = timing;
|
||||
_mapManager = mapManager;
|
||||
_prototypeManager = protoManager;
|
||||
_tileDefManager = tileDefManager;
|
||||
_anchorable = anchorable;
|
||||
_biome = biome;
|
||||
_dungeon = dungeon;
|
||||
_salvage = salvage;
|
||||
@@ -314,6 +312,7 @@ public sealed class SpawnSalvageMissionJob : Job<bool>
|
||||
// scale affects how many groups are spawned, not the size of the groups themselves
|
||||
var groupSpawns = _salvage.GetSpawnCount(mission.Difficulty) * scale;
|
||||
var groupSum = faction.MobGroups.Sum(o => o.Prob);
|
||||
var validSpawns = new List<Vector2i>();
|
||||
|
||||
for (var i = 0; i < groupSpawns; i++)
|
||||
{
|
||||
@@ -332,15 +331,31 @@ public sealed class SpawnSalvageMissionJob : Job<bool>
|
||||
|
||||
var spawnRoomIndex = random.Next(dungeon.Rooms.Count);
|
||||
var spawnRoom = dungeon.Rooms[spawnRoomIndex];
|
||||
var spawnTile = spawnRoom.Tiles.ElementAt(random.Next(spawnRoom.Tiles.Count));
|
||||
var spawnPosition = grid.GridTileToLocal(spawnTile);
|
||||
validSpawns.Clear();
|
||||
validSpawns.AddRange(spawnRoom.Tiles);
|
||||
random.Shuffle(validSpawns);
|
||||
|
||||
foreach (var entry in EntitySpawnCollection.GetSpawns(mobGroup.Entries, random))
|
||||
while (validSpawns.Count > 0)
|
||||
{
|
||||
var uid = _entManager.CreateEntityUninitialized(entry, spawnPosition);
|
||||
_entManager.RemoveComponent<GhostTakeoverAvailableComponent>(uid);
|
||||
_entManager.RemoveComponent<GhostRoleComponent>(uid);
|
||||
_entManager.InitializeAndStartEntity(uid);
|
||||
var spawnTile = validSpawns[^1];
|
||||
|
||||
if (!_anchorable.TileFree(grid, spawnTile, (int) CollisionGroup.MachineLayer, (int) CollisionGroup.MachineLayer))
|
||||
{
|
||||
validSpawns.RemoveAt(validSpawns.Count - 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
var spawnPosition = grid.GridTileToLocal(spawnTile);
|
||||
|
||||
foreach (var entry in EntitySpawnCollection.GetSpawns(mobGroup.Entries, random))
|
||||
{
|
||||
var uid = _entManager.CreateEntityUninitialized(entry, spawnPosition);
|
||||
_entManager.RemoveComponent<GhostTakeoverAvailableComponent>(uid);
|
||||
_entManager.RemoveComponent<GhostRoleComponent>(uid);
|
||||
_entManager.InitializeAndStartEntity(uid);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
await SuspendIfOutOfTime();
|
||||
|
||||
Reference in New Issue
Block a user