Merge remote-tracking branch 'upstream/master' into ups

This commit is contained in:
Jabak
2024-06-26 13:09:06 +03:00
41 changed files with 1376 additions and 282 deletions

View File

@@ -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

View File

@@ -48,9 +48,9 @@ public sealed partial class AccessLevelControl : GridContainer
"ButtonColorSecurityDepartment",
"ButtonColorMedicalDepartment",
"ButtonColorEngineeringDepartment",
"ButtonColorResearchingDepartment",
"ButtonColorScienceDepartment",
"ButtonColorCargoDepartment",
"ButtonColorServiceDepartment"
"ButtonColorCivilianDepartment"
};
var currentColorIndex = 0;

View File

@@ -148,9 +148,7 @@ namespace Content.Client.Ghost
private void OnGhostWarpsResponse(GhostWarpsResponseEvent msg)
{
if (!IsGhost)
{
return;
}
GhostWarpsResponse?.Invoke(msg);
}

View File

@@ -165,8 +165,11 @@ namespace Content.Client.Stylesheets
public static readonly Color ButtonColorMedical = Color.FromHex("#4494C8");
public static readonly Color ButtonColorEngineering = Color.FromHex("#FDA55E");
public static readonly Color ButtonColorCargo = Color.FromHex("#9E6A34");
public static readonly Color ButtonColorResearching = Color.FromHex("#984EB4");
public static readonly Color ButtonColorService = Color.FromHex("#40A166");
public static readonly Color ButtonColorScience = Color.FromHex("#984EB4");
public static readonly Color ButtonColorCivilian = Color.FromHex("#40A166");
public static readonly Color ButtonColorJustice = Color.FromHex("#8E3D3D");
public static readonly Color ButtonColorSpecific = Color.FromHex("#969696");
public static readonly Color ButtonColorAntagonist = Color.FromHex("#7F4141");
public override Stylesheet Stylesheet { get; }
@@ -1383,14 +1386,14 @@ namespace Content.Client.Stylesheets
new SelectorElement(typeof(MenuButton), new[] {MenuButton.StyleClassRedTopButton}, null, new[] {Button.StylePseudoClassNormal}),
new[]
{
new StyleProperty(Button.StylePropertyModulateSelf, ButtonColorService),
new StyleProperty(Button.StylePropertyModulateSelf, ButtonColorCivilian),
}),
new StyleRule(
new SelectorElement(typeof(MenuButton), new[] {MenuButton.StyleClassRedTopButton}, null, new[] {Button.StylePseudoClassNormal}),
new[]
{
new StyleProperty(Button.StylePropertyModulateSelf, ButtonColorResearching),
new StyleProperty(Button.StylePropertyModulateSelf, ButtonColorScience),
}),
new StyleRule(
new SelectorElement(typeof(MenuButton), new[] {MenuButton.StyleClassRedTopButton}, null, new[] {Button.StylePseudoClassNormal}),
@@ -1398,6 +1401,24 @@ namespace Content.Client.Stylesheets
{
new StyleProperty(Button.StylePropertyModulateSelf, ButtonColorCargo),
}),
new StyleRule(
new SelectorElement(typeof(MenuButton), new[] {MenuButton.StyleClassRedTopButton}, null, new[] {Button.StylePseudoClassNormal}),
new[]
{
new StyleProperty(Button.StylePropertyModulateSelf, ButtonColorJustice),
}),
new StyleRule(
new SelectorElement(typeof(MenuButton), new[] {MenuButton.StyleClassRedTopButton}, null, new[] {Button.StylePseudoClassNormal}),
new[]
{
new StyleProperty(Button.StylePropertyModulateSelf, ButtonColorSpecific),
}),
new StyleRule(
new SelectorElement(typeof(MenuButton), new[] {MenuButton.StyleClassRedTopButton}, null, new[] {Button.StylePseudoClassNormal}),
new[]
{
new StyleProperty(Button.StylePropertyModulateSelf, ButtonColorAntagonist),
}),
// NanoHeading
@@ -1657,20 +1678,35 @@ namespace Content.Client.Stylesheets
Element<Button>().Class("ButtonColorEngineeringDepartment").Pseudo(ContainerButton.StylePseudoClassNormal)
.Prop(Control.StylePropertyModulateSelf, ButtonColorEngineering),
Element<Button>().Class("ButtonColorResearchingDepartment")
.Prop(Control.StylePropertyModulateSelf, ButtonColorResearching),
Element<Button>().Class("ButtonColorResearchingDepartment").Pseudo(ContainerButton.StylePseudoClassNormal)
.Prop(Control.StylePropertyModulateSelf, ButtonColorResearching),
Element<Button>().Class("ButtonColorScienceDepartment")
.Prop(Control.StylePropertyModulateSelf, ButtonColorScience),
Element<Button>().Class("ButtonColorScienceDepartment").Pseudo(ContainerButton.StylePseudoClassNormal)
.Prop(Control.StylePropertyModulateSelf, ButtonColorScience),
Element<Button>().Class("ButtonColorServiceDepartment")
.Prop(Control.StylePropertyModulateSelf, ButtonColorService),
Element<Button>().Class("ButtonColorServiceDepartment").Pseudo(ContainerButton.StylePseudoClassNormal)
.Prop(Control.StylePropertyModulateSelf, ButtonColorService),
Element<Button>().Class("ButtonColorCivilianDepartment")
.Prop(Control.StylePropertyModulateSelf, ButtonColorCivilian),
Element<Button>().Class("ButtonColorCivilianDepartment").Pseudo(ContainerButton.StylePseudoClassNormal)
.Prop(Control.StylePropertyModulateSelf, ButtonColorCivilian),
Element<Button>().Class("ButtonColorCargoDepartment")
.Prop(Control.StylePropertyModulateSelf, ButtonColorCargo),
Element<Button>().Class("ButtonColorCargoDepartment").Pseudo(ContainerButton.StylePseudoClassNormal)
.Prop(Control.StylePropertyModulateSelf, ButtonColorCargo),
Element<Button>().Class("ButtonColorJusticeDepartment")
.Prop(Control.StylePropertyModulateSelf, ButtonColorJustice),
Element<Button>().Class("ButtonColorJusticeDepartment").Pseudo(ContainerButton.StylePseudoClassNormal)
.Prop(Control.StylePropertyModulateSelf, ButtonColorJustice),
Element<Button>().Class("ButtonColorSpecificDepartment")
.Prop(Control.StylePropertyModulateSelf, ButtonColorSpecific),
Element<Button>().Class("ButtonColorSpecificDepartment").Pseudo(ContainerButton.StylePseudoClassNormal)
.Prop(Control.StylePropertyModulateSelf, ButtonColorSpecific),
Element<Button>().Class("ButtonColorAntagonistDepartment")
.Prop(Control.StylePropertyModulateSelf, ButtonColorAntagonist),
Element<Button>().Class("ButtonColorAntagonistDepartment").Pseudo(ContainerButton.StylePseudoClassNormal)
.Prop(Control.StylePropertyModulateSelf, ButtonColorAntagonist),
// ---
// Green Button ---

View File

@@ -1,8 +1,7 @@
<DefaultWindow xmlns="https://spacestation14.io" Title="{Loc 'ghost-target-window-title'}" MinSize="450 450" SetSize="450 450">
<DefaultWindow xmlns="https://spacestation14.io" Title="{Loc 'ghost-target-window-title'}" MinSize="950 550" SetSize="950 550">
<BoxContainer Orientation="Vertical" HorizontalExpand="True" SizeFlagsStretchRatio="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">
<BoxContainer Name="GhostTeleportContainter" Orientation="Vertical">
<!-- Target buttons get added here by code -->
</BoxContainer>
</ScrollContainer>

