* basic religion vision * block god interactions * skill tree mob specify * silvania setup?? * clustering shader optimization * gods department & job * random gods jobs * Luxian god * Update Nature.png * Update sphere_of_light.yml * god chat * Update ChatSystem.cs * OBSERVATION * public observation and basic follower api * shader tweaks * improve shaders * spawning and praying on altars * altars ppvs override * move pvs overridiation from altars to observers * shader coloration * spectral z mover * god magic radius restricted * guide how to believe in god * sends messages to god when smoeone wanna become follower * follower doAfter * goodbye luxian, welcome lumera * goodbye silvania, welcome merkas * som polish and renamings * gods fast travel * Update altar.ftl * some lumera sfx * renouncing patrons! * renounce followers * followewr percentage calculation * remove from player-facing * fix * Update sphere_of_light.yml * Update base.yml
83 lines
2.9 KiB
C#
83 lines
2.9 KiB
C#
using Content.Server.GameTicking;
|
|
using Content.Server.Spawners.Components;
|
|
using Content.Server.Station.Systems;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Random;
|
|
|
|
namespace Content.Server.Spawners.EntitySystems;
|
|
|
|
public sealed class SpawnPointSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly GameTicker _gameTicker = default!;
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
[Dependency] private readonly StationSystem _stationSystem = default!;
|
|
[Dependency] private readonly StationSpawningSystem _stationSpawning = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
SubscribeLocalEvent<PlayerSpawningEvent>(OnPlayerSpawning);
|
|
}
|
|
|
|
private void OnPlayerSpawning(PlayerSpawningEvent args)
|
|
{
|
|
if (args.SpawnResult != null)
|
|
return;
|
|
|
|
// TODO: Cache all this if it ends up important.
|
|
var points = EntityQueryEnumerator<SpawnPointComponent, TransformComponent>();
|
|
var possiblePositions = new List<EntityCoordinates>();
|
|
|
|
while ( points.MoveNext(out var uid, out var spawnPoint, out var xform))
|
|
{
|
|
if (args.Station != null && _stationSystem.GetOwningStation(uid, xform) != args.Station)
|
|
continue;
|
|
|
|
//CP14 always spawn gods on gods spawnpoints
|
|
if (spawnPoint.SpawnType == SpawnPointType.Always && (args.Job == null || spawnPoint.Job == args.Job))
|
|
{
|
|
possiblePositions.Clear();
|
|
possiblePositions.Add(xform.Coordinates);
|
|
break;
|
|
}
|
|
//CP14end
|
|
|
|
if (_gameTicker.RunLevel == GameRunLevel.InRound && spawnPoint.SpawnType == SpawnPointType.LateJoin)
|
|
{
|
|
possiblePositions.Add(xform.Coordinates);
|
|
}
|
|
|
|
if (_gameTicker.RunLevel != GameRunLevel.InRound &&
|
|
spawnPoint.SpawnType == SpawnPointType.Job &&
|
|
(args.Job == null || spawnPoint.Job == args.Job))
|
|
{
|
|
possiblePositions.Add(xform.Coordinates);
|
|
}
|
|
}
|
|
|
|
if (possiblePositions.Count == 0)
|
|
{
|
|
// Ok we've still not returned, but we need to put them /somewhere/.
|
|
// TODO: Refactor gameticker spawning code so we don't have to do this!
|
|
var points2 = EntityQueryEnumerator<SpawnPointComponent, TransformComponent>();
|
|
|
|
if (points2.MoveNext(out var spawnPoint, out var xform))
|
|
{
|
|
possiblePositions.Add(xform.Coordinates);
|
|
}
|
|
else
|
|
{
|
|
Log.Error("No spawn points were available!");
|
|
return;
|
|
}
|
|
}
|
|
|
|
var spawnLoc = _random.Pick(possiblePositions);
|
|
|
|
args.SpawnResult = _stationSpawning.SpawnPlayerMob(
|
|
spawnLoc,
|
|
args.Job,
|
|
args.HumanoidCharacterProfile,
|
|
args.Station);
|
|
}
|
|
}
|