Remove ghost compref (#19478)

This commit is contained in:
metalgearsloth
2023-08-25 18:50:46 +10:00
committed by GitHub
parent 7c4564adcc
commit 0b542098db
33 changed files with 191 additions and 211 deletions

View File

@@ -1,50 +0,0 @@
using Content.Shared.Actions;
using Content.Shared.Actions.ActionTypes;
using Content.Shared.Ghost;
using Robust.Shared.Utility;
namespace Content.Client.Ghost
{
[RegisterComponent]
[ComponentReference(typeof(SharedGhostComponent))]
public sealed partial class GhostComponent : SharedGhostComponent
{
public bool IsAttached { get; set; }
public InstantAction ToggleLightingAction = new()
{
Icon = new SpriteSpecifier.Texture(new ("Interface/VerbIcons/light.svg.192dpi.png")),
DisplayName = "ghost-gui-toggle-lighting-manager-name",
Description = "ghost-gui-toggle-lighting-manager-desc",
ClientExclusive = true,
CheckCanInteract = false,
Event = new ToggleLightingActionEvent(),
};
public InstantAction ToggleFoVAction = new()
{
Icon = new SpriteSpecifier.Texture(new ("Interface/VerbIcons/vv.svg.192dpi.png")),
DisplayName = "ghost-gui-toggle-fov-name",
Description = "ghost-gui-toggle-fov-desc",
ClientExclusive = true,
CheckCanInteract = false,
Event = new ToggleFoVActionEvent(),
};
public InstantAction ToggleGhostsAction = new()
{
Icon = new SpriteSpecifier.Rsi(new ("Mobs/Ghosts/ghost_human.rsi"), "icon"),
DisplayName = "ghost-gui-toggle-ghost-visibility-name",
Description = "ghost-gui-toggle-ghost-visibility-desc",
ClientExclusive = true,
CheckCanInteract = false,
Event = new ToggleGhostsActionEvent(),
};
}
public sealed partial class ToggleLightingActionEvent : InstantActionEvent { };
public sealed partial class ToggleFoVActionEvent : InstantActionEvent { };
public sealed partial class ToggleGhostsActionEvent : InstantActionEvent { };
}

View File

@@ -11,7 +11,6 @@ using Robust.Shared.GameStates;
namespace Content.Client.Ghost namespace Content.Client.Ghost
{ {
[UsedImplicitly]
public sealed class GhostSystem : SharedGhostSystem public sealed class GhostSystem : SharedGhostSystem
{ {
[Dependency] private readonly IClientConsoleHost _console = default!; [Dependency] private readonly IClientConsoleHost _console = default!;
@@ -60,7 +59,7 @@ namespace Content.Client.Ghost
SubscribeLocalEvent<GhostComponent, ComponentInit>(OnGhostInit); SubscribeLocalEvent<GhostComponent, ComponentInit>(OnGhostInit);
SubscribeLocalEvent<GhostComponent, ComponentRemove>(OnGhostRemove); SubscribeLocalEvent<GhostComponent, ComponentRemove>(OnGhostRemove);
SubscribeLocalEvent<GhostComponent, ComponentHandleState>(OnGhostState); SubscribeLocalEvent<GhostComponent, AfterAutoHandleStateEvent>(OnGhostState);
SubscribeLocalEvent<GhostComponent, PlayerAttachedEvent>(OnGhostPlayerAttach); SubscribeLocalEvent<GhostComponent, PlayerAttachedEvent>(OnGhostPlayerAttach);
SubscribeLocalEvent<GhostComponent, PlayerDetachedEvent>(OnGhostPlayerDetach); SubscribeLocalEvent<GhostComponent, PlayerDetachedEvent>(OnGhostPlayerDetach);
@@ -77,7 +76,7 @@ namespace Content.Client.Ghost
private void OnGhostInit(EntityUid uid, GhostComponent component, ComponentInit args) private void OnGhostInit(EntityUid uid, GhostComponent component, ComponentInit args)
{ {
if (TryComp(component.Owner, out SpriteComponent? sprite)) if (TryComp(uid, out SpriteComponent? sprite))
{ {
sprite.Visible = GhostVisibility; sprite.Visible = GhostVisibility;
} }
@@ -146,7 +145,7 @@ namespace Content.Client.Ghost
PlayerAttached?.Invoke(component); PlayerAttached?.Invoke(component);
} }
private void OnGhostState(EntityUid uid, GhostComponent component, ref ComponentHandleState args) private void OnGhostState(EntityUid uid, GhostComponent component, ref AfterAutoHandleStateEvent args)
{ {
if (TryComp<SpriteComponent>(uid, out var sprite)) if (TryComp<SpriteComponent>(uid, out var sprite))
sprite.LayerSetColor(0, component.color); sprite.LayerSetColor(0, component.color);

View File

@@ -1,10 +1,10 @@
#nullable enable #nullable enable
using System.Linq; using System.Linq;
using Content.Server.Ghost.Components;
using Content.Server.Ghost.Roles; using Content.Server.Ghost.Roles;
using Content.Server.Ghost.Roles.Components; using Content.Server.Ghost.Roles.Components;
using Content.Server.Mind; using Content.Server.Mind;
using Content.Server.Players; using Content.Server.Players;
using Content.Shared.Ghost;
using Robust.Shared.Console; using Robust.Shared.Console;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Map; using Robust.Shared.Map;

View File

@@ -1,7 +1,7 @@
using System.Linq; using System.Linq;
using Content.Server.Ghost.Components;
using Content.Server.Mind; using Content.Server.Mind;
using Content.Server.Players; using Content.Server.Players;
using Content.Shared.Ghost;
using Robust.Server.Console; using Robust.Server.Console;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Server.Player; using Robust.Server.Player;

View File

@@ -1,8 +1,8 @@
using System.Linq; using System.Linq;
using Content.IntegrationTests.Pair; using Content.IntegrationTests.Pair;
using Content.Server.Ghost.Components;
using Content.Server.Mind; using Content.Server.Mind;
using Content.Server.Players; using Content.Server.Players;
using Content.Shared.Ghost;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.Enums; using Robust.Shared.Enums;

View File

@@ -1,6 +1,6 @@
using System.Linq; using System.Linq;
using Content.Server.Ghost.Components;
using Content.Server.Mind; using Content.Server.Mind;
using Content.Shared.Ghost;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Map; using Robust.Shared.Map;

View File

@@ -1,5 +1,4 @@
using Content.Server.GameTicking; using Content.Server.GameTicking;
using Content.Server.Ghost.Components;
using Content.Server.Mind; using Content.Server.Mind;
using Content.Server.Players; using Content.Server.Players;
using Content.Shared.Administration; using Content.Shared.Administration;

View File

@@ -1,9 +1,9 @@
using System.Linq; using System.Linq;
using System.Numerics; using System.Numerics;
using Content.Server.Ghost.Components;
using Content.Server.Warps; using Content.Server.Warps;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Follower; using Content.Shared.Follower;
using Content.Shared.Ghost;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.Console; using Robust.Shared.Console;
using Robust.Shared.Enums; using Robust.Shared.Enums;

View File

@@ -5,7 +5,6 @@ using Content.Server.Administration.Logs;
using Content.Server.Administration.Managers; using Content.Server.Administration.Managers;
using Content.Server.Chat.Managers; using Content.Server.Chat.Managers;
using Content.Server.GameTicking; using Content.Server.GameTicking;
using Content.Server.Ghost.Components;
using Content.Server.Players; using Content.Server.Players;
using Content.Server.Station.Components; using Content.Server.Station.Components;
using Content.Server.Station.Systems; using Content.Server.Station.Systems;
@@ -13,6 +12,7 @@ using Content.Shared.ActionBlocker;
using Content.Shared.CCVar; using Content.Shared.CCVar;
using Content.Shared.Chat; using Content.Shared.Chat;
using Content.Shared.Database; using Content.Shared.Database;
using Content.Shared.Ghost;
using Content.Shared.IdentityManagement; using Content.Shared.IdentityManagement;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Inventory; using Content.Shared.Inventory;

View File

@@ -1,6 +1,5 @@
using Content.Server.Body.Systems; using Content.Server.Body.Systems;
using Content.Server.Drone.Components; using Content.Server.Drone.Components;
using Content.Server.Ghost.Components;
using Content.Server.Ghost.Roles.Components; using Content.Server.Ghost.Roles.Components;
using Content.Server.Mind.Components; using Content.Server.Mind.Components;
using Content.Server.Popups; using Content.Server.Popups;
@@ -10,6 +9,7 @@ using Content.Shared.Body.Components;
using Content.Shared.Drone; using Content.Shared.Drone;
using Content.Shared.Emoting; using Content.Shared.Emoting;
using Content.Shared.Examine; using Content.Shared.Examine;
using Content.Shared.Ghost;
using Content.Shared.IdentityManagement; using Content.Shared.IdentityManagement;
using Content.Shared.Interaction.Components; using Content.Shared.Interaction.Components;
using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Events;

View File

@@ -1,9 +1,9 @@
using Content.Server.DeviceNetwork.Components; using Content.Server.DeviceNetwork.Components;
using Content.Server.EUI; using Content.Server.EUI;
using Content.Server.Ghost.Components;
using Content.Shared.Eui; using Content.Shared.Eui;
using Content.Shared.Fax; using Content.Shared.Fax;
using Content.Shared.Follower; using Content.Shared.Follower;
using Content.Shared.Ghost;
using Content.Shared.Paper; using Content.Shared.Paper;
namespace Content.Server.Fax.AdminUI; namespace Content.Server.Fax.AdminUI;

View File

@@ -2,12 +2,12 @@ using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Content.Server.GameTicking.Presets; using Content.Server.GameTicking.Presets;
using Content.Server.Ghost.Components;
using Content.Server.Maps; using Content.Server.Maps;
using Content.Shared.CCVar; using Content.Shared.CCVar;
using Content.Shared.Damage; using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes; using Content.Shared.Damage.Prototypes;
using Content.Shared.Database; using Content.Shared.Database;
using Content.Shared.Ghost;
using Content.Shared.Mobs.Components; using Content.Shared.Mobs.Components;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.Player; using Robust.Server.Player;
@@ -273,13 +273,13 @@ namespace Content.Server.GameTicking
if (mind.TimeOfDeath.HasValue) if (mind.TimeOfDeath.HasValue)
{ {
ghostComponent.TimeOfDeath = mind.TimeOfDeath!.Value; _ghost.SetTimeOfDeath(ghost, mind.TimeOfDeath!.Value, ghostComponent);
} }
if (playerEntity != null) if (playerEntity != null)
_adminLogger.Add(LogType.Mind, $"{EntityManager.ToPrettyString(playerEntity.Value):player} ghosted{(!canReturn ? " (non-returnable)" : "")}"); _adminLogger.Add(LogType.Mind, $"{EntityManager.ToPrettyString(playerEntity.Value):player} ghosted{(!canReturn ? " (non-returnable)" : "")}");
_ghosts.SetCanReturnToBody(ghostComponent, canReturn); _ghost.SetCanReturnToBody(ghostComponent, canReturn);
if (canReturn) if (canReturn)
_mind.Visit(mind, ghost); _mind.Visit(mind, ghost);

View File

@@ -34,14 +34,38 @@ namespace Content.Server.GameTicking
{ {
public sealed partial class GameTicker : SharedGameTicker public sealed partial class GameTicker : SharedGameTicker
{ {
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly IBanManager _banManager = default!;
[Dependency] private readonly IBaseServer _baseServer = default!;
[Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
[Dependency] private readonly IConsoleHost _consoleHost = default!;
[Dependency] private readonly IGameMapManager _gameMapManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly ILogManager _logManager = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;
#if EXCEPTION_TOLERANCE
[Dependency] private readonly IRuntimeLog _runtimeLog = default!;
#endif
[Dependency] private readonly IServerPreferencesManager _prefsManager = default!;
[Dependency] private readonly IServerDbManager _db = default!;
[Dependency] private readonly ArrivalsSystem _arrivals = default!; [Dependency] private readonly ArrivalsSystem _arrivals = default!;
[Dependency] private readonly ChatSystem _chatSystem = default!;
[Dependency] private readonly DamageableSystem _damageable = default!;
[Dependency] private readonly MapLoaderSystem _map = default!; [Dependency] private readonly MapLoaderSystem _map = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly GhostSystem _ghost = default!; [Dependency] private readonly GhostSystem _ghost = default!;
[Dependency] private readonly MindSystem _mind = default!; [Dependency] private readonly MindSystem _mind = default!;
[Dependency] private readonly MindTrackerSystem _mindTracker = default!; [Dependency] private readonly MindTrackerSystem _mindTracker = default!;
[Dependency] private readonly MobStateSystem _mobState = default!; [Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly PlayTimeTrackingSystem _playTimeTrackings = default!;
[Dependency] private readonly PvsOverrideSystem _pvsOverride = default!; [Dependency] private readonly PvsOverrideSystem _pvsOverride = default!;
[Dependency] private readonly ServerUpdateManager _serverUpdates = default!;
[Dependency] private readonly StationJobsSystem _stationJobs = default!;
[Dependency] private readonly StationSpawningSystem _stationSpawning = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly UserDbDataManager _userDb = default!;
[ViewVariables] private bool _initialized; [ViewVariables] private bool _initialized;
[ViewVariables] private bool _postInitialized; [ViewVariables] private bool _postInitialized;
@@ -106,31 +130,5 @@ namespace Content.Server.GameTicking
base.Update(frameTime); base.Update(frameTime);
UpdateRoundFlow(frameTime); UpdateRoundFlow(frameTime);
} }
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
[Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private readonly IServerPreferencesManager _prefsManager = default!;
[Dependency] private readonly IBaseServer _baseServer = default!;
[Dependency] private readonly IGameMapManager _gameMapManager = default!;
[Dependency] private readonly IServerDbManager _db = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly ILogManager _logManager = default!;
[Dependency] private readonly IConsoleHost _consoleHost = default!;
#if EXCEPTION_TOLERANCE
[Dependency] private readonly IRuntimeLog _runtimeLog = default!;
#endif
[Dependency] private readonly StationSpawningSystem _stationSpawning = default!;
[Dependency] private readonly StationJobsSystem _stationJobs = default!;
[Dependency] private readonly DamageableSystem _damageable = default!;
[Dependency] private readonly GhostSystem _ghosts = default!;
[Dependency] private readonly IBanManager _banManager = default!;
[Dependency] private readonly ChatSystem _chatSystem = default!;
[Dependency] private readonly ServerUpdateManager _serverUpdates = default!;
[Dependency] private readonly PlayTimeTrackingSystem _playTimeTrackings = default!;
[Dependency] private readonly UserDbDataManager _userDb = default!;
} }
} }

View File

@@ -1,33 +0,0 @@
using Content.Shared.Actions;
using Content.Shared.Actions.ActionTypes;
using Content.Shared.Ghost;
using Robust.Shared.Utility;
namespace Content.Server.Ghost.Components
{
[RegisterComponent]
[ComponentReference(typeof(SharedGhostComponent))]
public sealed partial class GhostComponent : SharedGhostComponent
{
public TimeSpan TimeOfDeath { get; set; } = TimeSpan.Zero;
[DataField("booRadius")]
public float BooRadius = 3;
[DataField("booMaxTargets")]
public int BooMaxTargets = 3;
[DataField("action")]
public InstantAction Action = new()
{
UseDelay = TimeSpan.FromSeconds(120),
Icon = new SpriteSpecifier.Texture(new ("Interface/Actions/scream.png")),
DisplayName = "action-name-boo",
Description = "action-description-boo",
CheckCanInteract = false,
Event = new BooActionEvent(),
};
}
public sealed partial class BooActionEvent : InstantActionEvent { }
}

View File

@@ -26,8 +26,7 @@ using Robust.Shared.Timing;
namespace Content.Server.Ghost namespace Content.Server.Ghost
{ {
[UsedImplicitly] public sealed partial class GhostSystem : SharedGhostSystem
public sealed class GhostSystem : SharedGhostSystem
{ {
[Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IPlayerManager _playerManager = default!;

View File

@@ -1,6 +1,5 @@
using Content.Server.Administration.Logs; using Content.Server.Administration.Logs;
using Content.Server.EUI; using Content.Server.EUI;
using Content.Server.Ghost.Components;
using Content.Server.Ghost.Roles.Components; using Content.Server.Ghost.Roles.Components;
using Content.Server.Ghost.Roles.Events; using Content.Server.Ghost.Roles.Events;
using Content.Server.Ghost.Roles.UI; using Content.Server.Ghost.Roles.UI;

View File

@@ -3,7 +3,6 @@ using System.Linq;
using Content.Server.Administration.Logs; using Content.Server.Administration.Logs;
using Content.Server.GameTicking; using Content.Server.GameTicking;
using Content.Server.Ghost; using Content.Server.Ghost;
using Content.Server.Ghost.Components;
using Content.Server.Mind.Components; using Content.Server.Mind.Components;
using Content.Server.Objectives; using Content.Server.Objectives;
using Content.Server.Players; using Content.Server.Players;
@@ -11,6 +10,7 @@ using Content.Server.Roles;
using Content.Shared.Database; using Content.Shared.Database;
using Content.Shared.Examine; using Content.Shared.Examine;
using Content.Shared.GameTicking; using Content.Shared.GameTicking;
using Content.Shared.Ghost;
using Content.Shared.Mobs.Systems; using Content.Shared.Mobs.Systems;
using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Events;
using Content.Shared.Mobs.Components; using Content.Shared.Mobs.Components;

View File

@@ -1,11 +1,11 @@
using System.Linq; using System.Linq;
using Content.Server.Administration.Logs; using Content.Server.Administration.Logs;
using Content.Server.Ghost.Components;
using Content.Server.Players; using Content.Server.Players;
using Content.Server.Pointing.Components; using Content.Server.Pointing.Components;
using Content.Server.Visible; using Content.Server.Visible;
using Content.Shared.Bed.Sleep; using Content.Shared.Bed.Sleep;
using Content.Shared.Database; using Content.Shared.Database;
using Content.Shared.Ghost;
using Content.Shared.IdentityManagement; using Content.Shared.IdentityManagement;
using Content.Shared.Input; using Content.Shared.Input;
using Content.Shared.Interaction; using Content.Shared.Interaction;

View File

@@ -1,5 +1,4 @@
using Content.Server.Administration.Logs; using Content.Server.Administration.Logs;
using Content.Server.Ghost.Components;
using Content.Server.Mind.Components; using Content.Server.Mind.Components;
using Content.Server.Station.Components; using Content.Server.Station.Components;
using Content.Server.Singularity.Events; using Content.Server.Singularity.Events;
@@ -13,6 +12,7 @@ using Robust.Shared.Map;
using Robust.Shared.Map.Components; using Robust.Shared.Map.Components;
using Robust.Shared.Physics.Events; using Robust.Shared.Physics.Events;
using System.Numerics; using System.Numerics;
using Content.Shared.Ghost;
namespace Content.Server.Singularity.EntitySystems; namespace Content.Server.Singularity.EntitySystems;

View File

@@ -6,9 +6,8 @@ using Robust.Shared.Physics.Systems;
using Robust.Shared.Timing; using Robust.Shared.Timing;
using Content.Shared.Singularity.EntitySystems; using Content.Shared.Singularity.EntitySystems;
using Content.Server.Ghost.Components;
using Content.Server.Singularity.Components; using Content.Server.Singularity.Components;
using Content.Shared.Ghost;
namespace Content.Server.Singularity.EntitySystems; namespace Content.Server.Singularity.EntitySystems;

View File

@@ -1,6 +1,5 @@
using System.Linq; using System.Linq;
using Content.Server.Administration.Managers; using Content.Server.Administration.Managers;
using Content.Server.Ghost.Components;
using Content.Server.Interaction; using Content.Server.Interaction;
using Content.Server.Popups; using Content.Server.Popups;
using Content.Server.Stack; using Content.Server.Stack;
@@ -11,6 +10,7 @@ using Content.Shared.CombatMode;
using Content.Shared.Containers.ItemSlots; using Content.Shared.Containers.ItemSlots;
using Content.Shared.Destructible; using Content.Shared.Destructible;
using Content.Shared.DoAfter; using Content.Shared.DoAfter;
using Content.Shared.Ghost;
using Content.Shared.Hands.Components; using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems; using Content.Shared.Hands.EntitySystems;
using Content.Shared.Implants.Components; using Content.Shared.Implants.Components;

View File

@@ -1,7 +1,7 @@
using Content.Server.Ghost.Components; using Content.Server.Mind.Components;
using Content.Server.Mind.Components;
using Content.Shared.Administration.Logs; using Content.Shared.Administration.Logs;
using Content.Shared.Database; using Content.Shared.Database;
using Content.Shared.Ghost;
using Content.Shared.Teleportation.Systems; using Content.Shared.Teleportation.Systems;
using Robust.Shared.Map; using Robust.Shared.Map;

View File

@@ -1,6 +1,6 @@
using Content.Server.Administration.Managers; using Content.Server.Administration.Managers;
using Content.Server.Ghost.Components;
using Content.Shared.ActionBlocker; using Content.Shared.ActionBlocker;
using Content.Shared.Ghost;
using Content.Shared.Hands; using Content.Shared.Hands;
using Content.Shared.Hands.Components; using Content.Shared.Hands.Components;
using Content.Shared.Interaction; using Content.Shared.Interaction;

View File

@@ -1,5 +1,5 @@
using Content.Server.Ghost.Components;
using Content.Shared.Examine; using Content.Shared.Examine;
using Content.Shared.Ghost;
namespace Content.Server.Warps; namespace Content.Server.Warps;

View File

@@ -1,7 +1,7 @@
using System.Linq; using System.Linq;
using Content.Server.Ghost.Components;
using Content.Server.Mind.Components; using Content.Server.Mind.Components;
using Content.Server.Worldgen.Components; using Content.Server.Worldgen.Components;
using Content.Shared.Ghost;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Map; using Robust.Shared.Map;

View File

@@ -61,7 +61,7 @@ public sealed class FollowerSystem : EntitySystem
if (ev.User == ev.Target || ev.Target.IsClientSide()) if (ev.User == ev.Target || ev.Target.IsClientSide())
return; return;
if (HasComp<SharedGhostComponent>(ev.User)) if (HasComp<GhostComponent>(ev.User))
{ {
var verb = new AlternativeVerb() var verb = new AlternativeVerb()
{ {

View File

@@ -0,0 +1,118 @@
using Content.Shared.Actions;
using Content.Shared.Actions.ActionTypes;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
using Robust.Shared.Utility;
namespace Content.Shared.Ghost;
[RegisterComponent, NetworkedComponent, Access(typeof(SharedGhostSystem))]
[AutoGenerateComponentState]
public sealed partial class GhostComponent : Component
{
// I have no idea what this means I just wanted to kill comp references.
[ViewVariables]
public bool IsAttached;
public InstantAction ToggleLightingAction = new()
{
Icon = new SpriteSpecifier.Texture(new ("Interface/VerbIcons/light.svg.192dpi.png")),
DisplayName = "ghost-gui-toggle-lighting-manager-name",
Description = "ghost-gui-toggle-lighting-manager-desc",
ClientExclusive = true,
CheckCanInteract = false,
Event = new ToggleLightingActionEvent(),
};
public InstantAction ToggleFoVAction = new()
{
Icon = new SpriteSpecifier.Texture(new ("Interface/VerbIcons/vv.svg.192dpi.png")),
DisplayName = "ghost-gui-toggle-fov-name",
Description = "ghost-gui-toggle-fov-desc",
ClientExclusive = true,
CheckCanInteract = false,
Event = new ToggleFoVActionEvent(),
};
public InstantAction ToggleGhostsAction = new()
{
Icon = new SpriteSpecifier.Rsi(new ("Mobs/Ghosts/ghost_human.rsi"), "icon"),
DisplayName = "ghost-gui-toggle-ghost-visibility-name",
Description = "ghost-gui-toggle-ghost-visibility-desc",
ClientExclusive = true,
CheckCanInteract = false,
Event = new ToggleGhostsActionEvent(),
};
[ViewVariables(VVAccess.ReadWrite), DataField("timeOfDeath", customTypeSerializer:typeof(TimeOffsetSerializer))]
public TimeSpan TimeOfDeath = TimeSpan.Zero;
[DataField("booRadius")]
public float BooRadius = 3;
[DataField("booMaxTargets")]
public int BooMaxTargets = 3;
[DataField("action")]
public InstantAction Action = new()
{
UseDelay = TimeSpan.FromSeconds(120),
Icon = new SpriteSpecifier.Texture(new ("Interface/Actions/scream.png")),
DisplayName = "action-name-boo",
Description = "action-description-boo",
CheckCanInteract = false,
Event = new BooActionEvent(),
};
// TODO: instead of this funny stuff just give it access and update in system dirtying when needed
[ViewVariables(VVAccess.ReadWrite)]
public bool CanGhostInteract
{
get => _canGhostInteract;
set
{
if (_canGhostInteract == value) return;
_canGhostInteract = value;
Dirty();
}
}
[DataField("canInteract"), AutoNetworkedField]
private bool _canGhostInteract;
/// <summary>
/// Changed by <see cref="SharedGhostSystem.SetCanReturnToBody"/>
/// </summary>
// TODO MIRROR change this to use friend classes when thats merged
[ViewVariables(VVAccess.ReadWrite)]
public bool CanReturnToBody
{
get => _canReturnToBody;
set
{
if (_canReturnToBody == value) return;
_canReturnToBody = value;
Dirty();
}
}
/// <summary>
/// Ghost color
/// </summary>
/// <remarks>Used to allow admins to change ghost colors. Should be removed if the capability to edit existing sprite colors is ever added back.</remarks>
[DataField("color"), AutoNetworkedField]
[ViewVariables(VVAccess.ReadWrite)]
public Color color = Color.White;
[DataField("canReturnToBody"), AutoNetworkedField]
private bool _canReturnToBody;
}
public sealed partial class BooActionEvent : InstantActionEvent { }
public sealed partial class ToggleFoVActionEvent : InstantActionEvent { };
public sealed partial class ToggleGhostsActionEvent : InstantActionEvent { };
public sealed partial class ToggleLightingActionEvent : InstantActionEvent { };

View File

@@ -1,55 +0,0 @@
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
namespace Content.Shared.Ghost
{
[NetworkedComponent]
[AutoGenerateComponentState]
public abstract partial class SharedGhostComponent : Component
{
// TODO: instead of this funny stuff just give it access and update in system dirtying when needed
[ViewVariables(VVAccess.ReadWrite)]
public bool CanGhostInteract
{
get => _canGhostInteract;
set
{
if (_canGhostInteract == value) return;
_canGhostInteract = value;
Dirty();
}
}
[DataField("canInteract"), AutoNetworkedField]
private bool _canGhostInteract;
/// <summary>
/// Changed by <see cref="SharedGhostSystem.SetCanReturnToBody"/>
/// </summary>
// TODO MIRROR change this to use friend classes when thats merged
[ViewVariables(VVAccess.ReadWrite)]
public bool CanReturnToBody
{
get => _canReturnToBody;
set
{
if (_canReturnToBody == value) return;
_canReturnToBody = value;
Dirty();
}
}
/// <summary>
/// Ghost color
/// </summary>
/// <remarks>Used to allow admins to change ghost colors. Should be removed if the capability to edit existing sprite colors is ever added back.</remarks>
[DataField("color"), AutoNetworkedField]
[ViewVariables(VVAccess.ReadWrite)]
public Color color = Color.White;
[DataField("canReturnToBody"), AutoNetworkedField]
private bool _canReturnToBody;
}
}

View File

@@ -1,4 +1,3 @@
using Content.Shared.DragDrop;
using Content.Shared.Emoting; using Content.Shared.Emoting;
using Content.Shared.Hands; using Content.Shared.Hands;
using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Events;
@@ -8,28 +7,36 @@ using Robust.Shared.Serialization;
namespace Content.Shared.Ghost namespace Content.Shared.Ghost
{ {
/// <summary> /// <summary>
/// System for the <see cref="SharedGhostComponent"/>. /// System for the <see cref="GhostComponent"/>.
/// Prevents ghosts from interacting when <see cref="SharedGhostComponent.CanGhostInteract"/> is false. /// Prevents ghosts from interacting when <see cref="GhostComponent.CanGhostInteract"/> is false.
/// </summary> /// </summary>
public abstract class SharedGhostSystem : EntitySystem public abstract class SharedGhostSystem : EntitySystem
{ {
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<SharedGhostComponent, UseAttemptEvent>(OnAttempt); SubscribeLocalEvent<GhostComponent, UseAttemptEvent>(OnAttempt);
SubscribeLocalEvent<SharedGhostComponent, InteractionAttemptEvent>(OnAttempt); SubscribeLocalEvent<GhostComponent, InteractionAttemptEvent>(OnAttempt);
SubscribeLocalEvent<SharedGhostComponent, EmoteAttemptEvent>(OnAttempt); SubscribeLocalEvent<GhostComponent, EmoteAttemptEvent>(OnAttempt);
SubscribeLocalEvent<SharedGhostComponent, DropAttemptEvent>(OnAttempt); SubscribeLocalEvent<GhostComponent, DropAttemptEvent>(OnAttempt);
SubscribeLocalEvent<SharedGhostComponent, PickupAttemptEvent>(OnAttempt); SubscribeLocalEvent<GhostComponent, PickupAttemptEvent>(OnAttempt);
} }
private void OnAttempt(EntityUid uid, SharedGhostComponent component, CancellableEntityEventArgs args) private void OnAttempt(EntityUid uid, GhostComponent component, CancellableEntityEventArgs args)
{ {
if (!component.CanGhostInteract) if (!component.CanGhostInteract)
args.Cancel(); args.Cancel();
} }
public void SetCanReturnToBody(EntityUid uid, bool value, SharedGhostComponent? component = null) public void SetTimeOfDeath(EntityUid uid, TimeSpan value, GhostComponent? component)
{
if (!Resolve(uid, ref component))
return;
component.TimeOfDeath = value;
}
public void SetCanReturnToBody(EntityUid uid, bool value, GhostComponent? component = null)
{ {
if (!Resolve(uid, ref component)) if (!Resolve(uid, ref component))
return; return;
@@ -37,7 +44,7 @@ namespace Content.Shared.Ghost
component.CanReturnToBody = value; component.CanReturnToBody = value;
} }
public void SetCanReturnToBody(SharedGhostComponent component, bool value) public void SetCanReturnToBody(GhostComponent component, bool value)
{ {
component.CanReturnToBody = value; component.CanReturnToBody = value;
} }

View File

@@ -54,7 +54,7 @@ public static class Identity
{ {
// Would check for uid == viewer here but I think it's better for you to see yourself // Would check for uid == viewer here but I think it's better for you to see yourself
// how everyone else will see you, otherwise people will probably get confused and think they aren't disguised // how everyone else will see you, otherwise people will probably get confused and think they aren't disguised
return ent.HasComponent<SharedGhostComponent>(viewer); return ent.HasComponent<GhostComponent>(viewer);
} }
} }

View File

@@ -92,7 +92,7 @@ public abstract class SharedContentEyeSystem : EntitySystem
if (args.SenderSession.AttachedEntity is not { } player) if (args.SenderSession.AttachedEntity is not { } player)
return; return;
if (!HasComp<SharedGhostComponent>(player) && !_admin.IsAdmin(player)) if (!HasComp<GhostComponent>(player) && !_admin.IsAdmin(player))
return; return;
if (TryComp<SharedEyeComponent>(player, out var eyeComp)) if (TryComp<SharedEyeComponent>(player, out var eyeComp))

View File

@@ -219,7 +219,7 @@ public abstract class SharedEventHorizonSystem : EntitySystem
// For prediction reasons always want the client to ignore these. // For prediction reasons always want the client to ignore these.
if (HasComp<MapGridComponent>(otherUid) || if (HasComp<MapGridComponent>(otherUid) ||
HasComp<SharedGhostComponent>(otherUid)) HasComp<GhostComponent>(otherUid))
{ {
args.Cancelled = true; args.Cancelled = true;
return true; return true;

View File

@@ -50,7 +50,7 @@ public abstract class SharedPortalSystem : EntitySystem
private void OnGetVerbs(EntityUid uid, PortalComponent component, GetVerbsEvent<AlternativeVerb> args) private void OnGetVerbs(EntityUid uid, PortalComponent component, GetVerbsEvent<AlternativeVerb> args)
{ {
// Traversal altverb for ghosts to use that bypasses normal functionality // Traversal altverb for ghosts to use that bypasses normal functionality
if (!args.CanAccess || !HasComp<SharedGhostComponent>(args.User)) if (!args.CanAccess || !HasComp<GhostComponent>(args.User))
return; return;
// Don't use the verb with unlinked or with multi-output portals // Don't use the verb with unlinked or with multi-output portals