View File

@@ -1,92 +1,346 @@
using System.Linq;
using System.Numerics;
using Content.Shared._White.Antag;
using Content.Shared.Ghost;
using Content.Shared.Roles;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Prototypes;
namespace Content.Client.UserInterface.Systems.Ghost.Controls
{
[GenerateTypedNameReferences]
public sealed partial class GhostTargetWindow : DefaultWindow
{
private List<(string, NetEntity)> _warps = new();
private string _searchText = string.Empty;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
private List<GhostWarpPlayer> _playerWarps = new();
private List<GhostWarpPlace> _placeWarps = new();
private List<GhostWarpGlobalAntagonist> _globalAntoginists = new();
private List<GhostWarpPlayer> _alivePlayers = new();
private List<GhostWarpPlayer> _leftPlayers = new();
private List<GhostWarpPlayer> _deadPlayers = new();
private List<GhostWarpPlayer> _ghostPlayers = new();
public event Action<NetEntity>? WarpClicked;
public GhostTargetWindow()
{
IoCManager.InjectDependencies(this);
RobustXamlLoader.Load(this);
SearchBar.OnTextChanged += OnSearchTextChanged;
}
public void UpdateWarps(IEnumerable<GhostWarp> warps)
{
// Server COULD send these sorted but how about we just use the client to do it instead
_warps = warps
.OrderBy(w => w.IsWarpPoint)
.ThenBy(w => w.DisplayName, Comparer<string>.Create(
(x, y) => string.Compare(x, y, StringComparison.Ordinal)))
.Select(w =>
{
var name = w.IsWarpPoint
? Loc.GetString("ghost-target-window-current-button", ("name", w.DisplayName))
: w.DisplayName;
return (name, w.Entity);
})
.ToList();
}
public void Populate()
{
ButtonContainer.DisposeAllChildren();
GhostTeleportContainter.DisposeAllChildren();
_playerWarps = GetSortedPlayers(_playerWarps);
_placeWarps = GetSortedPlaces(_placeWarps);
_globalAntoginists = GetSortedAntagonists(_globalAntoginists);
PlayersAllocation();
AddButtons();
}
public void UpdateWarps(List<GhostWarpPlayer> players, List<GhostWarpPlace> places, List<GhostWarpGlobalAntagonist> antagonists)
{
_playerWarps = players;
_placeWarps = places;
_globalAntoginists = antagonists;
}
private void AddButtons()
{
foreach (var (name, warpTarget) in _warps)
AddAntagButtons(_globalAntoginists, "ghost-teleport-menu-antagonists-label", "ButtonColorAntagonistDepartment");
AddPlayerButtons(_alivePlayers, "ghost-teleport-menu-alive-label", string.Empty, true); // Alive
AddPlayerButtons(_deadPlayers, "ghost-teleport-menu-dead-label", string.Empty, true); // Dead
AddPlayerButtons(_ghostPlayers, "ghost-teleport-menu-ghosts-label", string.Empty, true); // Ghost
AddPlayerButtons(_leftPlayers, "ghost-teleport-menu-left-label", string.Empty, true); // Left
AddPlaceButtons(_placeWarps, "ghost-teleport-menu-locations-label", "ButtonColorSpecificDepartment");
}
private void AddPlayerButtons(List<GhostWarpPlayer> players, string text, string styleClass,
bool enableByDepartmentColorSheet)
{
if (players.Count == 0)
return;
var bigGrid = new GridContainer();
var bigLabel = new Label
{
var currentButtonRef = new Button
Text = Loc.GetString(text),
StyleClasses = { "LabelBig" }
};
bigGrid.AddChild(bigLabel);
var sortedPlayers = SortPlayersByDepartment(players);
foreach (var departmentList in sortedPlayers)
{
if (departmentList.Count == 0)
continue;
var departmentGrid = new GridContainer
{
Text = name,
Columns = 5
};
if (enableByDepartmentColorSheet)
styleClass = _prototypeManager.Index<DepartmentPrototype>(departmentList[0].DepartmentID).ButtonStyle;
var labelText = _prototypeManager.Index<DepartmentPrototype>(departmentList[0].DepartmentID).Name;
var departmentLabel = new Label
{
Text = Loc.GetString(labelText) + ": " + departmentList.Count,
StyleClasses = { "LabelSecondaryColor" }
};
foreach (var player in departmentList)
{
var playerButton = new Button
{
Text = player.Name,
TextAlign = Label.AlignMode.Right,
HorizontalAlignment = HAlignment.Center,
VerticalAlignment = VAlignment.Center,
SizeFlagsStretchRatio = 1,
StyleClasses = { styleClass },
ToolTip = player.JobName,
TooltipDelay = 0.1f,
SetWidth = 180,
};
playerButton.OnPressed += _ => WarpClicked?.Invoke(player.Entity);
departmentGrid.AddChild(playerButton);
}
bigGrid.AddChild(departmentLabel);
bigGrid.AddChild(departmentGrid);
}
GhostTeleportContainter.AddChild(bigGrid);
}
private void AddPlaceButtons(List<GhostWarpPlace> places, string text, string styleClass)
{
if (places.Count == 0)
return;
var bigGrid = new GridContainer();
var bigLabel = new Label
{
Text = Loc.GetString(text),
StyleClasses = { "LabelBig" }
};
bigGrid.AddChild(bigLabel);
var placesGrid = new GridContainer
{
Columns = 5,
};
var countLabel = new Label
{
Text = Loc.GetString("ghost-teleport-menu-count-label") + ": " + places.Count,
StyleClasses = { "LabelSecondaryColor" }
};
foreach (var place in places)
{
var placeButton = new Button
{
Text = place.Name,
TextAlign = Label.AlignMode.Right,
HorizontalAlignment = HAlignment.Center,
VerticalAlignment = VAlignment.Center,
SizeFlagsStretchRatio = 1,
MinSize = new Vector2(340, 20),
ClipText = true,
StyleClasses = { styleClass },
ToolTip = place.Description,
TooltipDelay = 0.1f,
SetWidth = 180,
};
currentButtonRef.OnPressed += _ => WarpClicked?.Invoke(warpTarget);
currentButtonRef.Visible = ButtonIsVisible(currentButtonRef);
placeButton.OnPressed += _ => WarpClicked?.Invoke(place.Entity);
ButtonContainer.AddChild(currentButtonRef);
placesGrid.AddChild(placeButton);
}
bigGrid.AddChild(countLabel);
bigGrid.AddChild(placesGrid);
GhostTeleportContainter.AddChild(bigGrid);
}
private bool ButtonIsVisible(Button button)
private void AddAntagButtons(List<GhostWarpGlobalAntagonist> antags, string text, string styleClass)
{
return string.IsNullOrEmpty(_searchText) || button.Text == null || button.Text.Contains(_searchText, StringComparison.OrdinalIgnoreCase);
}
if (antags.Count == 0)
return;
private void UpdateVisibleButtons()
{
foreach (var child in ButtonContainer.Children)
var bigGrid = new GridContainer();
var bigLabel = new Label
{
if (child is Button button)
button.Visible = ButtonIsVisible(button);
Text = Loc.GetString(text),
StyleClasses = { "LabelBig" }
};
bigGrid.AddChild(bigLabel);
var sortedAntags = SortAntagsByWeight(antags);
foreach (var antagList in sortedAntags)
{
if (antagList.Count == 0)
continue;
var departmentGrid = new GridContainer
{
Columns = 5
};
var labelText = "ghost-teleport-menu-count-label";
foreach (var antag in antagList)
{
var playerButton = new Button
{
Text = antag.Name,
TextAlign = Label.AlignMode.Right,
HorizontalAlignment = HAlignment.Center,
VerticalAlignment = VAlignment.Center,
SizeFlagsStretchRatio = 1,
StyleClasses = { styleClass },
ToolTip = Loc.GetString(antag.AntagonistDescription),
TooltipDelay = 0.1f,
SetWidth = 180,
};
playerButton.OnPressed += _ => WarpClicked?.Invoke(antag.Entity);
departmentGrid.AddChild(playerButton);
labelText = antag.AntagonistName;
}
var departmentLabel = new Label
{
Text = Loc.GetString(labelText) + ": " + antagList.Count,
StyleClasses = { "LabelSecondaryColor" }
};
bigGrid.AddChild(departmentLabel);
bigGrid.AddChild(departmentGrid);
}
GhostTeleportContainter.AddChild(bigGrid);
}
private void OnSearchTextChanged(LineEdit.LineEditEventArgs args)
public List<List<GhostWarpPlayer>> SortPlayersByDepartment(List<GhostWarpPlayer> players)
{
_searchText = args.Text;
var sortedPlayers = new List<List<GhostWarpPlayer>>();
UpdateVisibleButtons();
players = players.OrderBy(p => _prototypeManager.Index<DepartmentPrototype>(p.DepartmentID).Weight).ToList();
var currentList = new List<GhostWarpPlayer>();
var currentWeight = _prototypeManager.Index<DepartmentPrototype>(players[0].DepartmentID).Weight;
foreach (var player in players)
{
var weight = _prototypeManager.Index<DepartmentPrototype>(player.DepartmentID).Weight;
if (weight == currentWeight)
{
currentList.Add(player);
}
else
{
sortedPlayers.Add(currentList);
currentList = new List<GhostWarpPlayer> { player };
currentWeight = weight;
}
}
if (!sortedPlayers.Contains(currentList))
sortedPlayers.Add(currentList);
sortedPlayers.Reverse();
return sortedPlayers;
}
public List<List<GhostWarpGlobalAntagonist>> SortAntagsByWeight(List<GhostWarpGlobalAntagonist> antagonists)
{
var sortedAntags = new List<List<GhostWarpGlobalAntagonist>>();
antagonists = antagonists.OrderBy(a => _prototypeManager.Index<AntagonistPrototype>(a.PrototypeID).Weight).ToList();
var currentList = new List<GhostWarpGlobalAntagonist>();
var currentWeight = _prototypeManager.Index<AntagonistPrototype>(antagonists[0].PrototypeID).Weight;
foreach (var antagonist in antagonists)
{
var weight = _prototypeManager.Index<AntagonistPrototype>(antagonist.PrototypeID).Weight;
if (weight == currentWeight)
{
currentList.Add(antagonist);
}
else
{
sortedAntags.Add(currentList);
currentList = new List<GhostWarpGlobalAntagonist> { antagonist };
currentWeight = weight;
}
}
if (!sortedAntags.Contains(currentList))
sortedAntags.Add(currentList);
return sortedAntags;
}
private List<GhostWarpPlace> GetSortedPlaces(List<GhostWarpPlace> places)
{
return places
.OrderBy(w => w.Name)
.ToList();
}
private List<GhostWarpPlayer> GetSortedPlayers(List<GhostWarpPlayer> players)
{
return players
.OrderBy(w => w.Name)
.ToList();
}
private List<GhostWarpGlobalAntagonist> GetSortedAntagonists(List<GhostWarpGlobalAntagonist> antagonists)
{
return antagonists
.OrderBy(w => w.Name)
.ToList();
}
private void PlayersAllocation()
{
_alivePlayers.Clear();
_deadPlayers.Clear();
_leftPlayers.Clear();
_ghostPlayers.Clear();
foreach (var warp in _playerWarps)
{
if (warp.IsDead)
_deadPlayers.Add(warp);
else if (warp.IsLeft)
_leftPlayers.Add(warp);
else if (warp.IsAlive)
_alivePlayers.Add(warp);
else if (warp.IsGhost)
_ghostPlayers.Add(warp);
}
}
}
}

