Cherrypicks 3 (#382)
* Mobs burn to ashes on excessive heat damage (#26971) * mobs burn to ashes on excessive heat damage * remove comment, remove random lines I didn't mean to add * combine code into behavior * clean unused * fix namespace * drop next to * fix spawn entities behavior spawning entities outside container * fix burning to ash not working on all mobs (#27158) * add ghostnado button to warp menu (#27556) * add ghostnado button to warp menu * translator ops --------- Co-authored-by: deltanedas <@deltanedas:kde.org> * Make arguments and parameters wrap to one variable per line (#27766) * Fix ghosts getting spawned in nullspace (#27617) * Add tests for ghost spawn position * Make ghosts spawn immediately * Format mind system * Move ghost spawning to GhostSystem * Spawn ghost on grid or map This fixes the ghosts being attached the parent entity instead of the grid. * Move logging out of the ghost system * Make round start observer spawn using GhostSystem * Move GameTicker ghost spawning to GhostSystem Moved the more robust character name selection code over. Moved the TimeOfDeath code over. Added canReturn logic. * Add overrides and default for ghost spawn coordinates * Add warning log to ghost spawn fail * Clean up test * Dont spawn ghost on map delete * Minor changes to the role test * Fix role test failing to spawn ghost It was failing the map check due to using Nullspace * Fix ghost tests when running in parallel Not sure what happened, but it seems to be because they were running simultaneously and overwriting values. * Clean up ghost tests * Test that map deletion does not spawn ghosts * Spawn ghost on the next available map * Disallow spawning on deleted maps * Fix map deletion ghost test * Cleanup --------- Co-authored-by: Whisper <121047731+QuietlyWhisper@users.noreply.github.com> Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: ShadowCommander <shadowjjt@gmail.com>
This commit is contained in:
@@ -336,7 +336,11 @@ dotnet_naming_symbols.type_parameters_symbols.applicable_kinds = type_parameter
|
||||
|
||||
# ReSharper properties
|
||||
resharper_braces_for_ifelse = required_for_multiline
|
||||
resharper_csharp_wrap_arguments_style = chop_if_long
|
||||
resharper_csharp_wrap_parameters_style = chop_if_long
|
||||
resharper_keep_existing_attribute_arrangement = true
|
||||
resharper_wrap_chained_binary_patterns = chop_if_long
|
||||
resharper_wrap_chained_method_calls = chop_if_long
|
||||
|
||||
[*.{csproj,xml,yml,yaml,dll.config,msbuildproj,targets,props}]
|
||||
indent_size = 2
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<DefaultWindow xmlns="https://spacestation14.io" Title="{Loc 'ghost-target-window-title'}" MinSize="450 450" SetSize="450 450">
|
||||
<BoxContainer Orientation="Vertical" HorizontalExpand="True" SizeFlagsStretchRatio="0.4">
|
||||
<Button Name="GhostnadoButton" Text="{Loc 'ghost-target-window-warp-to-most-followed'}" HorizontalAlignment="Center" Margin="0 4" />
|
||||
<LineEdit Name="SearchBar" PlaceHolder="Search" HorizontalExpand="True" Margin="0 4" />
|
||||
<ScrollContainer VerticalExpand="True" HorizontalExpand="True" HScrollEnabled="False">
|
||||
<BoxContainer Name="ButtonContainer" Orientation="Vertical" VerticalExpand="True" SeparationOverride="5">
|
||||
|
||||
@@ -15,11 +15,14 @@ namespace Content.Client.UserInterface.Systems.Ghost.Controls
|
||||
private string _searchText = string.Empty;
|
||||
|
||||
public event Action<NetEntity>? WarpClicked;
|
||||
public event Action? OnGhostnadoClicked;
|
||||
|
||||
public GhostTargetWindow()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
SearchBar.OnTextChanged += OnSearchTextChanged;
|
||||
|
||||
GhostnadoButton.OnPressed += _ => OnGhostnadoClicked?.Invoke();
|
||||
}
|
||||
|
||||
public void UpdateWarps(IEnumerable<GhostWarp> warps)
|
||||
|
||||
@@ -111,6 +111,12 @@ public sealed class GhostUIController : UIController, IOnSystemChanged<GhostSyst
|
||||
_net.SendSystemNetworkMessage(msg);
|
||||
}
|
||||
|
||||
private void OnGhostnadoClicked()
|
||||
{
|
||||
var msg = new GhostnadoRequestEvent();
|
||||
_net.SendSystemNetworkMessage(msg);
|
||||
}
|
||||
|
||||
public void LoadGui()
|
||||
{
|
||||
if (Gui == null)
|
||||
@@ -121,7 +127,7 @@ public sealed class GhostUIController : UIController, IOnSystemChanged<GhostSyst
|
||||
Gui.GhostRolesPressed += GhostRolesPressed;
|
||||
Gui.TargetWindow.WarpClicked += OnWarpClicked;
|
||||
Gui.ReturnToRoundPressed += ReturnToRound;
|
||||
|
||||
Gui.TargetWindow.OnGhostnadoClicked += OnGhostnadoClicked;
|
||||
|
||||
UpdateGui();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#nullable enable
|
||||
using System.Linq;
|
||||
using Content.IntegrationTests.Pair;
|
||||
using Content.Server.Ghost.Roles;
|
||||
using Content.Server.Ghost.Roles.Components;
|
||||
using Content.Server.Players;
|
||||
@@ -26,7 +27,7 @@ public sealed class GhostRoleTests
|
||||
";
|
||||
|
||||
/// <summary>
|
||||
/// This is a simple test that just checks if a player can take a ghost roll and then regain control of their
|
||||
/// This is a simple test that just checks if a player can take a ghost role and then regain control of their
|
||||
/// original entity without encountering errors.
|
||||
/// </summary>
|
||||
[Test]
|
||||
@@ -34,12 +35,15 @@ public sealed class GhostRoleTests
|
||||
{
|
||||
await using var pair = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
Dirty = true,
|
||||
DummyTicker = false,
|
||||
Connected = true
|
||||
});
|
||||
var server = pair.Server;
|
||||
var client = pair.Client;
|
||||
|
||||
var mapData = await pair.CreateTestMap();
|
||||
|
||||
var entMan = server.ResolveDependency<IEntityManager>();
|
||||
var sPlayerMan = server.ResolveDependency<Robust.Server.Player.IPlayerManager>();
|
||||
var conHost = client.ResolveDependency<IConsoleHost>();
|
||||
@@ -51,7 +55,7 @@ public sealed class GhostRoleTests
|
||||
EntityUid originalMob = default;
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
originalMob = entMan.SpawnEntity(null, MapCoordinates.Nullspace);
|
||||
originalMob = entMan.SpawnEntity(null, mapData.GridCoords);
|
||||
mindSystem.TransferTo(originalMindId, originalMob, true);
|
||||
});
|
||||
|
||||
@@ -69,12 +73,12 @@ public sealed class GhostRoleTests
|
||||
Assert.That(entMan.HasComponent<GhostComponent>(ghost));
|
||||
Assert.That(ghost, Is.Not.EqualTo(originalMob));
|
||||
Assert.That(session.ContentData()?.Mind, Is.EqualTo(originalMindId));
|
||||
Assert.That(originalMind.OwnedEntity, Is.EqualTo(originalMob));
|
||||
Assert.That(originalMind.OwnedEntity, Is.EqualTo(originalMob), $"Original mob: {originalMob}, Ghost: {ghost}");
|
||||
Assert.That(originalMind.VisitingEntity, Is.EqualTo(ghost));
|
||||
|
||||
// Spawn ghost takeover entity.
|
||||
EntityUid ghostRole = default;
|
||||
await server.WaitPost(() => ghostRole = entMan.SpawnEntity("GhostRoleTestEntity", MapCoordinates.Nullspace));
|
||||
await server.WaitPost(() => ghostRole = entMan.SpawnEntity("GhostRoleTestEntity", mapData.GridCoords));
|
||||
|
||||
// Take the ghost role
|
||||
await server.WaitPost(() =>
|
||||
|
||||
159
Content.IntegrationTests/Tests/Minds/GhostTests.cs
Normal file
159
Content.IntegrationTests/Tests/Minds/GhostTests.cs
Normal file
@@ -0,0 +1,159 @@
|
||||
using System.Numerics;
|
||||
using Content.IntegrationTests.Pair;
|
||||
using Content.Shared.Ghost;
|
||||
using Content.Shared.Mind;
|
||||
using Content.Shared.Players;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.UnitTesting;
|
||||
|
||||
namespace Content.IntegrationTests.Tests.Minds;
|
||||
|
||||
[TestFixture]
|
||||
public sealed class GhostTests
|
||||
{
|
||||
struct GhostTestData
|
||||
{
|
||||
public IEntityManager SEntMan;
|
||||
public Robust.Server.Player.IPlayerManager SPlayerMan;
|
||||
public Server.Mind.MindSystem SMindSys;
|
||||
public SharedTransformSystem STransformSys = default!;
|
||||
|
||||
public TestPair Pair = default!;
|
||||
|
||||
public TestMapData MapData => Pair.TestMap!;
|
||||
|
||||
public RobustIntegrationTest.ServerIntegrationInstance Server => Pair.Server;
|
||||
public RobustIntegrationTest.ClientIntegrationInstance Client => Pair.Client;
|
||||
|
||||
/// <summary>
|
||||
/// Initial player coordinates. Note that this does not necessarily correspond to the position of the
|
||||
/// <see cref="Player"/> entity.
|
||||
/// </summary>
|
||||
public NetCoordinates PlayerCoords = default!;
|
||||
|
||||
public NetEntity Player = default!;
|
||||
public EntityUid SPlayerEnt = default!;
|
||||
|
||||
public ICommonSession ClientSession = default!;
|
||||
public ICommonSession ServerSession = default!;
|
||||
|
||||
public GhostTestData()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<GhostTestData> SetupData()
|
||||
{
|
||||
var data = new GhostTestData();
|
||||
|
||||
// Client is needed to create a session for the ghost system. Creating a dummy session was too difficult.
|
||||
data.Pair = await PoolManager.GetServerClient(new PoolSettings
|
||||
{
|
||||
DummyTicker = false,
|
||||
Connected = true,
|
||||
Dirty = true
|
||||
});
|
||||
|
||||
data.SEntMan = data.Pair.Server.ResolveDependency<IServerEntityManager>();
|
||||
data.SPlayerMan = data.Pair.Server.ResolveDependency<Robust.Server.Player.IPlayerManager>();
|
||||
data.SMindSys = data.SEntMan.System<Server.Mind.MindSystem>();
|
||||
data.STransformSys = data.SEntMan.System<SharedTransformSystem>();
|
||||
|
||||
// Setup map.
|
||||
await data.Pair.CreateTestMap();
|
||||
data.PlayerCoords = data.SEntMan.GetNetCoordinates(data.MapData.GridCoords.Offset(new Vector2(0.5f, 0.5f)).WithEntityId(data.MapData.MapUid, data.STransformSys, data.SEntMan));
|
||||
|
||||
if (data.Client.Session == null)
|
||||
Assert.Fail("No player");
|
||||
data.ClientSession = data.Client.Session!;
|
||||
data.ServerSession = data.SPlayerMan.GetSessionById(data.ClientSession.UserId);
|
||||
|
||||
Entity<MindComponent> mind = default!;
|
||||
await data.Pair.Server.WaitPost(() =>
|
||||
{
|
||||
data.Player = data.SEntMan.GetNetEntity(data.SEntMan.SpawnEntity(null, data.SEntMan.GetCoordinates(data.PlayerCoords)));
|
||||
mind = data.SMindSys.CreateMind(data.ServerSession.UserId, "DummyPlayerEntity");
|
||||
data.SPlayerEnt = data.SEntMan.GetEntity(data.Player);
|
||||
data.SMindSys.TransferTo(mind, data.SPlayerEnt, mind: mind.Comp);
|
||||
data.Server.PlayerMan.SetAttachedEntity(data.ServerSession, data.SPlayerEnt);
|
||||
});
|
||||
|
||||
await data.Pair.RunTicksSync(5);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(data.ServerSession.ContentData()?.Mind, Is.EqualTo(mind.Owner));
|
||||
Assert.That(data.ServerSession.AttachedEntity, Is.EqualTo(data.SPlayerEnt));
|
||||
Assert.That(data.ServerSession.AttachedEntity, Is.EqualTo(mind.Comp.CurrentEntity),
|
||||
"Player is not attached to the mind's current entity.");
|
||||
Assert.That(data.SEntMan.EntityExists(mind.Comp.OwnedEntity),
|
||||
"The mind's current entity does not exist");
|
||||
Assert.That(mind.Comp.VisitingEntity == null || data.SEntMan.EntityExists(mind.Comp.VisitingEntity),
|
||||
"The minds visited entity does not exist.");
|
||||
});
|
||||
|
||||
Assert.That(data.SPlayerEnt, Is.Not.EqualTo(null));
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test that a ghost gets created when the player entity is deleted.
|
||||
/// 1. Delete mob
|
||||
/// 2. Assert is ghost
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task TestGridGhostOnDelete()
|
||||
{
|
||||
var data = await SetupData();
|
||||
|
||||
var oldPosition = data.SEntMan.GetComponent<TransformComponent>(data.SPlayerEnt).Coordinates;
|
||||
|
||||
Assert.That(!data.SEntMan.HasComponent<GhostComponent>(data.SPlayerEnt), "Player was initially a ghost?");
|
||||
|
||||
// Delete entity
|
||||
await data.Server.WaitPost(() => data.SEntMan.DeleteEntity(data.SPlayerEnt));
|
||||
await data.Pair.RunTicksSync(5);
|
||||
|
||||
var ghost = data.ServerSession.AttachedEntity!.Value;
|
||||
Assert.That(data.SEntMan.HasComponent<GhostComponent>(ghost), "Player did not become a ghost");
|
||||
|
||||
// Ensure the position is the same
|
||||
var ghostPosition = data.SEntMan.GetComponent<TransformComponent>(ghost).Coordinates;
|
||||
Assert.That(ghostPosition, Is.EqualTo(oldPosition));
|
||||
|
||||
await data.Pair.CleanReturnAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test that a ghost gets created when the player entity is queue deleted.
|
||||
/// 1. Delete mob
|
||||
/// 2. Assert is ghost
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task TestGridGhostOnQueueDelete()
|
||||
{
|
||||
var data = await SetupData();
|
||||
|
||||
var oldPosition = data.SEntMan.GetComponent<TransformComponent>(data.SPlayerEnt).Coordinates;
|
||||
|
||||
Assert.That(!data.SEntMan.HasComponent<GhostComponent>(data.SPlayerEnt), "Player was initially a ghost?");
|
||||
|
||||
// Delete entity
|
||||
await data.Server.WaitPost(() => data.SEntMan.QueueDeleteEntity(data.SPlayerEnt));
|
||||
await data.Pair.RunTicksSync(5);
|
||||
|
||||
var ghost = data.ServerSession.AttachedEntity!.Value;
|
||||
Assert.That(data.SEntMan.HasComponent<GhostComponent>(ghost), "Player did not become a ghost");
|
||||
|
||||
// Ensure the position is the same
|
||||
var ghostPosition = data.SEntMan.GetComponent<TransformComponent>(ghost).Coordinates;
|
||||
Assert.That(ghostPosition, Is.EqualTo(oldPosition));
|
||||
|
||||
await data.Pair.CleanReturnAsync();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
#nullable enable
|
||||
using System.Linq;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Shared.Ghost;
|
||||
@@ -77,7 +78,7 @@ public sealed partial class MindTests
|
||||
await using var pair = await SetupPair(dirty: true);
|
||||
var server = pair.Server;
|
||||
var testMap = await pair.CreateTestMap();
|
||||
var coordinates = testMap.GridCoords;
|
||||
var testMap2 = await pair.CreateTestMap();
|
||||
|
||||
var entMan = server.ResolveDependency<IServerEntityManager>();
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
@@ -91,7 +92,7 @@ public sealed partial class MindTests
|
||||
MindComponent mind = default!;
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
playerEnt = entMan.SpawnEntity(null, coordinates);
|
||||
playerEnt = entMan.SpawnEntity(null, testMap.GridCoords);
|
||||
mindId = player.ContentData()!.Mind!.Value;
|
||||
mind = entMan.GetComponent<MindComponent>(mindId);
|
||||
mindSystem.TransferTo(mindId, playerEnt);
|
||||
@@ -100,14 +101,20 @@ public sealed partial class MindTests
|
||||
});
|
||||
|
||||
await pair.RunTicksSync(5);
|
||||
await server.WaitPost(() => mapManager.DeleteMap(testMap.MapId));
|
||||
await server.WaitAssertion(() => mapManager.DeleteMap(testMap.MapId));
|
||||
await pair.RunTicksSync(5);
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
#pragma warning disable NUnit2045 // Interdependent assertions.
|
||||
Assert.That(entMan.EntityExists(mind.CurrentEntity), Is.True);
|
||||
Assert.That(mind.CurrentEntity, Is.Not.EqualTo(playerEnt));
|
||||
// Spawn ghost on the second map
|
||||
var attachedEntity = player.AttachedEntity;
|
||||
Assert.That(entMan.EntityExists(attachedEntity), Is.True);
|
||||
Assert.That(attachedEntity, Is.Not.EqualTo(playerEnt));
|
||||
Assert.That(entMan.HasComponent<GhostComponent>(attachedEntity));
|
||||
var transform = entMan.GetComponent<TransformComponent>(attachedEntity.Value);
|
||||
Assert.That(transform.MapID, Is.Not.EqualTo(MapId.Nullspace));
|
||||
Assert.That(transform.MapID, Is.Not.EqualTo(testMap.MapId));
|
||||
#pragma warning restore NUnit2045
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Popups;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
|
||||
namespace Content.Server.Destructible.Thresholds.Behaviors;
|
||||
|
||||
[UsedImplicitly]
|
||||
[DataDefinition]
|
||||
public sealed partial class BurnBodyBehavior : IThresholdBehavior
|
||||
{
|
||||
|
||||
public void Execute(EntityUid bodyId, DestructibleSystem system, EntityUid? cause = null)
|
||||
{
|
||||
var transformSystem = system.EntityManager.System<TransformSystem>();
|
||||
var inventorySystem = system.EntityManager.System<InventorySystem>();
|
||||
var sharedPopupSystem = system.EntityManager.System<SharedPopupSystem>();
|
||||
|
||||
if (system.EntityManager.TryGetComponent<InventoryComponent>(bodyId, out var comp))
|
||||
{
|
||||
foreach (var item in inventorySystem.GetHandOrInventoryEntities(bodyId))
|
||||
{
|
||||
transformSystem.DropNextTo(item, bodyId);
|
||||
}
|
||||
}
|
||||
|
||||
sharedPopupSystem.PopupCoordinates(Loc.GetString("bodyburn-text-others", ("name", bodyId)), transformSystem.GetMoverCoordinates(bodyId), PopupType.LargeCaution);
|
||||
|
||||
system.EntityManager.QueueDeleteEntity(bodyId);
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,10 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
|
||||
public float Offset { get; set; } = 0.5f;
|
||||
|
||||
[DataField("transferForensics")]
|
||||
public bool DoTransferForensics = false;
|
||||
public bool DoTransferForensics;
|
||||
|
||||
[DataField]
|
||||
public bool SpawnInContainer;
|
||||
|
||||
public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
|
||||
{
|
||||
@@ -49,7 +52,9 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
|
||||
|
||||
if (EntityPrototypeHelpers.HasComponent<StackComponent>(entityId, system.PrototypeManager, system.ComponentFactory))
|
||||
{
|
||||
var spawned = system.EntityManager.SpawnEntity(entityId, position.Offset(getRandomVector()));
|
||||
var spawned = SpawnInContainer
|
||||
? system.EntityManager.SpawnNextToOrDrop(entityId, owner)
|
||||
: system.EntityManager.SpawnEntity(entityId, position.Offset(getRandomVector()));
|
||||
system.StackSystem.SetCount(spawned, count);
|
||||
|
||||
TransferForensics(spawned, system, owner);
|
||||
@@ -58,7 +63,9 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
|
||||
{
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var spawned = system.EntityManager.SpawnEntity(entityId, position.Offset(getRandomVector()));
|
||||
var spawned = SpawnInContainer
|
||||
? system.EntityManager.SpawnNextToOrDrop(entityId, owner)
|
||||
: system.EntityManager.SpawnEntity(entityId, position.Offset(getRandomVector()));
|
||||
|
||||
TransferForensics(spawned, system, owner);
|
||||
}
|
||||
|
||||
@@ -283,40 +283,18 @@ namespace Content.Server.GameTicking
|
||||
}
|
||||
}
|
||||
|
||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||
var coords = _transform.GetMoverCoordinates(position, xformQuery);
|
||||
|
||||
var ghost = Spawn(ObserverPrototypeName, coords);
|
||||
|
||||
// Try setting the ghost entity name to either the character name or the player name.
|
||||
// If all else fails, it'll default to the default entity prototype name, "observer".
|
||||
// However, that should rarely happen.
|
||||
if (!string.IsNullOrWhiteSpace(mind.CharacterName))
|
||||
_metaData.SetEntityName(ghost, mind.CharacterName);
|
||||
else if (!string.IsNullOrWhiteSpace(mind.Session?.Name))
|
||||
_metaData.SetEntityName(ghost, mind.Session.Name);
|
||||
|
||||
var ghostComponent = Comp<GhostComponent>(ghost);
|
||||
|
||||
if (mind.TimeOfDeath.HasValue)
|
||||
{
|
||||
_ghost.SetTimeOfDeath(ghost, mind.TimeOfDeath!.Value, ghostComponent);
|
||||
}
|
||||
var ghost = _ghost.SpawnGhost((mindId, mind), position, canReturn);
|
||||
if (ghost == null)
|
||||
return false;
|
||||
|
||||
if (playerEntity != null)
|
||||
_adminLogger.Add(LogType.Mind, $"{EntityManager.ToPrettyString(playerEntity.Value):player} ghosted{(!canReturn ? " (non-returnable)" : "")}");
|
||||
|
||||
_ghost.SetCanReturnToBody(ghostComponent, canReturn);
|
||||
|
||||
if (canReturn)
|
||||
_mind.Visit(mindId, ghost, mind);
|
||||
else
|
||||
_mind.TransferTo(mindId, ghost, mind: mind);
|
||||
|
||||
var player = mind.Session;
|
||||
var userId = player?.UserId;
|
||||
if (userId.HasValue && !_ghostSystem._deathTime.TryGetValue(userId.Value, out _))
|
||||
_ghostSystem._deathTime[userId.Value] = _gameTiming.CurTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ using Content.Server.Speech.Components;
|
||||
using Content.Server.Station.Components;
|
||||
using Content.Shared.Chat;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Mind;
|
||||
using Content.Shared.Players;
|
||||
using Content.Shared.Mind;
|
||||
using Content.Shared.Preferences;
|
||||
@@ -59,7 +60,9 @@ namespace Content.Server.GameTicking
|
||||
return spawnableStations;
|
||||
}
|
||||
|
||||
private void SpawnPlayers(List<ICommonSession> readyPlayers, Dictionary<NetUserId, HumanoidCharacterProfile> profiles, bool force)
|
||||
private void SpawnPlayers(List<ICommonSession> 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));
|
||||
@@ -120,10 +123,17 @@ namespace Content.Server.GameTicking
|
||||
RefreshLateJoinAllowed();
|
||||
|
||||
// Allow rules to add roles to players who have been spawned in. (For example, on-station traitors)
|
||||
RaiseLocalEvent(new RulePlayerJobsAssignedEvent(assignedJobs.Keys.Select(x => _playerManager.GetSessionById(x)).ToArray(), profiles, force));
|
||||
RaiseLocalEvent(new RulePlayerJobsAssignedEvent(
|
||||
assignedJobs.Keys.Select(x => _playerManager.GetSessionById(x)).ToArray(),
|
||||
profiles,
|
||||
force));
|
||||
}
|
||||
|
||||
private void SpawnPlayer(ICommonSession player, EntityUid station, string? jobId = null, bool lateJoin = true, bool silent = false)
|
||||
private void SpawnPlayer(ICommonSession player,
|
||||
EntityUid station,
|
||||
string? jobId = null,
|
||||
bool lateJoin = true,
|
||||
bool silent = false)
|
||||
{
|
||||
var character = GetPlayerProfile(player);
|
||||
|
||||
@@ -136,7 +146,12 @@ namespace Content.Server.GameTicking
|
||||
SpawnPlayer(player, character, station, jobId, lateJoin, silent);
|
||||
}
|
||||
|
||||
private void SpawnPlayer(ICommonSession player, HumanoidCharacterProfile character, EntityUid station, string? jobId = null, bool lateJoin = true, bool silent = false)
|
||||
private void SpawnPlayer(ICommonSession player,
|
||||
HumanoidCharacterProfile character,
|
||||
EntityUid station,
|
||||
string? jobId = null,
|
||||
bool lateJoin = true,
|
||||
bool silent = false)
|
||||
{
|
||||
// Can't spawn players with a dummy ticker!
|
||||
if (DummyTicker)
|
||||
@@ -244,7 +259,9 @@ namespace Content.Server.GameTicking
|
||||
restrictedRoles.UnionWith(jobBans);
|
||||
|
||||
// Pick best job best on prefs.
|
||||
jobId ??= _stationJobs.PickBestAvailableJobWithPriority(station, character.JobPriorities, true,
|
||||
jobId ??= _stationJobs.PickBestAvailableJobWithPriority(station,
|
||||
character.JobPriorities,
|
||||
true,
|
||||
restrictedRoles);
|
||||
// If no job available, stay in lobby, or if no lobby spawn as observer
|
||||
if (jobId is null)
|
||||
@@ -253,7 +270,9 @@ namespace Content.Server.GameTicking
|
||||
{
|
||||
JoinAsObserver(player);
|
||||
}
|
||||
_chatManager.DispatchServerMessage(player, Loc.GetString("game-ticker-player-no-jobs-available-when-joining"));
|
||||
|
||||
_chatManager.DispatchServerMessage(player,
|
||||
Loc.GetString("game-ticker-player-no-jobs-available-when-joining"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -267,7 +286,7 @@ namespace Content.Server.GameTicking
|
||||
_mind.SetUserId(newMind, data.UserId);
|
||||
|
||||
var jobPrototype = _prototypeManager.Index<JobPrototype>(jobId);
|
||||
var job = new JobComponent { Prototype = jobId };
|
||||
var job = new JobComponent {Prototype = jobId};
|
||||
_roles.MindAddRole(newMind, job, silent: silent);
|
||||
var jobName = _jobs.MindTryGetJobName(newMind);
|
||||
|
||||
@@ -311,12 +330,11 @@ namespace Content.Server.GameTicking
|
||||
if (lateJoin && !silent)
|
||||
{
|
||||
_chatSystem.DispatchStationAnnouncement(station,
|
||||
Loc.GetString(
|
||||
"latejoin-arrival-announcement",
|
||||
("character", MetaData(mob).EntityName),
|
||||
Loc.GetString("latejoin-arrival-announcement",
|
||||
("character", MetaData(mob).EntityName),
|
||||
("gender", character.Gender), // WD-EDIT
|
||||
("job", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(jobName))
|
||||
), Loc.GetString("latejoin-arrival-sender"),
|
||||
("job", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(jobName))),
|
||||
Loc.GetString("latejoin-arrival-sender"),
|
||||
playDefaultSound: false);
|
||||
}
|
||||
|
||||
@@ -328,14 +346,17 @@ namespace Content.Server.GameTicking
|
||||
_stationJobs.TryAssignJob(station, jobPrototype, player.UserId);
|
||||
|
||||
if (lateJoin)
|
||||
_adminLogger.Add(LogType.LateJoin, LogImpact.Medium, $"Player {player.Name} late joined as {character.Name:characterName} on station {Name(station):stationName} with {ToPrettyString(mob):entity} as a {jobName:jobName}.");
|
||||
_adminLogger.Add(LogType.LateJoin,
|
||||
LogImpact.Medium,
|
||||
$"Player {player.Name} late joined as {character.Name:characterName} on station {Name(station):stationName} with {ToPrettyString(mob):entity} as a {jobName:jobName}.");
|
||||
else
|
||||
_adminLogger.Add(LogType.RoundStartJoin, LogImpact.Medium, $"Player {player.Name} joined as {character.Name:characterName} on station {Name(station):stationName} with {ToPrettyString(mob):entity} as a {jobName:jobName}.");
|
||||
_adminLogger.Add(LogType.RoundStartJoin,
|
||||
LogImpact.Medium,
|
||||
$"Player {player.Name} joined as {character.Name:characterName} on station {Name(station):stationName} with {ToPrettyString(mob):entity} as a {jobName:jobName}.");
|
||||
|
||||
// Make sure they're aware of extended access.
|
||||
if (Comp<StationJobsComponent>(station).ExtendedAccess
|
||||
&& (jobPrototype.ExtendedAccess.Count > 0
|
||||
|| jobPrototype.ExtendedAccessGroups.Count > 0))
|
||||
&& (jobPrototype.ExtendedAccess.Count > 0 || jobPrototype.ExtendedAccessGroups.Count > 0))
|
||||
{
|
||||
_chatManager.DispatchServerMessage(player, Loc.GetString("job-greet-crew-shortages"));
|
||||
}
|
||||
@@ -357,14 +378,20 @@ namespace Content.Server.GameTicking
|
||||
}
|
||||
else
|
||||
{
|
||||
_chatManager.DispatchServerMessage(player, Loc.GetString("latejoin-arrivals-direction-time",
|
||||
("time", $"{arrival:mm\\:ss}")));
|
||||
_chatManager.DispatchServerMessage(player,
|
||||
Loc.GetString("latejoin-arrivals-direction-time", ("time", $"{arrival:mm\\:ss}")));
|
||||
}
|
||||
}
|
||||
|
||||
// We raise this event directed to the mob, but also broadcast it so game rules can do something now.
|
||||
PlayersJoinedRoundNormally++;
|
||||
var aev = new PlayerSpawnCompleteEvent(mob, player, jobId, lateJoin, PlayersJoinedRoundNormally, station, character);
|
||||
var aev = new PlayerSpawnCompleteEvent(mob,
|
||||
player,
|
||||
jobId,
|
||||
lateJoin,
|
||||
PlayersJoinedRoundNormally,
|
||||
station,
|
||||
character);
|
||||
RaiseLocalEvent(mob, aev, true);
|
||||
}
|
||||
|
||||
@@ -485,32 +512,24 @@ namespace Content.Server.GameTicking
|
||||
if (DummyTicker)
|
||||
return;
|
||||
|
||||
var mind = player.GetMind();
|
||||
Entity<MindComponent?>? mind = player.GetMind();
|
||||
if (mind == null)
|
||||
{
|
||||
mind = _mind.CreateMind(player.UserId);
|
||||
var name = GetPlayerProfile(player).Name;
|
||||
var (mindId, mindComp) = _mind.CreateMind(player.UserId, name);
|
||||
mind = (mindId, mindComp);
|
||||
_mind.SetUserId(mind.Value, player.UserId);
|
||||
_roles.MindAddRole(mind.Value, new ObserverRoleComponent());
|
||||
}
|
||||
|
||||
var name = GetPlayerProfile(player).Name;
|
||||
|
||||
var ghost = SpawnObserverMob();
|
||||
_metaData.SetEntityName(ghost, name);
|
||||
_ghost.SetCanReturnToBody(ghost, false);
|
||||
_mind.TransferTo(mind.Value, ghost);
|
||||
_adminLogger.Add(LogType.LateJoin, LogImpact.Low, $"{player.Name} late joined the round as an Observer with {ToPrettyString(ghost):entity}.");
|
||||
var ghost = _ghost.SpawnGhost(mind.Value);
|
||||
_adminLogger.Add(LogType.LateJoin,
|
||||
LogImpact.Low,
|
||||
$"{player.Name} late joined the round as an Observer with {ToPrettyString(ghost):entity}.");
|
||||
}
|
||||
|
||||
#region Mob Spawning Helpers
|
||||
private EntityUid SpawnObserverMob()
|
||||
{
|
||||
var coordinates = GetObserverSpawnPoint();
|
||||
return EntityManager.SpawnEntity(ObserverPrototypeName, coordinates);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Spawn Points
|
||||
|
||||
public EntityCoordinates GetObserverSpawnPoint()
|
||||
{
|
||||
_possiblePositions.Clear();
|
||||
@@ -531,8 +550,7 @@ namespace Content.Server.GameTicking
|
||||
var query = AllEntityQuery<MapGridComponent>();
|
||||
while (query.MoveNext(out var uid, out var grid))
|
||||
{
|
||||
if (!metaQuery.TryGetComponent(uid, out var meta) ||
|
||||
meta.EntityPaused)
|
||||
if (!metaQuery.TryGetComponent(uid, out var meta) || meta.EntityPaused || TerminatingOrDeleted(uid))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -553,8 +571,7 @@ namespace Content.Server.GameTicking
|
||||
{
|
||||
var gridXform = Transform(gridUid);
|
||||
|
||||
return new EntityCoordinates(gridUid,
|
||||
gridXform.InvWorldMatrix.Transform(toMap.Position));
|
||||
return new EntityCoordinates(gridUid, gridXform.InvWorldMatrix.Transform(toMap.Position));
|
||||
}
|
||||
|
||||
return spawn;
|
||||
@@ -570,8 +587,9 @@ namespace Content.Server.GameTicking
|
||||
{
|
||||
var mapUid = _mapManager.GetMapEntityId(map);
|
||||
|
||||
if (!metaQuery.TryGetComponent(mapUid, out var meta) ||
|
||||
meta.EntityPaused)
|
||||
if (!metaQuery.TryGetComponent(mapUid, out var meta)
|
||||
|| meta.EntityPaused
|
||||
|| TerminatingOrDeleted(mapUid))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -584,6 +602,7 @@ namespace Content.Server.GameTicking
|
||||
_sawmill.Warning("Found no observer spawn points!");
|
||||
return EntityCoordinates.Invalid;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -601,7 +620,11 @@ namespace Content.Server.GameTicking
|
||||
public bool LateJoin { get; }
|
||||
public EntityUid Station { get; }
|
||||
|
||||
public PlayerBeforeSpawnEvent(ICommonSession player, HumanoidCharacterProfile profile, string? jobId, bool lateJoin, EntityUid station)
|
||||
public PlayerBeforeSpawnEvent(ICommonSession player,
|
||||
HumanoidCharacterProfile profile,
|
||||
string? jobId,
|
||||
bool lateJoin,
|
||||
EntityUid station)
|
||||
{
|
||||
Player = player;
|
||||
Profile = profile;
|
||||
@@ -629,7 +652,13 @@ namespace Content.Server.GameTicking
|
||||
// Ex. If this is the 27th person to join, this will be 27.
|
||||
public int JoinOrder { get; }
|
||||
|
||||
public PlayerSpawnCompleteEvent(EntityUid mob, ICommonSession player, string? jobId, bool lateJoin, int joinOrder, EntityUid station, HumanoidCharacterProfile profile)
|
||||
public PlayerSpawnCompleteEvent(EntityUid mob,
|
||||
ICommonSession player,
|
||||
string? jobId,
|
||||
bool lateJoin,
|
||||
int joinOrder,
|
||||
EntityUid station,
|
||||
HumanoidCharacterProfile profile)
|
||||
{
|
||||
Mob = mob;
|
||||
Player = player;
|
||||
|
||||
@@ -29,6 +29,7 @@ using Robust.Server.Player;
|
||||
using Content.Shared._White;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Player;
|
||||
@@ -55,11 +56,19 @@ namespace Content.Server.Ghost
|
||||
[Dependency] private readonly VisibilitySystem _visibilitySystem = default!;
|
||||
[Dependency] private readonly IChatManager _chatManager = default!;
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly MetaDataSystem _metaData = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
|
||||
private EntityQuery<GhostComponent> _ghostQuery;
|
||||
private EntityQuery<PhysicsComponent> _physicsQuery;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_ghostQuery = GetEntityQuery<GhostComponent>();
|
||||
_physicsQuery = GetEntityQuery<PhysicsComponent>();
|
||||
|
||||
SubscribeLocalEvent<GhostComponent, ComponentStartup>(OnGhostStartup);
|
||||
SubscribeLocalEvent<GhostComponent, MapInitEvent>(OnMapInit);
|
||||
SubscribeLocalEvent<GhostComponent, ComponentShutdown>(OnGhostShutdown);
|
||||
@@ -75,6 +84,7 @@ namespace Content.Server.Ghost
|
||||
SubscribeNetworkEvent<GhostWarpsRequestEvent>(OnGhostWarpsRequest);
|
||||
SubscribeNetworkEvent<GhostReturnToBodyRequest>(OnGhostReturnToBodyRequest);
|
||||
SubscribeNetworkEvent<GhostWarpToTargetRequestEvent>(OnGhostWarpToTargetRequest);
|
||||
SubscribeNetworkEvent<GhostnadoRequestEvent>(OnGhostnadoRequest);
|
||||
|
||||
SubscribeNetworkEvent<GhostReturnToRoundRequest>(OnGhostReturnToRoundRequest);
|
||||
|
||||
@@ -319,7 +329,7 @@ namespace Content.Server.Ghost
|
||||
private void OnGhostReturnToBodyRequest(GhostReturnToBodyRequest msg, EntitySessionEventArgs args)
|
||||
{
|
||||
if (args.SenderSession.AttachedEntity is not {Valid: true} attached
|
||||
|| !TryComp(attached, out GhostComponent? ghost)
|
||||
|| !_ghostQuery.TryComp(attached, out var ghost)
|
||||
|| !ghost.CanReturnToBody
|
||||
|| !TryComp(attached, out ActorComponent? actor))
|
||||
{
|
||||
@@ -335,7 +345,7 @@ namespace Content.Server.Ghost
|
||||
private void OnGhostWarpsRequest(GhostWarpsRequestEvent msg, EntitySessionEventArgs args)
|
||||
{
|
||||
if (args.SenderSession.AttachedEntity is not {Valid: true} entity
|
||||
|| !HasComp<GhostComponent>(entity))
|
||||
|| !_ghostQuery.HasComp(entity))
|
||||
{
|
||||
Log.Warning($"User {args.SenderSession.Name} sent a {nameof(GhostWarpsRequestEvent)} without being a ghost.");
|
||||
return;
|
||||
@@ -348,7 +358,7 @@ namespace Content.Server.Ghost
|
||||
private void OnGhostWarpToTargetRequest(GhostWarpToTargetRequestEvent msg, EntitySessionEventArgs args)
|
||||
{
|
||||
if (args.SenderSession.AttachedEntity is not {Valid: true} attached
|
||||
|| !TryComp(attached, out GhostComponent? _))
|
||||
|| !_ghostQuery.HasComp(attached))
|
||||
{
|
||||
Log.Warning($"User {args.SenderSession.Name} tried to warp to {msg.Target} without being a ghost.");
|
||||
return;
|
||||
@@ -362,17 +372,37 @@ namespace Content.Server.Ghost
|
||||
return;
|
||||
}
|
||||
|
||||
if ((TryComp(target, out WarpPointComponent? warp) && warp.Follow) || HasComp<MobStateComponent>(target))
|
||||
WarpTo(attached, target);
|
||||
}
|
||||
|
||||
private void OnGhostnadoRequest(GhostnadoRequestEvent msg, EntitySessionEventArgs args)
|
||||
{
|
||||
if (args.SenderSession.AttachedEntity is not {} uid
|
||||
|| !_ghostQuery.HasComp(uid))
|
||||
{
|
||||
_followerSystem.StartFollowingEntity(attached, target);
|
||||
Log.Warning($"User {args.SenderSession.Name} tried to ghostnado without being a ghost.");
|
||||
return;
|
||||
}
|
||||
|
||||
var xform = Transform(attached);
|
||||
_transformSystem.SetCoordinates(attached, xform, Transform(target).Coordinates);
|
||||
_transformSystem.AttachToGridOrMap(attached, xform);
|
||||
if (TryComp(attached, out PhysicsComponent? physics))
|
||||
_physics.SetLinearVelocity(attached, Vector2.Zero, body: physics);
|
||||
if (_followerSystem.GetMostFollowed() is not {} target)
|
||||
return;
|
||||
|
||||
WarpTo(uid, target);
|
||||
}
|
||||
|
||||
private void WarpTo(EntityUid uid, EntityUid target)
|
||||
{
|
||||
if ((TryComp(target, out WarpPointComponent? warp) && warp.Follow) || HasComp<MobStateComponent>(target))
|
||||
{
|
||||
_followerSystem.StartFollowingEntity(uid, target);
|
||||
return;
|
||||
}
|
||||
|
||||
var xform = Transform(uid);
|
||||
_transformSystem.SetCoordinates(uid, xform, Transform(target).Coordinates);
|
||||
_transformSystem.AttachToGridOrMap(uid, xform);
|
||||
if (_physicsQuery.TryComp(uid, out var physics))
|
||||
_physics.SetLinearVelocity(uid, Vector2.Zero, body: physics);
|
||||
}
|
||||
|
||||
private IEnumerable<GhostWarp> GetLocationWarps()
|
||||
@@ -444,5 +474,59 @@ namespace Content.Server.Ghost
|
||||
|
||||
return ghostBoo.Handled;
|
||||
}
|
||||
|
||||
public EntityUid? SpawnGhost(Entity<MindComponent?> mind, EntityUid targetEntity,
|
||||
bool canReturn = false)
|
||||
{
|
||||
_transformSystem.TryGetMapOrGridCoordinates(targetEntity, out var spawnPosition);
|
||||
return SpawnGhost(mind, spawnPosition, canReturn);
|
||||
}
|
||||
|
||||
public EntityUid? SpawnGhost(Entity<MindComponent?> mind, EntityCoordinates? spawnPosition = null,
|
||||
bool canReturn = false)
|
||||
{
|
||||
if (!Resolve(mind, ref mind.Comp))
|
||||
return null;
|
||||
|
||||
// Test if the map is being deleted
|
||||
var mapUid = spawnPosition?.GetMapUid(EntityManager);
|
||||
if (mapUid == null || TerminatingOrDeleted(mapUid.Value))
|
||||
spawnPosition = null;
|
||||
|
||||
spawnPosition ??= _ticker.GetObserverSpawnPoint();
|
||||
|
||||
if (!spawnPosition.Value.IsValid(EntityManager))
|
||||
{
|
||||
Log.Warning($"No spawn valid ghost spawn position found for {mind.Comp.CharacterName}"
|
||||
+ " \"{ToPrettyString(mind)}\"");
|
||||
_minds.TransferTo(mind.Owner, null, createGhost: false, mind: mind.Comp);
|
||||
return null;
|
||||
}
|
||||
|
||||
var ghost = SpawnAtPosition(GameTicker.ObserverPrototypeName, spawnPosition.Value);
|
||||
var ghostComponent = Comp<GhostComponent>(ghost);
|
||||
|
||||
// Try setting the ghost entity name to either the character name or the player name.
|
||||
// If all else fails, it'll default to the default entity prototype name, "observer".
|
||||
// However, that should rarely happen.
|
||||
if (!string.IsNullOrWhiteSpace(mind.Comp.CharacterName))
|
||||
_metaData.SetEntityName(ghost, mind.Comp.CharacterName);
|
||||
else if (!string.IsNullOrWhiteSpace(mind.Comp.Session?.Name))
|
||||
_metaData.SetEntityName(ghost, mind.Comp.Session.Name);
|
||||
|
||||
if (mind.Comp.TimeOfDeath.HasValue)
|
||||
{
|
||||
SetTimeOfDeath(ghost, mind.Comp.TimeOfDeath!.Value, ghostComponent);
|
||||
}
|
||||
|
||||
SetCanReturnToBody(ghostComponent, canReturn);
|
||||
|
||||
if (canReturn)
|
||||
_minds.Visit(mind.Owner, ghost, mind.Comp);
|
||||
else
|
||||
_minds.TransferTo(mind.Owner, ghost, mind: mind.Comp);
|
||||
Log.Debug($"Spawned ghost \"{ToPrettyString(ghost)}\" for {mind.Comp.CharacterName}.");
|
||||
return ghost;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.Ghost;
|
||||
using Content.Server.Mind.Commands;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Ghost;
|
||||
@@ -9,10 +10,8 @@ using Content.Shared.Mind.Components;
|
||||
using Content.Shared.Players;
|
||||
using Robust.Server.GameStates;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Mind;
|
||||
@@ -22,8 +21,7 @@ public sealed class MindSystem : SharedMindSystem
|
||||
[Dependency] private readonly GameTicker _gameTicker = default!;
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly IPlayerManager _players = default!;
|
||||
[Dependency] private readonly MetaDataSystem _metaData = default!;
|
||||
[Dependency] private readonly SharedGhostSystem _ghosts = default!;
|
||||
[Dependency] private readonly GhostSystem _ghosts = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
[Dependency] private readonly PvsOverrideSystem _pvsOverride = default!;
|
||||
|
||||
@@ -63,8 +61,8 @@ public sealed class MindSystem : SharedMindSystem
|
||||
&& !Terminating(visiting))
|
||||
{
|
||||
TransferTo(mindId, visiting, mind: mind);
|
||||
if (TryComp(visiting, out GhostComponent? ghost))
|
||||
_ghosts.SetCanReturnToBody(ghost, false);
|
||||
if (TryComp(visiting, out GhostComponent? ghostComp))
|
||||
_ghosts.SetCanReturnToBody(ghostComp, false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -74,40 +72,13 @@ public sealed class MindSystem : SharedMindSystem
|
||||
if (!component.GhostOnShutdown || mind.Session == null || _gameTicker.RunLevel == GameRunLevel.PreRoundLobby)
|
||||
return;
|
||||
|
||||
var xform = Transform(uid);
|
||||
var gridId = xform.GridUid;
|
||||
var spawnPosition = Transform(uid).Coordinates;
|
||||
|
||||
// Use a regular timer here because the entity has probably been deleted.
|
||||
Timer.Spawn(0, () =>
|
||||
{
|
||||
// Make extra sure the round didn't end between spawning the timer and it being executed.
|
||||
if (_gameTicker.RunLevel == GameRunLevel.PreRoundLobby)
|
||||
return;
|
||||
|
||||
// Async this so that we don't throw if the grid we're on is being deleted.
|
||||
if (!HasComp<MapGridComponent>(gridId))
|
||||
spawnPosition = _gameTicker.GetObserverSpawnPoint();
|
||||
|
||||
// TODO refactor observer spawning.
|
||||
// please.
|
||||
if (!spawnPosition.IsValid(EntityManager))
|
||||
{
|
||||
// This should be an error, if it didn't cause tests to start erroring when they delete a player.
|
||||
Log.Warning($"Entity \"{ToPrettyString(uid)}\" for {mind.CharacterName} was deleted, and no applicable spawn location is available.");
|
||||
TransferTo(mindId, null, createGhost: false, mind: mind);
|
||||
return;
|
||||
}
|
||||
|
||||
var ghost = Spawn(GameTicker.ObserverPrototypeName, spawnPosition);
|
||||
var ghostComponent = Comp<GhostComponent>(ghost);
|
||||
_ghosts.SetCanReturnToBody(ghostComponent, false);
|
||||
|
||||
var ghost = _ghosts.SpawnGhost((mindId, mind), uid);
|
||||
if (ghost != null)
|
||||
// Log these to make sure they're not causing the GameTicker round restart bugs...
|
||||
Log.Debug($"Entity \"{ToPrettyString(uid)}\" for {mind.CharacterName} was deleted, spawned \"{ToPrettyString(ghost)}\".");
|
||||
_metaData.SetEntityName(ghost, mind.CharacterName ?? string.Empty);
|
||||
TransferTo(mindId, ghost, mind: mind);
|
||||
});
|
||||
else
|
||||
// This should be an error, if it didn't cause tests to start erroring when they delete a player.
|
||||
Log.Warning($"Entity \"{ToPrettyString(uid)}\" for {mind.CharacterName} was deleted, and no applicable spawn location is available.");
|
||||
}
|
||||
|
||||
public override bool TryGetMind(NetUserId user, [NotNullWhen(true)] out EntityUid? mindId, [NotNullWhen(true)] out MindComponent? mind)
|
||||
|
||||
@@ -266,6 +266,27 @@ public sealed class FollowerSystem : EntitySystem
|
||||
StopFollowingEntity(player, uid, followed);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the most followed entity.
|
||||
/// </summary>
|
||||
public EntityUid? GetMostFollowed()
|
||||
{
|
||||
EntityUid? picked = null;
|
||||
int most = 0;
|
||||
var query = EntityQueryEnumerator<FollowedComponent>();
|
||||
while (query.MoveNext(out var uid, out var comp))
|
||||
{
|
||||
var count = comp.Following.Count;
|
||||
if (count > most)
|
||||
{
|
||||
picked = uid;
|
||||
most = count;
|
||||
}
|
||||
}
|
||||
|
||||
return picked;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class FollowEvent : EntityEventArgs
|
||||
|
||||
@@ -125,6 +125,12 @@ namespace Content.Shared.Ghost
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A client to server request for their ghost to be warped to the most followed entity.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class GhostnadoRequestEvent : EntityEventArgs;
|
||||
|
||||
/// <summary>
|
||||
/// A client to server request for their ghost to return to body
|
||||
/// </summary>
|
||||
|
||||
1
Resources/Locale/en-US/burning/bodyburn.ftl
Normal file
1
Resources/Locale/en-US/burning/bodyburn.ftl
Normal file
@@ -0,0 +1 @@
|
||||
bodyburn-text-others = {$name} burns to ash!
|
||||
@@ -19,6 +19,7 @@ ghost-gui-toggle-hearing-popup-off = You can now only hear radio and nearby mess
|
||||
|
||||
ghost-target-window-title = Ghost Warp
|
||||
ghost-target-window-current-button = Warp: {$name}
|
||||
ghost-target-window-warp-to-most-followed = Warp to Most Followed
|
||||
|
||||
ghost-roles-window-title = Ghost Roles
|
||||
ghost-roles-window-request-role-button = Request
|
||||
|
||||
@@ -60,6 +60,21 @@
|
||||
damage: 400
|
||||
behaviors:
|
||||
- !type:GibBehavior { }
|
||||
- trigger:
|
||||
!type:DamageTypeTrigger
|
||||
damageType: Heat
|
||||
damage: 1500
|
||||
behaviors:
|
||||
- !type:SpawnEntitiesBehavior
|
||||
spawnInContainer: true
|
||||
spawn:
|
||||
Ash:
|
||||
min: 1
|
||||
max: 1
|
||||
- !type:BurnBodyBehavior { }
|
||||
- !type:PlaySoundBehavior
|
||||
sound:
|
||||
collection: MeatLaserImpact
|
||||
- type: RadiationReceiver
|
||||
- type: Stamina
|
||||
- type: MobState
|
||||
|
||||
Reference in New Issue
Block a user