2021-12-03 20:31:14 +11:00
|
|
|
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;
|
2021-02-12 04:35:56 +01:00
|
|
|
using Robust.Shared.GameObjects;
|
2021-12-03 11:11:52 +01:00
|
|
|
using Robust.Shared.IoC;
|
2021-02-12 04:35:56 +01:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.Ghost.Roles.Components
|
2021-02-12 04:35:56 +01:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Allows a ghost to take over the Owner entity.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[RegisterComponent, ComponentReference(typeof(GhostRoleComponent))]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class GhostTakeoverAvailableComponent : GhostRoleComponent
|
2021-02-12 04:35:56 +01:00
|
|
|
{
|
|
|
|
|
public override bool Take(IPlayerSession session)
|
|
|
|
|
{
|
|
|
|
|
if (Taken)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
Taken = true;
|
|
|
|
|
|
|
|
|
|
var mind = Owner.EnsureComponent<MindComponent>();
|
|
|
|
|
|
2021-03-16 15:50:20 +01:00
|
|
|
if (mind.HasMind)
|
2021-10-23 10:56:37 +02:00
|
|
|
return false;
|
2021-02-12 04:35:56 +01:00
|
|
|
|
2021-12-03 20:31:14 +11:00
|
|
|
if (MakeSentient)
|
2021-12-07 21:54:00 +11:00
|
|
|
MakeSentientCommand.MakeSentient(Owner, IoCManager.Resolve<IEntityManager>());
|
2021-12-03 20:31:14 +11:00
|
|
|
|
2021-11-15 18:14:34 +00:00
|
|
|
var ghostRoleSystem = EntitySystem.Get<GhostRoleSystem>();
|
2021-12-07 21:54:00 +11:00
|
|
|
ghostRoleSystem.GhostRoleInternalCreateMindAndTransfer(session, Owner, Owner, this);
|
2021-03-16 15:50:20 +01:00
|
|
|
|
2021-11-15 18:14:34 +00:00
|
|
|
ghostRoleSystem.UnregisterGhostRole(this);
|
2021-02-12 04:35:56 +01:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|