using Content.Server.Mind.Commands; using Content.Server.Mind.Components; using Robust.Server.Player; namespace Content.Server.Ghost.Roles.Components { /// /// Allows a ghost to take over the Owner entity. /// [RegisterComponent, ComponentReference(typeof(GhostRoleComponent))] public sealed class GhostTakeoverAvailableComponent : GhostRoleComponent { public override bool Take(IPlayerSession session) { if (Taken) return false; Taken = true; var mind = Owner.EnsureComponent(); if (mind.HasMind) return false; if (MakeSentient) MakeSentientCommand.MakeSentient(Owner, IoCManager.Resolve(), AllowMovement, AllowSpeech); var ghostRoleSystem = EntitySystem.Get(); ghostRoleSystem.GhostRoleInternalCreateMindAndTransfer(session, Owner, Owner, this); ghostRoleSystem.UnregisterGhostRole(this); return true; } } }