Make nukies usable (#8257)
* Make nukies usable - Spawn points that work - Radar default range bumped up - Used the infiltrator instead - Spawning works I playtested it and it was working so anything new pops up then I'm gonna screm. * a
This commit is contained in:
@@ -205,7 +205,7 @@ namespace Content.Server.GameTicking
|
||||
// MapInitialize *before* spawning players, our codebase is too shit to do it afterwards...
|
||||
_mapManager.DoMapInitialize(DefaultMap);
|
||||
|
||||
SpawnPlayers(readyPlayers, origReadyPlayers.Select(x => x.UserId), profiles, force);
|
||||
SpawnPlayers(readyPlayers, profiles, force);
|
||||
|
||||
_roundStartDateTime = DateTime.UtcNow;
|
||||
RunLevel = GameRunLevel.InRound;
|
||||
|
||||
@@ -30,15 +30,34 @@ namespace Content.Server.GameTicking
|
||||
// Mainly to avoid allocations.
|
||||
private readonly List<EntityCoordinates> _possiblePositions = new();
|
||||
|
||||
private void SpawnPlayers(List<IPlayerSession> readyPlayers, IEnumerable<NetUserId> origReadyPlayers,
|
||||
Dictionary<NetUserId, HumanoidCharacterProfile> profiles, bool force)
|
||||
private void SpawnPlayers(List<IPlayerSession> readyPlayers, Dictionary<NetUserId, HumanoidCharacterProfile> profiles, bool force)
|
||||
{
|
||||
// Allow game rules to spawn players by themselves if needed. (For example, nuke ops or wizard)
|
||||
RaiseLocalEvent(new RulePlayerSpawningEvent(readyPlayers, profiles, force));
|
||||
|
||||
var playerNetIds = readyPlayers.Select(o => o.UserId).ToHashSet();
|
||||
|
||||
// RulePlayerSpawning feeds a readonlydictionary of profiles.
|
||||
// We need to take these players out of the pool of players available as they've been used.
|
||||
if (readyPlayers.Count != profiles.Count)
|
||||
{
|
||||
var toRemove = new RemQueue<NetUserId>();
|
||||
|
||||
foreach (var (player, _) in profiles)
|
||||
{
|
||||
if (playerNetIds.Contains(player)) continue;
|
||||
toRemove.Add(player);
|
||||
}
|
||||
|
||||
foreach (var player in toRemove)
|
||||
{
|
||||
profiles.Remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
var assignedJobs = _stationJobs.AssignJobs(profiles, _stationSystem.Stations.ToList());
|
||||
|
||||
_stationJobs.AssignOverflowJobs(ref assignedJobs, origReadyPlayers, profiles, _stationSystem.Stations.ToList());
|
||||
_stationJobs.AssignOverflowJobs(ref assignedJobs, playerNetIds, profiles, _stationSystem.Stations.ToList());
|
||||
|
||||
// Spawn everybody in!
|
||||
foreach (var (player, (job, station)) in assignedJobs)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.Nuke;
|
||||
using Content.Server.RoundEnd;
|
||||
using Content.Server.Spawners.Components;
|
||||
using Content.Server.Station.Components;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Shared.CCVar;
|
||||
@@ -49,7 +50,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
|
||||
private void OnNukeExploded(NukeExplodedEvent ev)
|
||||
{
|
||||
if (!Enabled) return;
|
||||
|
||||
|
||||
_opsWon = true;
|
||||
_roundEndSystem.EndRound();
|
||||
}
|
||||
@@ -78,6 +79,8 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
|
||||
|
||||
private void OnPlayersSpawning(RulePlayerSpawningEvent ev)
|
||||
{
|
||||
if (!Enabled) return;
|
||||
|
||||
_aliveNukeops.Clear();
|
||||
|
||||
var numOps = (int)Math.Min(Math.Floor((double)ev.PlayerPool.Count / _cfg.GetCVar(CCVars.NukeopsPlayersPerOp)),
|
||||
@@ -88,22 +91,22 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
|
||||
ops[i] = _random.PickAndTake(ev.PlayerPool);
|
||||
}
|
||||
|
||||
var map = "/Maps/syndiepuddle.yml";
|
||||
var map = "/Maps/infiltrator.yml";
|
||||
|
||||
var aabbs = _stationSystem.Stations.SelectMany(x =>
|
||||
Comp<StationDataComponent>(x).Grids.Select(x => _mapManager.GetGridComp(x).Grid.WorldBounds.CalcBoundingBox())).ToArray();
|
||||
Comp<StationDataComponent>(x).Grids.Select(x => _mapManager.GetGridComp(x).Grid.WorldAABB)).ToArray();
|
||||
var aabb = aabbs[0];
|
||||
for (int i = 1; i < aabbs.Length; i++)
|
||||
{
|
||||
aabb.Union(aabbs[i]);
|
||||
}
|
||||
|
||||
var (_, grid) = _mapLoader.LoadBlueprint(GameTicker.DefaultMap, map, new MapLoadOptions
|
||||
var (_, gridId) = _mapLoader.LoadBlueprint(GameTicker.DefaultMap, map, new MapLoadOptions
|
||||
{
|
||||
Offset = aabb.Center + MathF.Max(aabb.Height, aabb.Width)*2.5f
|
||||
Offset = aabb.Center + MathF.Max(aabb.Height / 2f, aabb.Width / 2f) * 2.5f
|
||||
});
|
||||
|
||||
if (!grid.HasValue)
|
||||
if (!gridId.HasValue)
|
||||
{
|
||||
Logger.ErrorS("NUKEOPS", $"Gridid was null when loading \"{map}\", aborting.");
|
||||
foreach (var session in ops)
|
||||
@@ -113,19 +116,52 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
|
||||
return;
|
||||
}
|
||||
|
||||
var gear = _prototypeManager.Index<StartingGearPrototype>("SyndicateOperativeGearFull");
|
||||
var spawnpos = new EntityCoordinates(_mapManager.GetGridEuid(grid.Value), new Vector2(1.5f, -4.5f));
|
||||
var gridUid = _mapManager.GetGridEuid(gridId.Value);
|
||||
// TODO: Loot table or something
|
||||
var commanderGear = _prototypeManager.Index<StartingGearPrototype>("SyndicateCommanderGearFull");
|
||||
var starterGear = _prototypeManager.Index<StartingGearPrototype>("SyndicateOperativeGearFull");
|
||||
|
||||
var spawns = new List<EntityCoordinates>();
|
||||
|
||||
// Forgive me for hardcoding prototypes
|
||||
foreach (var (_, meta, xform) in EntityManager.EntityQuery<SpawnPointComponent, MetaDataComponent, TransformComponent>(true))
|
||||
{
|
||||
if (meta.EntityPrototype?.ID != "SpawnPointNukies" || xform.ParentUid != gridUid) continue;
|
||||
|
||||
spawns.Add(xform.Coordinates);
|
||||
}
|
||||
|
||||
if (spawns.Count == 0)
|
||||
{
|
||||
spawns.Add(EntityManager.GetComponent<TransformComponent>(gridUid).Coordinates);
|
||||
Logger.WarningS("nukies", $"Fell back to default spawn for nukies!");
|
||||
}
|
||||
|
||||
// TODO: This should spawn the nukies in regardless and transfer if possible; rest should go to shot roles.
|
||||
for (var i = 0; i < ops.Length; i++)
|
||||
{
|
||||
string name;
|
||||
StartingGearPrototype gear;
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
name = $"Commander";
|
||||
gear = commanderGear;
|
||||
}
|
||||
else
|
||||
{
|
||||
name = $"Operator #{i}";
|
||||
gear = starterGear;
|
||||
}
|
||||
|
||||
var session = ops[i];
|
||||
var name = $"Operator #{i}";
|
||||
var newMind = new Mind.Mind(session.UserId)
|
||||
{
|
||||
CharacterName = name
|
||||
};
|
||||
newMind.ChangeOwningPlayer(session.UserId);
|
||||
|
||||
var mob = EntityManager.SpawnEntity("MobHuman", spawnpos);
|
||||
var mob = EntityManager.SpawnEntity("MobHuman", _random.Pick(spawns));
|
||||
EntityManager.GetComponent<MetaDataComponent>(mob).EntityName = name;
|
||||
|
||||
newMind.TransferTo(mob);
|
||||
|
||||
@@ -5,5 +5,5 @@ public sealed class RadarConsoleComponent : Component
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("range")]
|
||||
public float Range = 256f;
|
||||
public float Range = 512f;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
- type: entity
|
||||
id: SpawnPointNukies
|
||||
parent: MarkerBase
|
||||
name: nukies
|
||||
components:
|
||||
- type: SpawnPoint
|
||||
- type: Sprite
|
||||
layers:
|
||||
- state: green
|
||||
- sprite: Objects/Fun/toys.rsi
|
||||
state: synb
|
||||
@@ -64,6 +64,6 @@
|
||||
- nukeops
|
||||
name: nukeops-title
|
||||
description: nukeops-description
|
||||
showInVote: false
|
||||
showInVote: true
|
||||
rules:
|
||||
- Nukeops
|
||||
|
||||
Reference in New Issue
Block a user