Files
crystall-punk-14/Content.Server/Ghost/Roles/Components/GhostTakeoverAvailableComponent.cs

39 lines
1.1 KiB
C#
Raw Normal View History

using Content.Server.Mind.Commands;
2021-06-09 22:19:39 +02:00
using Content.Server.Mind.Components;
2021-02-12 10:45:22 +01:00
using Robust.Server.Player;
using Robust.Shared.GameObjects;
2021-12-03 11:11:52 +01:00
using Robust.Shared.IoC;
2021-06-09 22:19:39 +02:00
namespace Content.Server.Ghost.Roles.Components
{
/// <summary>
/// Allows a ghost to take over the Owner entity.
/// </summary>
[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<MindComponent>();
if (mind.HasMind)
return false;
if (MakeSentient)
2021-12-07 21:54:00 +11:00
MakeSentientCommand.MakeSentient(Owner, IoCManager.Resolve<IEntityManager>());
var ghostRoleSystem = EntitySystem.Get<GhostRoleSystem>();
2021-12-07 21:54:00 +11:00
ghostRoleSystem.GhostRoleInternalCreateMindAndTransfer(session, Owner, Owner, this);
ghostRoleSystem.UnregisterGhostRole(this);
return true;
}
}
}