View File

@@ -1,7 +1,7 @@
using Content.Client.Gameplay;
using Content.Client.Ghost;
using Content.Client.Ghost;
using Content.Client.UserInterface.Systems.Gameplay;
using Content.Client.UserInterface.Systems.Ghost.Widgets;
using Content.Shared._White.MagGloves;
using Content.Shared.Ghost;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controllers;
@@ -59,9 +59,7 @@ public sealed class GhostUIController : UIController, IOnSystemChanged<GhostSyst
public void UpdateGui()
{
if (Gui == null)
{
return;
}
Gui.Visible = _system?.IsGhost ?? false;
Gui.Update(_system?.AvailableGhostRoleCount, _system?.Player?.CanReturnToBody);
@@ -96,7 +94,7 @@ public sealed class GhostUIController : UIController, IOnSystemChanged<GhostSyst
if (Gui?.TargetWindow is not { } window)
return;
window.UpdateWarps(msg.Warps);
window.UpdateWarps(msg.Players, msg.Places, msg.Antagonists);
window.Populate();
}
@@ -122,7 +120,6 @@ public sealed class GhostUIController : UIController, IOnSystemChanged<GhostSyst
Gui.TargetWindow.WarpClicked += OnWarpClicked;
Gui.ReturnToRoundPressed += ReturnToRound;
UpdateGui();
}

View File

@@ -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(() =>

View 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();
}
}

View File

@@ -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
});

View File

