-using System.Globalization;
-using System.Linq;
using Content.Server.Chat.Managers;
+using Content.Server.Chat.Systems;
using Content.Server.GameTicking;
+using Content.Server.Ghost;
using Content.Server.Hands.Systems;
using Content.Server.Inventory;
using Content.Server.Popups;
-using Content.Server.Chat.Systems;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;
using Content.Server.StationRecords;
using Content.Server.StationRecords.Systems;
-using Content.Shared.StationRecords;
-using Content.Shared.UserInterface;
using Content.Shared.Access.Systems;
using Content.Shared.Bed.Cryostorage;
using Content.Shared.Chat;
using Content.Shared.Database;
using Content.Shared.Hands.Components;
using Content.Shared.Mind.Components;
+using Content.Shared.StationRecords;
+using Content.Shared.UserInterface;
using Robust.Server.Audio;
using Robust.Server.Containers;
using Robust.Server.GameObjects;
using Robust.Shared.Enums;
using Robust.Shared.Network;
using Robust.Shared.Player;
+using System.Globalization;
namespace Content.Server.Bed.Cryostorage;
[Dependency] private readonly ChatSystem _chatSystem = default!;
[Dependency] private readonly ClimbSystem _climb = default!;
[Dependency] private readonly ContainerSystem _container = default!;
- [Dependency] private readonly GameTicker _gameTicker = default!;
+ [Dependency] private readonly GhostSystem _ghostSystem = default!;
[Dependency] private readonly HandsSystem _hands = default!;
[Dependency] private readonly ServerInventorySystem _inventory = default!;
[Dependency] private readonly PopupSystem _popup = default!;
if (userId != null && Mind.TryGetMind(userId.Value, out var mind) &&
HasComp<CryostorageContainedComponent>(mind.Value.Comp.CurrentEntity))
{
- _gameTicker.OnGhostAttempt(mind.Value, false);
+ _ghostSystem.OnGhostAttempt(mind.Value, false);
}
}
using Content.Server.Body.Components;
-using Content.Server.GameTicking;
+using Content.Server.Ghost;
using Content.Server.Humanoid;
using Content.Shared.Body.Components;
using Content.Shared.Body.Part;
public sealed class BodySystem : SharedBodySystem
{
- [Dependency] private readonly GameTicker _ticker = default!;
+ [Dependency] private readonly GhostSystem _ghostSystem = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly HumanoidAppearanceSystem _humanoidSystem = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
if (_mobState.IsDead(ent) && _mindSystem.TryGetMind(ent, out var mindId, out var mind))
{
mind.TimeOfDeath ??= _gameTiming.RealTime;
- _ticker.OnGhostAttempt(mindId, canReturnGlobal: true, mind: mind);
+ _ghostSystem.OnGhostAttempt(mindId, canReturnGlobal: true, mind: mind);
}
}
-using Content.Server.GameTicking;
+using Content.Server.Ghost;
+using Content.Shared.Administration.Logs;
+using Content.Shared.Chat;
using Content.Shared.Damage;
using Content.Shared.Database;
using Content.Shared.Hands.Components;
using Content.Shared.Interaction.Events;
using Content.Shared.Item;
using Content.Shared.Mind;
+using Content.Shared.Mind.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Popups;
using Content.Shared.Tag;
using Robust.Shared.Player;
-using Content.Shared.Administration.Logs;
-using Content.Shared.Chat;
-using Content.Shared.Mind.Components;
namespace Content.Server.Chat;
[Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
- [Dependency] private readonly GameTicker _gameTicker = default!;
+ [Dependency] private readonly GhostSystem _ghostSystem = default!;
[Dependency] private readonly SharedSuicideSystem _suicide = default!;
public override void Initialize()
if (_tagSystem.HasTag(victim, "CannotSuicide"))
args.CanReturnToBody = true;
- if (_gameTicker.OnGhostAttempt(victim.Comp.Mind.Value, args.CanReturnToBody, mind: mindComponent))
+ if (_ghostSystem.OnGhostAttempt(victim.Comp.Mind.Value, args.CanReturnToBody, mind: mindComponent))
args.Handled = true;
}
using Content.Server.Administration.Logs;
-using Content.Server.GameTicking;
+using Content.Server.Ghost;
using Content.Server.Mind;
using Content.Server.NPC;
using Content.Server.NPC.HTN;
public sealed class CursedMaskSystem : SharedCursedMaskSystem
{
[Dependency] private readonly IAdminLogManager _adminLog = default!;
- [Dependency] private readonly GameTicker _ticker = default!;
+ [Dependency] private readonly GhostSystem _ghostSystem = default!;
[Dependency] private readonly HTNSystem _htn = default!;
[Dependency] private readonly MindSystem _mind = default!;
[Dependency] private readonly NPCSystem _npc = default!;
if (TryComp<ActorComponent>(wearer, out var actor) && actor.PlayerSession.GetMind() is { } mind)
{
var session = actor.PlayerSession;
- if (!_ticker.OnGhostAttempt(mind, false))
+ if (!_ghostSystem.OnGhostAttempt(mind, false))
return;
ent.Comp.StolenMind = mind;
-using System.Diagnostics.CodeAnalysis;
-using System.Linq;
-using System.Threading.Tasks;
using Content.Server.GameTicking.Presets;
using Content.Server.Maps;
using Content.Shared.CCVar;
-using Content.Shared.Damage;
-using Content.Shared.Damage.Prototypes;
-using Content.Shared.Database;
-using Content.Shared.FixedPoint;
-using Content.Shared.Ghost;
-using Content.Shared.Mind;
-using Content.Shared.Mobs;
-using Content.Shared.Mobs.Components;
-using Content.Shared.Mobs.Systems;
using JetBrains.Annotations;
using Robust.Shared.Player;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using System.Threading.Tasks;
namespace Content.Server.GameTicking
{
public sealed partial class GameTicker
{
- [Dependency] private readonly MobThresholdSystem _mobThresholdSystem = default!;
-
public const float PresetFailedCooldownIncrease = 30f;
/// <summary>
}
}
- public bool OnGhostAttempt(EntityUid mindId, bool canReturnGlobal, bool viaCommand = false, MindComponent? mind = null)
- {
- if (!Resolve(mindId, ref mind))
- return false;
-
- var playerEntity = mind.CurrentEntity;
-
- if (playerEntity != null && viaCommand)
- _adminLogger.Add(LogType.Mind, $"{EntityManager.ToPrettyString(playerEntity.Value):player} is attempting to ghost via command");
-
- var handleEv = new GhostAttemptHandleEvent(mind, canReturnGlobal);
- RaiseLocalEvent(handleEv);
-
- // Something else has handled the ghost attempt for us! We return its result.
- if (handleEv.Handled)
- return handleEv.Result;
-
- if (mind.PreventGhosting)
- {
- if (mind.Session != null) // Logging is suppressed to prevent spam from ghost attempts caused by movement attempts
- {
- _chatManager.DispatchServerMessage(mind.Session, Loc.GetString("comp-mind-ghosting-prevented"),
- true);
- }
-
- return false;
- }
-
- if (TryComp<GhostComponent>(playerEntity, out var comp) && !comp.CanGhostInteract)
- return false;
-
- if (mind.VisitingEntity != default)
- {
- _mind.UnVisit(mindId, mind: mind);
- }
-
- var position = Exists(playerEntity)
- ? Transform(playerEntity.Value).Coordinates
- : GetObserverSpawnPoint();
-
- if (position == default)
- return false;
-
- // Ok, so, this is the master place for the logic for if ghosting is "too cheaty" to allow returning.
- // There's no reason at this time to move it to any other place, especially given that the 'side effects required' situations would also have to be moved.
- // + If CharacterDeadPhysically applies, we're physically dead. Therefore, ghosting OK, and we can return (this is critical for gibbing)
- // Note that we could theoretically be ICly dead and still physically alive and vice versa.
- // (For example, a zombie could be dead ICly, but may retain memories and is definitely physically active)
- // + If we're in a mob that is critical, and we're supposed to be able to return if possible,
- // we're succumbing - the mob is killed. Therefore, character is dead. Ghosting OK.
- // (If the mob survives, that's a bug. Ghosting is kept regardless.)
- var canReturn = canReturnGlobal && _mind.IsCharacterDeadPhysically(mind);
-
- if (_configurationManager.GetCVar(CCVars.GhostKillCrit) &&
- canReturnGlobal &&
- TryComp(playerEntity, out MobStateComponent? mobState))
- {
- if (_mobState.IsCritical(playerEntity.Value, mobState))
- {
- canReturn = true;
-
- //todo: what if they dont breathe lol
- //cry deeply
-
- FixedPoint2 dealtDamage = 200;
- if (TryComp<DamageableComponent>(playerEntity, out var damageable)
- && TryComp<MobThresholdsComponent>(playerEntity, out var thresholds))
- {
- var playerDeadThreshold = _mobThresholdSystem.GetThresholdForState(playerEntity.Value, MobState.Dead, thresholds);
- dealtDamage = playerDeadThreshold - damageable.TotalDamage;
- }
-
- DamageSpecifier damage = new(_prototypeManager.Index<DamageTypePrototype>("Asphyxiation"), dealtDamage);
-
- _damageable.TryChangeDamage(playerEntity, damage, true);
- }
- }
-
- 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)" : "")}");
-
- return true;
- }
-
private void IncrementRoundNumber()
{
var playerIds = _playerGameStatuses.Keys.Select(player => player.UserId).ToArray();
RoundId = task.GetAwaiter().GetResult();
}
}
-
- public sealed class GhostAttemptHandleEvent : HandledEntityEventArgs
- {
- public MindComponent Mind { get; }
- public bool CanReturnGlobal { get; }
- public bool Result { get; set; }
-
- public GhostAttemptHandleEvent(MindComponent mind, bool canReturnGlobal)
- {
- Mind = mind;
- CanReturnGlobal = canReturnGlobal;
- }
- }
}
-using Content.Server.GameTicking;
using Content.Server.Popups;
using Content.Shared.Administration;
using Content.Shared.Mind;
mind = _entities.GetComponent<MindComponent>(mindId);
}
- if (!_entities.System<GameTicker>().OnGhostAttempt(mindId, true, true, mind))
+ if (!_entities.System<GhostSystem>().OnGhostAttempt(mindId, true, true, mind))
{
shell.WriteLine(Loc.GetString("ghost-command-denied"));
}
-using System.Linq;
-using System.Numerics;
+using Content.Server.Administration.Logs;
+using Content.Server.Chat.Managers;
using Content.Server.GameTicking;
using Content.Server.Ghost.Components;
using Content.Server.Mind;
using Content.Server.Roles.Jobs;
using Content.Server.Warps;
using Content.Shared.Actions;
+using Content.Shared.CCVar;
+using Content.Shared.Damage;
+using Content.Shared.Damage.Prototypes;
+using Content.Shared.Database;
using Content.Shared.Examine;
using Content.Shared.Eye;
+using Content.Shared.FixedPoint;
using Content.Shared.Follower;
using Content.Shared.Ghost;
using Content.Shared.Mind;
using Content.Shared.Mind.Components;
+using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Movement.Events;
using Content.Shared.Storage.Components;
using Robust.Server.GameObjects;
using Robust.Server.Player;
+using Robust.Shared.Configuration;
using Robust.Shared.Map;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Player;
+using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
+using System.Linq;
+using System.Numerics;
namespace Content.Server.Ghost
{
[Dependency] private readonly TransformSystem _transformSystem = default!;
[Dependency] private readonly VisibilitySystem _visibilitySystem = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!;
+ [Dependency] private readonly MobThresholdSystem _mobThresholdSystem = default!;
+ [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
+ [Dependency] private readonly IAdminLogManager _adminLogger = default!;
+ [Dependency] private readonly IConfigurationManager _configurationManager = default!;
+ [Dependency] private readonly IChatManager _chatManager = default!;
+ [Dependency] private readonly SharedMindSystem _mind = default!;
+ [Dependency] private readonly GameTicker _gameTicker = default!;
+ [Dependency] private readonly DamageableSystem _damageable = default!;
private EntityQuery<GhostComponent> _ghostQuery;
private EntityQuery<PhysicsComponent> _physicsQuery;
if (component.MustBeDead && (_mobState.IsAlive(uid) || _mobState.IsCritical(uid)))
return;
- _ticker.OnGhostAttempt(mindId, component.CanReturn, mind: mind);
+ OnGhostAttempt(mindId, component.CanReturn, mind: mind);
}
private void OnGhostStartup(EntityUid uid, GhostComponent component, ComponentStartup args)
Log.Debug($"Spawned ghost \"{ToPrettyString(ghost)}\" for {mind.Comp.CharacterName}.");
return ghost;
}
+
+ public bool OnGhostAttempt(EntityUid mindId, bool canReturnGlobal, bool viaCommand = false, MindComponent? mind = null)
+ {
+ if (!Resolve(mindId, ref mind))
+ return false;
+
+ var playerEntity = mind.CurrentEntity;
+
+ if (playerEntity != null && viaCommand)
+ _adminLogger.Add(LogType.Mind, $"{EntityManager.ToPrettyString(playerEntity.Value):player} is attempting to ghost via command");
+
+ var handleEv = new GhostAttemptHandleEvent(mind, canReturnGlobal);
+ RaiseLocalEvent(handleEv);
+
+ // Something else has handled the ghost attempt for us! We return its result.
+ if (handleEv.Handled)
+ return handleEv.Result;
+
+ if (mind.PreventGhosting)
+ {
+ if (mind.Session != null) // Logging is suppressed to prevent spam from ghost attempts caused by movement attempts
+ {
+ _chatManager.DispatchServerMessage(mind.Session, Loc.GetString("comp-mind-ghosting-prevented"),
+ true);
+ }
+
+ return false;
+ }
+
+ if (TryComp<GhostComponent>(playerEntity, out var comp) && !comp.CanGhostInteract)
+ return false;
+
+ if (mind.VisitingEntity != default)
+ {
+ _mind.UnVisit(mindId, mind: mind);
+ }
+
+ var position = Exists(playerEntity)
+ ? Transform(playerEntity.Value).Coordinates
+ : _gameTicker.GetObserverSpawnPoint();
+
+ if (position == default)
+ return false;
+
+ // Ok, so, this is the master place for the logic for if ghosting is "too cheaty" to allow returning.
+ // There's no reason at this time to move it to any other place, especially given that the 'side effects required' situations would also have to be moved.
+ // + If CharacterDeadPhysically applies, we're physically dead. Therefore, ghosting OK, and we can return (this is critical for gibbing)
+ // Note that we could theoretically be ICly dead and still physically alive and vice versa.
+ // (For example, a zombie could be dead ICly, but may retain memories and is definitely physically active)
+ // + If we're in a mob that is critical, and we're supposed to be able to return if possible,
+ // we're succumbing - the mob is killed. Therefore, character is dead. Ghosting OK.
+ // (If the mob survives, that's a bug. Ghosting is kept regardless.)
+ var canReturn = canReturnGlobal && _mind.IsCharacterDeadPhysically(mind);
+
+ if (_configurationManager.GetCVar(CCVars.GhostKillCrit) &&
+ canReturnGlobal &&
+ TryComp(playerEntity, out MobStateComponent? mobState))
+ {
+ if (_mobState.IsCritical(playerEntity.Value, mobState))
+ {
+ canReturn = true;
+
+ //todo: what if they dont breathe lol
+ //cry deeply
+
+ FixedPoint2 dealtDamage = 200;
+
+ if (TryComp<DamageableComponent>(playerEntity, out var damageable)
+ && TryComp<MobThresholdsComponent>(playerEntity, out var thresholds))
+ {
+ var playerDeadThreshold = _mobThresholdSystem.GetThresholdForState(playerEntity.Value, MobState.Dead, thresholds);
+ dealtDamage = playerDeadThreshold - damageable.TotalDamage;
+ }
+
+ DamageSpecifier damage = new(_prototypeManager.Index<DamageTypePrototype>("Asphyxiation"), dealtDamage);
+
+ _damageable.TryChangeDamage(playerEntity, damage, true);
+ }
+ }
+
+ var 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)" : "")}");
+
+ return true;
+ }
+ }
+
+ public sealed class GhostAttemptHandleEvent(MindComponent mind, bool canReturnGlobal) : HandledEntityEventArgs
+ {
+ public MindComponent Mind { get; } = mind;
+ public bool CanReturnGlobal { get; } = canReturnGlobal;
+ public bool Result { get; set; }
}
}
-using Content.Server.Chemistry.Containers.EntitySystems;
+using Content.Server.Administration.Logs;
using Content.Server.Fluids.EntitySystems;
-using Content.Server.GameTicking;
+using Content.Server.Ghost;
using Content.Server.Popups;
-using Content.Server.Power.Components;
+using Content.Server.Repairable;
using Content.Server.Stack;
using Content.Server.Wires;
using Content.Shared.Body.Systems;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Components.SolutionManager;
using Content.Shared.Chemistry.EntitySystems;
+using Content.Shared.Database;
+using Content.Shared.Destructible;
+using Content.Shared.Emag.Components;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Materials;
using Content.Shared.Mind;
using Content.Shared.Nutrition.EntitySystems;
+using Content.Shared.Power;
using Robust.Server.GameObjects;
using Robust.Shared.Player;
+using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using System.Linq;
-using Content.Server.Administration.Logs;
-using Content.Server.Repairable;
-using Content.Shared.Database;
-using Content.Shared.Destructible;
-using Content.Shared.Emag.Components;
-using Content.Shared.Power;
-using Robust.Shared.Prototypes;
namespace Content.Server.Materials;
{
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly AppearanceSystem _appearance = default!;
- [Dependency] private readonly GameTicker _ticker = default!;
+ [Dependency] private readonly GhostSystem _ghostSystem = default!;
[Dependency] private readonly MaterialStorageSystem _materialStorage = default!;
[Dependency] private readonly OpenableSystem _openable = default!;
[Dependency] private readonly PopupSystem _popup = default!;
if (TryComp(victim, out ActorComponent? actor) &&
_mind.TryGetMind(actor.PlayerSession, out var mindId, out var mind))
{
- _ticker.OnGhostAttempt(mindId, false, mind: mind);
+ _ghostSystem.OnGhostAttempt(mindId, false, mind: mind);
if (mind.OwnedEntity is { Valid: true } suicider)
{
_popup.PopupEntity(Loc.GetString("recycler-component-suicide-message"), suicider);
-using System.Diagnostics.CodeAnalysis;
using Content.Server.Administration.Logs;
using Content.Server.GameTicking;
using Content.Server.Ghost;
using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Utility;
+using System.Diagnostics.CodeAnalysis;
namespace Content.Server.Mind;
component = EnsureComp<MindContainerComponent>(entity.Value);
if (component.HasMind)
- _gameTicker.OnGhostAttempt(component.Mind.Value, false);
+ _ghosts.OnGhostAttempt(component.Mind.Value, false);
if (TryComp<ActorComponent>(entity.Value, out var actor))
{
-using Content.Server.GameTicking;
+using Content.Server.Ghost;
using Content.Server.Morgue.Components;
using Content.Server.Storage.Components;
using Content.Server.Storage.EntitySystems;
using Content.Shared.Storage;
using Content.Shared.Storage.Components;
using Content.Shared.Verbs;
-using Robust.Server.GameObjects;
-using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers;
using Robust.Shared.Player;
{
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
- [Dependency] private readonly GameTicker _ticker = default!;
+ [Dependency] private readonly GhostSystem _ghostSystem = default!;
[Dependency] private readonly EntityStorageSystem _entityStorage = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly StandingStateSystem _standing = default!;
var victim = args.Victim;
if (TryComp(victim, out ActorComponent? actor) && _minds.TryGetMind(victim, out var mindId, out var mind))
{
- _ticker.OnGhostAttempt(mindId, false, mind: mind);
+ _ghostSystem.OnGhostAttempt(mindId, false, mind: mind);
if (mind.OwnedEntity is { Valid: true } entity)
{