Skip to content

Commit

Permalink
фиксики фиксики
Browse files Browse the repository at this point in the history
  • Loading branch information
FaDeOkno committed Sep 4, 2024
1 parent bb6b581 commit 28a8415
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 14 deletions.
11 changes: 11 additions & 0 deletions Content.Server/Shuttles/Systems/ArrivalsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public sealed class ArrivalsSystem : EntitySystem
[Dependency] private readonly StationSpawningSystem _stationSpawning = default!;
[Dependency] private readonly StationSystem _station = default!;
[Dependency] private readonly ActorSystem _actor = default!;
[Dependency] private readonly ContainerSpawnPointSystem _containerSpawnPointSystem = default!;

private EntityQuery<PendingClockInComponent> _pendingQuery;
private EntityQuery<ArrivalsBlacklistComponent> _blacklistQuery;
Expand Down Expand Up @@ -338,6 +339,16 @@ public void HandlePlayerSpawning(PlayerSpawningEvent ev)
if (!Enabled || _ticker.RunLevel != GameRunLevel.InRound)
return;

// ADT station AI tweak start
if (ev.Job != null &&
ev.Job.Prototype.HasValue &&
_protoManager.Index(ev.Job.Prototype.Value).ContainerInsert)
{
_containerSpawnPointSystem.HandlePlayerSpawning(ev, true);
return;
}
// ADT station AI tweak end

if (!HasComp<StationArrivalsComponent>(ev.Station))
return;

Expand Down
55 changes: 41 additions & 14 deletions Content.Server/Spawners/EntitySystems/ContainerSpawnPointSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Server.Station.Systems;
using Robust.Server.Containers;
using Robust.Shared.Containers;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;

namespace Content.Server.Spawners.EntitySystems;
Expand All @@ -14,14 +15,26 @@ public sealed class ContainerSpawnPointSystem : EntitySystem
[Dependency] private readonly ContainerSystem _container = default!;
[Dependency] private readonly StationSystem _station = default!;
[Dependency] private readonly StationSpawningSystem _stationSpawning = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<PlayerSpawningEvent>(HandlePlayerSpawning, before: new []{ typeof(SpawnPointSystem) });
}

public void HandlePlayerSpawning(PlayerSpawningEvent args)
public void HandlePlayerSpawning(PlayerSpawningEvent args) // ADT station AI tweak
{
if (args.Job != null &&
args.Job.Prototype.HasValue &&
_proto.Index(args.Job.Prototype.Value).ContainerInsert)
HandlePlayerSpawning(args, true); // ADT station AI tweak
else
HandlePlayerSpawning(args, false); // ADT station AI tweak
}

// ADT station AI tweak start
public void HandlePlayerSpawning(PlayerSpawningEvent args, bool forceJob = false)
{
if (args.SpawnResult != null)
return;
Expand All @@ -34,25 +47,38 @@ public void HandlePlayerSpawning(PlayerSpawningEvent args)
if (args.Station != null && _station.GetOwningStation(uid, xform) != args.Station)
continue;

// If it's unset, then we allow it to be used for both roundstart and midround joins
if (spawnPoint.SpawnType == SpawnPointType.Unset)
if (forceJob)
{
// make sure we also check the job here for various reasons.
if (spawnPoint.Job == null || spawnPoint.Job == args.Job?.Prototype)
if (spawnPoint.SpawnType == SpawnPointType.Job &&
args.Job != null &&
spawnPoint.Job == args.Job.Prototype)
{
possibleContainers.Add((uid, spawnPoint, container, xform));
continue;
}
}

if (_gameTicker.RunLevel == GameRunLevel.InRound && spawnPoint.SpawnType == SpawnPointType.LateJoin)
else
{
possibleContainers.Add((uid, spawnPoint, container, xform));
}
// If it's unset, then we allow it to be used for both roundstart and midround joins
if (spawnPoint.SpawnType == SpawnPointType.Unset)
{
// make sure we also check the job here for various reasons.
if (spawnPoint.Job == null || spawnPoint.Job == args.Job?.Prototype)
possibleContainers.Add((uid, spawnPoint, container, xform));
continue;
}

if (_gameTicker.RunLevel != GameRunLevel.InRound &&
spawnPoint.SpawnType == SpawnPointType.Job &&
(args.Job == null || spawnPoint.Job == args.Job.Prototype))
{
possibleContainers.Add((uid, spawnPoint, container, xform));
if (_gameTicker.RunLevel == GameRunLevel.InRound && spawnPoint.SpawnType == SpawnPointType.LateJoin)
{
possibleContainers.Add((uid, spawnPoint, container, xform));
}

if (_gameTicker.RunLevel != GameRunLevel.InRound &&
spawnPoint.SpawnType == SpawnPointType.Job &&
(args.Job == null || spawnPoint.Job == args.Job.Prototype))
{
possibleContainers.Add((uid, spawnPoint, container, xform));
}
}
}

Expand Down Expand Up @@ -82,4 +108,5 @@ public void HandlePlayerSpawning(PlayerSpawningEvent args)
Del(args.SpawnResult);
args.SpawnResult = null;
}
// ADT station AI tweak end
}
5 changes: 5 additions & 0 deletions Content.Shared/Roles/JobPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ public sealed partial class JobPrototype : IPrototype
/// </summary>
[DataField]
public List<ProtoId<GuideEntryPrototype>>? Guides;

// ADT station AI tweak start
[DataField]
public bool ContainerInsert = false;
// ADT station AI tweak end
}

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Roles/Jobs/Science/borg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
icon: JobIconStationAi
supervisors: job-supervisors-rd
jobEntity: StationAiBrain
containerInsert: true

- type: job
id: Borg
Expand Down

0 comments on commit 28a8415

Please sign in to comment.