@@ -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);
}
}

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -46,6 +46,7 @@ using Robust.Shared.Random;
using Robust.Shared.Utility;
using System.Linq;
using Content.Server.StationEvents.Components;
using Content.Shared._White.Antag;
using Content.Shared.FixedPoint;
using Content.Shared.Mind;
@@ -731,6 +732,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem<NukeopsRuleComponent>
{
_metaData.SetEntityName(mob, name);
EnsureComp<NukeOperativeComponent>(mob);
EnsureComp<GlobalAntagonistComponent>(mob).AntagonistPrototype = "globalAntagonistNukeops";
if (profile != null)
_humanoid.LoadProfile(mob, profile);

View File

@@ -27,11 +27,17 @@ using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Content.Shared._White;
using Content.Shared._White.Antag;
using Content.Shared.Humanoid;
using Content.Shared.Roles;
using Content.Shared.SSDIndicator;
using Robust.Shared.Configuration;
using Robust.Shared.Map;
using Robust.Shared.Network;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using InvisibilityComponent = Content.Shared._White.Administration.InvisibilityComponent;
@@ -55,11 +61,20 @@ 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 IPrototypeManager _prototypeManager = 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);
@@ -101,8 +116,13 @@ namespace Content.Server.Ghost
{
var message = Loc.GetString("ghost-respawn-max-players", ("players", maxPlayers));
var wrappedMessage = Loc.GetString("chat-manager-server-wrap-message", ("message", message));
_chatManager.ChatMessageToOne(Shared.Chat.ChatChannel.Server, message,
wrappedMessage, default, false, args.SenderSession.ConnectedClient, Color.Red);
_chatManager.ChatMessageToOne(Shared.Chat.ChatChannel.Server,
message,
wrappedMessage,
default,
false,
args.SenderSession.ConnectedClient,
Color.Red);
return;
}
@@ -113,13 +133,18 @@ namespace Content.Server.Ghost
{
var message = Loc.GetString("ghost-respawn-bug");
var wrappedMessage = Loc.GetString("chat-manager-server-wrap-message", ("message", message));
_chatManager.ChatMessageToOne(Shared.Chat.ChatChannel.Server, message,
wrappedMessage, default, false, args.SenderSession.ConnectedClient, Color.Red);
_chatManager.ChatMessageToOne(Shared.Chat.ChatChannel.Server,
message,
wrappedMessage,
default,
false,
args.SenderSession.ConnectedClient,
Color.Red);
_deathTime[userId] = _gameTiming.CurTime;
return;
}
var timeUntilRespawn = (double)cfg.GetCVar(WhiteCVars.GhostRespawnTime);
var timeUntilRespawn = (double) cfg.GetCVar(WhiteCVars.GhostRespawnTime);
var timePast = (_gameTiming.CurTime - deathTime).TotalMinutes;
if (timePast >= timeUntilRespawn)
{
@@ -131,20 +156,32 @@ namespace Content.Server.Ghost
ticker.Respawn(targetPlayer);
_deathTime.Remove(userId);
_adminLogger.Add(LogType.Mind, LogImpact.Extreme, $"{args.SenderSession.ConnectedClient.UserName} вернулся в лобби посредством гост респавна.");
_adminLogger.Add(LogType.Mind,
LogImpact.Extreme,
$"{args.SenderSession.ConnectedClient.UserName} вернулся в лобби посредством гост респавна.");
var message = Loc.GetString("ghost-respawn-window-rules-footer");
var wrappedMessage = Loc.GetString("chat-manager-server-wrap-message", ("message", message));
_chatManager.ChatMessageToOne(Shared.Chat.ChatChannel.Server, message,
wrappedMessage, default, false, args.SenderSession.ConnectedClient, Color.Red);
_chatManager.ChatMessageToOne(Shared.Chat.ChatChannel.Server,
message,
wrappedMessage,
default,
false,
args.SenderSession.ConnectedClient,
Color.Red);
}
else
{
var message = Loc.GetString("ghost-respawn-time-left", ("time", (int)(timeUntilRespawn-timePast)));
var message = Loc.GetString("ghost-respawn-time-left", ("time", (int) (timeUntilRespawn - timePast)));
var wrappedMessage = Loc.GetString("chat-manager-server-wrap-message", ("message", message));
_chatManager.ChatMessageToOne(Shared.Chat.ChatChannel.Server, message,
wrappedMessage, default, false, args.SenderSession.ConnectedClient, Color.Red);
_chatManager.ChatMessageToOne(Shared.Chat.ChatChannel.Server,
message,
wrappedMessage,
default,
false,
args.SenderSession.ConnectedClient,
Color.Red);
}
}
@@ -318,8 +355,8 @@ 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)
if (args.SenderSession.AttachedEntity is not { Valid: true } attached
|| !_ghostQuery.TryComp(attached, out var ghost)
|| !ghost.CanReturnToBody
|| !TryComp(attached, out ActorComponent? actor))
{
@@ -334,21 +371,22 @@ namespace Content.Server.Ghost
private void OnGhostWarpsRequest(GhostWarpsRequestEvent msg, EntitySessionEventArgs args)
{
if (args.SenderSession.AttachedEntity is not {Valid: true} entity
|| !HasComp<GhostComponent>(entity))
if (args.SenderSession.AttachedEntity is not { Valid: true } entity
|| !_ghostQuery.HasComp(entity))
{
Log.Warning($"User {args.SenderSession.Name} sent a {nameof(GhostWarpsRequestEvent)} without being a ghost.");
Log.Warning(
$"User {args.SenderSession.Name} sent a {nameof(GhostWarpsRequestEvent)} without being a ghost.");
return;
}
var response = new GhostWarpsResponseEvent(GetPlayerWarps(entity).Concat(GetLocationWarps()).ToList());
var response = new GhostWarpsResponseEvent(GetPlayerWarps(), GetLocationWarps(), GetAntagonistWarps());
RaiseNetworkEvent(response, args.SenderSession.Channel);
}
private void OnGhostWarpToTargetRequest(GhostWarpToTargetRequestEvent msg, EntitySessionEventArgs args)
{
if (args.SenderSession.AttachedEntity is not {Valid: true} attached
|| !TryComp(attached, out GhostComponent? _))
if (args.SenderSession.AttachedEntity is not { Valid: true } attached
|| !_ghostQuery.HasComp(attached))
{
Log.Warning($"User {args.SenderSession.Name} tried to warp to {msg.Target} without being a ghost.");
return;
@@ -373,40 +411,121 @@ namespace Content.Server.Ghost
_transformSystem.AttachToGridOrMap(attached, xform);
if (TryComp(attached, out PhysicsComponent? physics))
_physics.SetLinearVelocity(attached, Vector2.Zero, body: physics);
WarpTo(attached, target);
}
private IEnumerable<GhostWarp> GetLocationWarps()
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 List<GhostWarpPlace> GetLocationWarps()
{
var warps = new List<GhostWarpPlace> { };
var allQuery = AllEntityQuery<WarpPointComponent>();
while (allQuery.MoveNext(out var uid, out var warp))
{
yield return new GhostWarp(GetNetEntity(uid), warp.Location ?? Name(uid), true);
var newWarp = new GhostWarpPlace(GetNetEntity(uid),
warp.Location ?? Name(uid),
warp.Location ?? Description(uid));
warps.Add(newWarp);
}
return warps;
}
private IEnumerable<GhostWarp> GetPlayerWarps(EntityUid except)
private List<GhostWarpPlayer> GetPlayerWarps()
{
foreach (var player in _playerManager.Sessions)
var warps = new List<GhostWarpPlayer> { };
foreach (var mindContainer in EntityQuery<MindContainerComponent>())
{
if (player.AttachedEntity is not {Valid: true} attached)
var entity = mindContainer.Owner;
if (!(HasComp<HumanoidAppearanceComponent>(entity) || HasComp<GhostComponent>(entity)) ||
HasComp<GlobalAntagonistComponent>(entity))
continue;
if (attached == except) continue;
var playerDepartmentId = _prototypeManager.Index<DepartmentPrototype>("Specific").ID;
var playerJobName = "Неизвестно";
TryComp<MindContainerComponent>(attached, out var mind);
if (_jobs.MindTryGetJob(mindContainer.Mind ?? mindContainer.LastMindStored,
out _,
out var jobPrototype))
{
playerJobName = Loc.GetString(jobPrototype.Name);
var jobName = _jobs.MindTryGetJobName(mind?.Mind);
var playerInfo = $"{Comp<MetaDataComponent>(attached).EntityName} ({jobName})";
if (_jobs.TryGetDepartment(jobPrototype.ID, out var departmentPrototype))
{
playerDepartmentId = departmentPrototype.ID;
}
}
if (_mobState.IsAlive(attached) || _mobState.IsCritical(attached))
yield return new GhostWarp(GetNetEntity(attached), playerInfo, false);
var hasAnyMind = (mindContainer.Mind ?? mindContainer.LastMindStored) != null;
var isDead = _mobState.IsDead(entity);
var isLeft = TryComp<SSDIndicatorComponent>(entity, out var indicator) && indicator.IsSSD && !isDead &&
hasAnyMind;
var warp = new GhostWarpPlayer(
GetNetEntity(entity),
Comp<MetaDataComponent>(entity).EntityName,
playerJobName,
playerDepartmentId,
HasComp<GhostComponent>(entity),
isLeft,
isDead,
_mobState.IsAlive(entity)
);
warps.Add(warp);
}
return warps;
}
private List<GhostWarpGlobalAntagonist> GetAntagonistWarps()
{
var warps = new List<GhostWarpGlobalAntagonist> { };
foreach (var antagonist in EntityQuery<GlobalAntagonistComponent>())
{
var entity = antagonist.Owner;
var prototype =
_prototypeManager.Index<AntagonistPrototype>(antagonist.AntagonistPrototype ??
"globalAntagonistUnknown");
var warp = new GhostWarpGlobalAntagonist(
GetNetEntity(entity),
Comp<MetaDataComponent>(entity).EntityName,
prototype.Name,
prototype.Description,
prototype.ID
);
warps.Add(warp);
}
return warps;
}
#endregion
private void OnEntityStorageInsertAttempt(EntityUid uid, GhostComponent comp, ref InsertIntoEntityStorageAttemptEvent args)
private void OnEntityStorageInsertAttempt(EntityUid uid,
GhostComponent comp,
ref InsertIntoEntityStorageAttemptEvent args)
{
args.Cancelled = true;
}
@@ -433,6 +552,7 @@ namespace Content.Server.Ghost
_visibilitySystem.AddLayer(uid, vis, (int) VisibilityFlags.Ghost, false);
_visibilitySystem.RemoveLayer(uid, vis, (int) VisibilityFlags.Normal, false);
}
_visibilitySystem.RefreshVisibility(uid, visibilityComponent: vis);
}
}
@@ -444,5 +564,62 @@ 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;
}
}
}

View File

@@ -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)

View File

@@ -20,6 +20,7 @@ using Robust.Shared.Audio;
using Robust.Shared.Player;
using System.Diagnostics.CodeAnalysis;
using Content.Server.Objectives.Components;
using Content.Shared._White.Antag;
using Robust.Shared.Audio.Systems;
namespace Content.Server.Ninja.Systems;
@@ -155,6 +156,8 @@ public sealed class SpaceNinjaSystem : SharedSpaceNinjaSystem
if (config == null)
return;
EnsureComp<GlobalAntagonistComponent>(uid).AntagonistPrototype = "globalAntagonistNinja";
var role = new NinjaRoleComponent
{
PrototypeId = "SpaceNinja"

View File

@@ -3,6 +3,7 @@ using Robust.Server.Maps;
using Content.Server.GameTicking.Rules.Components;
using Content.Server.StationEvents.Components;
using Content.Server.RoundEnd;
using Content.Shared._White.Antag;
namespace Content.Server.StationEvents.Events;
@@ -32,6 +33,9 @@ public sealed class LoneOpsSpawnRule : StationEventSystem<LoneOpsSpawnRuleCompon
var nukeopsEntity = GameTicker.AddGameRule(component.GameRuleProto);
component.AdditionalRule = nukeopsEntity;
var nukeopsComp = Comp<NukeopsRuleComponent>(nukeopsEntity);
EnsureComp<GlobalAntagonistComponent>(nukeopsEntity).AntagonistPrototype = "globalAntagonistLoneops";
nukeopsComp.SpawnOutpost = false;
nukeopsComp.RoundEndBehavior = RoundEndBehavior.Nothing;
GameTicker.StartGameRule(nukeopsEntity);

View File

@@ -15,6 +15,7 @@ using Content.Server.NPC.Systems;
using Content.Server.Roles;
using Content.Server.Speech.Components;
using Content.Server.Temperature.Components;
using Content.Shared._White.Antag;
using Content.Shared.CombatMode;
using Content.Shared.CombatMode.Pacification;
using Content.Shared.Damage;
@@ -96,6 +97,7 @@ namespace Content.Server.Zombies
//you're a real zombie now, son.
var zombiecomp = AddComp<ZombieComponent>(target);
EnsureComp<GlobalAntagonistComponent>(target).AntagonistPrototype = "globalAntagonistZombie";
//we need to basically remove all of these because zombies shouldn't
//get diseases, breath, be thirst, be hungry, die in space, have offspring or be paraplegic.

View File

@@ -23,6 +23,7 @@ using Robust.Shared.Configuration;
using Robust.Shared.Player;
using Robust.Shared.Random;
using Content.Shared._White;
using Content.Shared._White.Antag;
using Content.Shared._White.Cult.Components;
using Content.Shared._White.Cult.Systems;
using Content.Shared._White.Mood;
@@ -353,6 +354,7 @@ public sealed class CultRuleSystem : GameRuleSystem<CultRuleComponent>
return;
EnsureComp<PentagramComponent>(cultistComponent.Owner);
EnsureComp<GlobalAntagonistComponent>(cultistComponent.Owner).AntagonistPrototype = "globalAntagonistCult";
}
}

View File

@@ -24,6 +24,7 @@ using System.Linq;
using Content.Server.Objectives;
using Content.Server.Station.Components;
using Content.Server.StationEvents.Components;
using Content.Shared._White.Antag;
using Content.Shared.Mind;
using Content.Shared.NPC.Components;
using Content.Shared.Objectives.Components;
@@ -285,6 +286,7 @@ public sealed class WizardRuleSystem : GameRuleSystem<WizardRuleComponent>
bool endRoundOnDeath)
{
EnsureComp<WizardComponent>(mob).EndRoundOnDeath = endRoundOnDeath;
EnsureComp<GlobalAntagonistComponent>(mob).AntagonistPrototype = "globalAntagonistWizard";
profile ??= HumanoidCharacterProfile.RandomWithSpecies();

View File

@@ -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

View File

@@ -1,8 +1,10 @@
using Content.Shared._White.Antag;
using Content.Shared.Emoting;
using Content.Shared.Hands;
using Content.Shared.Interaction.Events;
using Content.Shared.Item;
using Content.Shared.Popups;
using Content.Shared.Roles;
using Robust.Shared.Serialization;
namespace Content.Shared.Ghost
@@ -62,18 +64,122 @@ namespace Content.Shared.Ghost
{
}
/// <summary>
/// An player body a ghost can warp to.
/// This is used as part of <see cref="GhostWarpsResponseEvent"/>
/// </summary>
[Serializable, NetSerializable]
public struct GhostWarpPlayer
{
public GhostWarpPlayer(NetEntity entity, string playerName, string playerJobName, string playerDepartmentID, bool isGhost, bool isLeft, bool isDead, bool isAlive)
{
Entity = entity;
Name = playerName;
JobName = playerJobName;
DepartmentID = playerDepartmentID;
IsGhost = isGhost;
IsLeft = isLeft;
IsDead = isDead;
IsAlive = isAlive;
}
/// <summary>
/// The entity representing the warp point.
/// This is passed back to the server in <see cref="GhostWarpToTargetRequestEvent"/>
/// </summary>
public NetEntity Entity { get; }
/// <summary>
/// The display player name to be surfaced in the ghost warps menu
/// </summary>
public string Name { get; }
/// <summary>
/// The display player job to be surfaced in the ghost warps menu
/// </summary>
public string JobName { get; }
/// <summary>
/// The display player department to be surfaced in the ghost warps menu
/// </summary>
public string DepartmentID { get; set; }
/// <summary>
/// Is player is ghost
/// </summary>
public bool IsGhost { get; }
/// <summary>
/// Is player body alive
/// </summary>
public bool IsAlive { get; }
/// <summary>
/// Is player body dead
/// </summary>
public bool IsDead { get; }
/// <summary>
/// Is player left from body
/// </summary>
public bool IsLeft { get; }
}
[Serializable, NetSerializable]
public struct GhostWarpGlobalAntagonist
{
public GhostWarpGlobalAntagonist(NetEntity entity, string playerName, string antagonistName, string antagonistDescription, string prototypeID)
{
Entity = entity;
Name = playerName;
AntagonistName = antagonistName;
AntagonistDescription = antagonistDescription;
PrototypeID = prototypeID;
}
/// <summary>
/// The entity representing the warp point.
/// This is passed back to the server in <see cref="GhostWarpToTargetRequestEvent"/>
/// </summary>
public NetEntity Entity { get; }
/// <summary>
/// The display player name to be surfaced in the ghost warps menu
/// </summary>
public string Name { get; }
/// <summary>
/// The display antagonist name to be surfaced in the ghost warps menu
/// </summary>
public string AntagonistName { get; }
/// <summary>
/// The display antagonist description to be surfaced in the ghost warps menu
/// </summary>
public string AntagonistDescription { get; }
/// <summary>
/// A antagonist prototype id
/// </summary>
public string PrototypeID { get; }
}
/// <summary>
/// An individual place a ghost can warp to.
/// This is used as part of <see cref="GhostWarpsResponseEvent"/>
/// </summary>
[Serializable, NetSerializable]
public struct GhostWarp
public struct GhostWarpPlace
{
public GhostWarp(NetEntity entity, string displayName, bool isWarpPoint)
public GhostWarpPlace(NetEntity entity, string name, string description)
{
Entity = entity;
DisplayName = displayName;
IsWarpPoint = isWarpPoint;
Name = name;
Description = description;
}
/// <summary>
@@ -85,14 +191,14 @@ namespace Content.Shared.Ghost
/// <summary>
/// The display name to be surfaced in the ghost warps menu
/// </summary>
public string DisplayName { get; }
public string Name { get; }
/// <summary>
/// Whether this warp represents a warp point or a player
/// The display name to be surfaced in the ghost warps menu
/// </summary>
public bool IsWarpPoint { get; }
}
public string Description { get; }
}
/// <summary>
/// A server to client response for a <see cref="GhostWarpsRequestEvent"/>.
/// Contains players, and locations a ghost can warp to
@@ -100,15 +206,27 @@ namespace Content.Shared.Ghost
[Serializable, NetSerializable]
public sealed class GhostWarpsResponseEvent : EntityEventArgs
{
public GhostWarpsResponseEvent(List<GhostWarp> warps)
public GhostWarpsResponseEvent(List<GhostWarpPlayer> players, List<GhostWarpPlace> places, List<GhostWarpGlobalAntagonist> antagonists)
{
Warps = warps;
Players = players;
Places = places;
Antagonists = antagonists;
}
/// <summary>
/// A list of players to teleport.
/// </summary>
public List<GhostWarpPlayer> Players { get; }
/// <summary>
/// A list of warp points.
/// </summary>
public List<GhostWarp> Warps { get; }
public List<GhostWarpPlace> Places { get; }
/// <summary>
/// A list of antagonists to teleport.
/// </summary>
public List<GhostWarpGlobalAntagonist> Antagonists { get; }
}
/// <summary>
@@ -125,6 +243,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>
@@ -153,3 +277,4 @@ namespace Content.Shared.Ghost
{
}
}

View File

@@ -17,6 +17,10 @@ namespace Content.Shared.Mind.Components
[Access(typeof(SharedMindSystem), Other = AccessPermissions.ReadWriteExecute)] // FIXME Friends
public EntityUid? Mind { get; set; }
[DataField, AutoNetworkedField]
[Access(typeof(SharedMindSystem), Other = AccessPermissions.ReadWriteExecute)]
public EntityUid? LastMindStored { get; set; }
/// <summary>
/// True if we have a mind, false otherwise.
/// </summary>
@@ -59,6 +63,7 @@ namespace Content.Shared.Mind.Components
public MindRemovedMessage(Entity<MindComponent> mind, Entity<MindContainerComponent> container)
: base(mind, container)
{
container.Comp.LastMindStored = mind; // Holy shit
}
}

View File

@@ -8,20 +8,25 @@ public sealed partial class DepartmentPrototype : IPrototype
{
[IdDataField] public string ID { get; } = default!;
/// <summary>
/// A name string.
/// </summary>
[DataField(required: true)]
public string Name = default!;
/// <summary>
/// A description string to display in the character menu as an explanation of the department's function.
/// </summary>
[DataField("description", required: true)]
[DataField (required: true)]
public string Description = default!;
/// <summary>
/// A color representing this department to use for text.
/// </summary>
[DataField("color", required: true)]
[DataField(required: true)]
public Color Color = default!;
[ViewVariables(VVAccess.ReadWrite),
DataField("roles", customTypeSerializer: typeof(PrototypeIdListSerializer<JobPrototype>))]
[ViewVariables(VVAccess.ReadWrite), DataField(customTypeSerializer: typeof(PrototypeIdListSerializer<JobPrototype>))]
public List<string> Roles = new();
/// <summary>
@@ -34,8 +39,14 @@ public sealed partial class DepartmentPrototype : IPrototype
/// <summary>
/// Departments with a higher weight sorted before other departments in UI.
/// </summary>
[DataField("weight")]
[DataField]
public int Weight { get; private set; } = 0;
/// <summary>
/// A style string references to style in StyleNano.cs
/// </summary>
[DataField]
public string ButtonStyle = default!;
}
/// <summary>

View File

@@ -0,0 +1,29 @@
using Robust.Shared.Prototypes;
namespace Content.Shared._White.Antag;
[Prototype("antagonist")]
public sealed partial class AntagonistPrototype : IPrototype
{
[IdDataField] public string ID { get; } = default!;
/// <summary>
/// A name string to display in ghost teleport menu .
/// </summary>
[DataField(required: true)]
public string Name = default!;
/// <summary>
/// A description string to display in the character menu as an explanation of the department's function.
/// </summary>
[DataField(required: true)]
public string Description = default!;
/// <summary>
/// A description string to display in the character menu as an explanation of the department's function.
/// </summary>
[DataField(required: true)]
public int Weight = default!;
}

View File

@@ -0,0 +1,11 @@
using Robust.Shared.GameStates;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Shared._White.Antag;
[RegisterComponent, NetworkedComponent]
public sealed partial class GlobalAntagonistComponent : Component
{
[DataField(required: true, customTypeSerializer: typeof(PrototypeIdSerializer<AntagonistPrototype>))]
public string? AntagonistPrototype;
}

View File

@@ -4876,3 +4876,60 @@
id: 324
time: '2024-06-22T12:55:50.0000000+00:00'
url: https://api.github.com/repos/frosty-dev/ss14-core/pulls/376
- author: Aviu
changes:
- message: "\u0422\u0435\u043F\u0435\u0440\u044C \u043C\u043E\u0436\u043D\u043E\
\ \u0441\u0433\u043E\u0440\u0435\u0442\u044C \u0434\u043E \u0442\u043B\u0430\
."
type: Add
- message: "\u0422\u0435\u043F\u0435\u0440\u044C \u043F\u0440\u0438 \u0443\u0434\
\u0430\u043B\u0435\u043D\u0438\u0438 \u0442\u0435\u043B\u0430 \u043F\u0440\u0438\
\u0437\u0440\u0430\u043A \u043A\u043E\u0440\u0440\u0435\u043A\u0442\u043D\u043E\
\ \u0441\u043F\u0430\u0432\u043D\u0438\u0442\u0441\u044F."
type: Fix
id: 325
time: '2024-06-25T21:39:44.0000000+00:00'
url: https://api.github.com/repos/frosty-dev/ss14-core/pulls/382
- author: ThereDrD
changes:
- message: "\u0418\u043D\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0442\u0435\u043B\
\u0435\u043F\u043E\u0440\u0442\u0430 \u043F\u0440\u0438\u0437\u0440\u0430\u043A\
\u0430 \u043F\u0435\u0440\u0435\u0440\u0430\u0431\u043E\u0442\u0430\u043D \u043F\
\u043E\u0434 \u0441\u0442\u0438\u043B\u044C \u0441\u044113 \u0438 \u0441\u0442\
\u0430\u043B \u0431\u043E\u043B\u0435\u0435 \u0431\u043E\u043B\u0435\u0435 \u0443\
\u0434\u043E\u0431\u043D\u044B\u0439. \u0422\u0435\u043F\u0435\u0440\u044C \u044D\
\u0442\u043E \u043C\u043E\u0436\u043D\u043E \u0441\u0447\u0438\u0442\u0430\u0442\
\u044C \u043F\u043E\u043B\u043D\u043E\u0446\u0435\u043D\u043D\u044B\u043C \u043E\
\u0431\u0437\u043E\u0440\u043E\u043C \u0441\u043E\u0441\u0442\u043E\u044F\u043D\
\u0438\u044F \u0440\u0430\u0443\u043D\u0434\u0430."
type: Add
- message: "\u0414\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u0430 \u0421\u043E\u0440\
\u0442\u0438\u0440\u043E\u0432\u043A\u0430 \u043F\u0435\u0440\u0441\u043E\u043D\
\u0430\u0436\u0435\u0439 \u0438 \u0438\u0433\u0440\u043E\u043A\u043E\u0432 \u043F\
\u043E \u0434\u0435\u043F\u0430\u0440\u0442\u0430\u043C\u0435\u043D\u0442\u0430\
\u043C\u0438 \u0438 \u043F\u043E\u0434\u0441\u043A\u0430\u0437\u043A\u0430 \u0441\
\ \u0434\u043E\u043B\u0436\u043D\u043E\u0441\u0442\u044C\u044E \u043F\u0435\u0440\
\u0441\u043E\u043D\u0430\u0436\u0430 \u043F\u0440\u0438 \u043D\u0430\u0432\u0435\
\u0434\u0435\u043D\u0438\u0438 \u043C\u044B\u0448\u043A\u0438 \u043D\u0430 \u0438\
\u043C\u044F."
type: Add
- message: "\u0412 \u043C\u0435\u043D\u044E \u0442\u0435\u043B\u0435\u043F\u043E\
\u0440\u0442\u0430 \u0433\u043E\u0441\u0442\u043E\u0432 \u0442\u0435\u043F\u0435\
\u0440\u044C \u0432\u044B\u0434\u0435\u043B\u044F\u044E\u0442\u0441\u044F \u0433\
\u043B\u043E\u0431\u0430\u043B\u044C\u043D\u044B\u0435 \u0430\u043D\u0442\u0430\
\u0433\u043E\u043D\u0438\u0441\u0442\u044B, \u043D\u0430\u043F\u0440\u0438\u043C\
\u0435\u0440 \u041D\u044E\u043A\u0435\u0440\u044B, \u043F\u0430\u0443\u043A\u0438\
\ \u0438\u043B\u0438 \u041A\u0443\u043B\u044C\u0442, \u043A\u043E\u0433\u0434\
\u0430 \u043F\u043E\u043B\u0443\u0447\u0438\u0442 \u043D\u0438\u043C\u0431\u044B\
."
type: Add
- message: "\u041F\u043E\u0438\u0441\u043A \u0443\u0434\u0430\u043B\u0435\u043D\
\ \u0438\u0437 \u043C\u0435\u043D\u044E \u0442\u0435\u043B\u0435\u043F\u043E\
\u0440\u0442\u0430 \u0432 \u0432\u0438\u0434\u0443 \u043D\u0435\u0432\u0435\u0440\
\u043E\u044F\u0442\u043D\u043E\u0439 \u0437\u0430\u0431\u0430\u0433\u043E\u0432\
\u0430\u043D\u043D\u043E\u0441\u0442\u0438 \u0438\u0437-\u0437\u0430 \u043A\u043E\
\u0434\u0430 \u0434\u0432\u0438\u0436\u043A\u0430."
type: Remove
id: 326
time: '2024-06-26T02:13:42.0000000+00:00'
url: https://api.github.com/repos/frosty-dev/ss14-core/pulls/378

View File

@@ -0,0 +1 @@
bodyburn-text-others = {$name} burns to ash!

View File

@@ -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

View File

@@ -0,0 +1,34 @@
global-antagonist-wizard-name = Волшебник
global-antagonist-wizard-description = Старый сумашедший из Федерации Магов, обученный смертельным заклинаниям
global-antagonist-nukeops-name = Ядерный оперативник
global-antagonist-nukeops-description = Элитный наемник Синдиката
global-antagonist-loneops-name = Одинокий оперативник
global-antagonist-loneops-description = Элитный наемник Синдиката, один против всей станции
global-antagonist-cult-name = Кровавый культист
global-antagonist-cult-description = Демонопоклонники, использующие магию крови
global-antagonist-ninja-name = Ниндзя
global-antagonist-ninja-description = Напичканный высокими технологиями элитный боец
global-antagonist-zombie-name = Зомби
global-antagonist-zombie-description = Восставший из мертвых под действием вируса
global-antagonist-dragon-name = Космический дракон
global-antagonist-dragon-description = Дракон! Я видела дракона!!
global-antagonist-revenant-name = Мстительный дух
global-antagonist-revenant-description = Призрачное существо питающееся жизненной силой
global-antagonist-slime-name = Слизень
global-antagonist-slime-description = Голодный сгусток чего-то одновременно твердого и жидкого
global-antagonist-spider-name = Гигансткий паук
global-antagonist-spider-description = Соразмерный с человеком агрессивный паук
global-antagonist-spider-clown-name = Гигантский хонк-паук
global-antagonist-spider-clown-description = Соразмерный с человеком агрессивный клоун-паук. ХОНК!
global-antagonist-rats-name = Гигантская крыса
global-antagonist-rats-description = Вечноголодная и агрессивная крыса
global-antagonist-unknown-name = Неизвестно
global-antagonist-unknown-description = Подозрительно!!
ghost-teleport-menu-antagonists-label = Антагонисты
ghost-teleport-menu-alive-label = Живые
ghost-teleport-menu-dead-label = Мертвые
ghost-teleport-menu-ghosts-label = Призраки
ghost-teleport-menu-left-label = Вышедшие из тела
ghost-teleport-menu-locations-label = Локации и объекты
ghost-teleport-menu-count-label = Количество

View File

@@ -5,6 +5,6 @@ department-Engineering = Инженерный отдел
department-Medical = Медицинский отдел
department-Security = Служба безопасности
department-Science = Научный отдел
department-Specific = Особые для станции
department-Specific = Другие
department-Silicon = Киборги
department-Justice = Отдел юстиции

View File

@@ -2225,6 +2225,8 @@
name: ghost-role-information-giant-spider-name
description: ghost-role-information-giant-spider-description
- type: GhostTakeoverAvailable
- type: GlobalAntagonist
antagonistPrototype: globalAntagonistSpider
- type: entity
name: angry monkey
@@ -2285,6 +2287,8 @@
- type: Bloodstream
bloodMaxVolume: 150
bloodReagent: Laughter
- type: GlobalAntagonist
antagonistPrototype: globalAntagonistSpiderClown
- type: entity
name: possum

View File

@@ -121,6 +121,8 @@
- type: NightVision
toggleSound: null
color: "#404040"
- type: GlobalAntagonist
antagonistPrototype: globalAntagonistRats
- type: entity
id: MobRatKingBuff
@@ -198,7 +200,6 @@
- map: [ "enum.DamageStateVisualLayers.BaseUnshaded"]
state: eyes
shader: unshaded
- type: SpriteMovement
movementLayers:
movement:
@@ -291,6 +292,8 @@
- type: FireVisuals
sprite: Mobs/Effects/onfire.rsi
normalState: Mouse_burning
- type: GlobalAntagonist
antagonistPrototype: globalAntagonistRats
- type: weightedRandomEntity
id: RatKingLoot

View File

@@ -93,3 +93,5 @@
- RevenantTheme
- type: Speech
speechVerb: Ghost
- type: GlobalAntagonist
antagonistPrototype: globalAntagonistRevenant

View File

@@ -148,6 +148,8 @@
- SimpleHostile
- type: GhostRole
description: ghost-role-information-angry-slimes-description
- type: GlobalAntagonist
antagonistPrototype: globalAntagonistSlime
- type: entity
name: green slime
@@ -183,6 +185,8 @@
- SimpleHostile
- type: GhostRole
description: ghost-role-information-angry-slimes-description
- type: GlobalAntagonist
antagonistPrototype: globalAntagonistSlime
- type: entity
name: yellow slime
@@ -218,3 +222,5 @@
- SimpleHostile
- type: GhostRole
description: ghost-role-information-angry-slimes-description
- type: GlobalAntagonist
antagonistPrototype: globalAntagonistSlime

View File

@@ -154,6 +154,8 @@
- type: GuideHelp
guides:
- MinorAntagonists
- type: GlobalAntagonist
antagonistPrototype: globalAntagonistDragon
- type: entity
parent: BaseMobDragon

View File

@@ -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

View File

@@ -1,7 +1,9 @@
- type: department
id: Command
name: department-Command
description: department-Command-description
color: "#334E6D"
weight: 200
roles:
- CentralCommandOfficial
- Captain
@@ -13,13 +15,14 @@
- Quartermaster
- Inspector
primary: false
weight: 100
buttonStyle: ButtonColorCommandDepartment
- type: department
id: Security
name: department-Security
description: department-Security-description
color: "#DE3A3A"
weight: 20
weight: 180
roles:
- HeadOfSecurity
- Warden
@@ -27,21 +30,80 @@
- SecurityOfficer
- Detective
- SecurityCadet
buttonStyle: ButtonColorSecurityDepartment
- type: department
id: Justice
name: department-Justice
description: department-Justice-description
weight: 160
color: "#710d00"
roles:
- Inspector
- Lawyer
buttonStyle: ButtonColorJusticeDepartment
- type: department
id: Medical
name: department-Medical
description: department-Medical-description
color: "#52B4E9"
weight: 140
roles:
- ChiefMedicalOfficer
- SeniorPhysician
- MedicalDoctor
- Paramedic
- Chemist
- MedicalIntern
- Psychologist
buttonStyle: ButtonColorMedicalDepartment
- type: department
id: Engineering
name: department-Engineering
description: department-Engineering-description
color: "#EFB341"
weight: 120
roles:
- ChiefEngineer
- SeniorEngineer
- AtmosphericTechnician
- StationEngineer
- TechnicalAssistant
buttonStyle: ButtonColorEngineeringDepartment
- type: department
id: Science
name: department-Science
description: department-Science-description
color: "#D381C9"
weight: 100
roles:
- ResearchDirector
- SeniorResearcher
- Scientist
- ResearchAssistant
buttonStyle: ButtonColorScienceDepartment
- type: department
id: Cargo
name: department-Cargo
description: department-Cargo-description
color: "#A46106"
weight: 80
roles:
- Quartermaster
- CargoTechnician
- SalvageSpecialist
buttonStyle: ButtonColorCargoDepartment
- type: department
id: Civilian
name: department-Civilian
description: department-Civilian-description
color: "#9FED58"
weight: -10
weight: 60
roles:
- HeadOfPersonnel
- Borg
@@ -60,57 +122,18 @@
- Visitor
- Zookeeper
- Passenger
- type: department
id: Engineering
description: department-Engineering-description
color: "#EFB341"
roles:
- ChiefEngineer
- SeniorEngineer
- AtmosphericTechnician
- StationEngineer
- TechnicalAssistant
- type: department
id: Medical
description: department-Medical-description
color: "#52B4E9"
roles:
- ChiefMedicalOfficer
- SeniorPhysician
- MedicalDoctor
- Paramedic
- Chemist
- MedicalIntern
- Psychologist
- type: department
id: Science
description: department-Science-description
color: "#D381C9"
roles:
- ResearchDirector
- SeniorResearcher
- Scientist
- ResearchAssistant
buttonStyle: ButtonColorCivilianDepartment
- type: department
id: Specific
name: department-Specific
description: department-Specific-description
color: "#9FED58"
weight: 10
weight: 0
roles:
- Boxer
- Reporter
- Zookeeper
- Psychologist
primary: false
- type: department
id: Justice
description: department-Justice-description
color: "#710d00"
roles:
- Inspector
- Lawyer
buttonStyle: ButtonColorSpecificDepartment

View File

@@ -0,0 +1,77 @@
- type: antagonist
id: globalAntagonistWizard
name: global-antagonist-wizard-name
description: global-antagonist-wizard-description
weight: 0
- type: antagonist
id: globalAntagonistNukeops
name: global-antagonist-nukeops-name
description: global-antagonist-nukeops-description
weight: 1
- type: antagonist
id: globalAntagonistLoneops
name: global-antagonist-loneops-name
description: global-antagonist-loneops-description
weight: 2
- type: antagonist
id: globalAntagonistCult
name: global-antagonist-cult-name
description: global-antagonist-cult-description
weight: 3
- type: antagonist
id: globalAntagonistNinja
name: global-antagonist-ninja-name
description: global-antagonist-ninja-description
weight: 4
- type: antagonist
id: globalAntagonistZombie
name: global-antagonist-zombie-name
description: global-antagonist-zombie-description
weight: 5
- type: antagonist
id: globalAntagonistDragon
name: global-antagonist-dragon-name
description: global-antagonist-dragon-description
weight: 6
- type: antagonist
id: globalAntagonistRevenant
name: global-antagonist-revenant-name
description: global-antagonist-revenant-description
weight: 7
- type: antagonist
id: globalAntagonistSlime
name: global-antagonist-slime-name
description: global-antagonist-slime-description
weight: 8
- type: antagonist
id: globalAntagonistSpider
name: global-antagonist-spider-name
description: global-antagonist-spider-description
weight: 9
- type: antagonist
id: globalAntagonistSpiderClown
name: global-antagonist-spider-clown-name
description: global-antagonist-spider-clown-description
weight: 10
- type: antagonist
id: globalAntagonistRats
name: global-antagonist-rats-name
description: global-antagonist-rats-description
weight: 11
- type: antagonist
id: globalAntagonistUnknown
name: global-antagonist-unknown-name
description: global-antagonist-unknown-description
weight: 12