2020-02-24 03:49:40 +01:00
|
|
|
using Content.Server.GameObjects.Components.Mobs;
|
2020-04-17 19:28:08 +02:00
|
|
|
using Content.Server.GameObjects.Components.Observer;
|
2020-02-24 03:49:40 +01:00
|
|
|
using Content.Server.Players;
|
2020-08-13 14:40:27 +02:00
|
|
|
using Content.Shared.GameObjects.Verbs;
|
2020-02-24 03:49:40 +01:00
|
|
|
using Robust.Server.Console;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Server.GameObjects;
|
|
|
|
|
using Robust.Shared.GameObjects;
|
2020-02-24 03:49:40 +01:00
|
|
|
using Robust.Shared.IoC;
|
2020-08-29 13:36:02 +02:00
|
|
|
using Robust.Shared.Localization;
|
2020-02-24 03:49:40 +01:00
|
|
|
|
|
|
|
|
namespace Content.Server.GlobalVerbs
|
|
|
|
|
{
|
|
|
|
|
[GlobalVerb]
|
|
|
|
|
public class ControlMobVerb : GlobalVerb
|
|
|
|
|
{
|
|
|
|
|
public override bool RequireInteractionRange => false;
|
2020-08-15 20:42:39 +02:00
|
|
|
public override bool BlockedByContainers => false;
|
2020-02-24 03:49:40 +01:00
|
|
|
|
2020-05-23 03:09:44 +02:00
|
|
|
public override void GetData(IEntity user, IEntity target, VerbData data)
|
2020-02-24 03:49:40 +01:00
|
|
|
{
|
2020-05-23 03:09:44 +02:00
|
|
|
data.Visibility = VerbVisibility.Invisible;
|
|
|
|
|
|
2020-02-24 03:49:40 +01:00
|
|
|
var groupController = IoCManager.Resolve<IConGroupController>();
|
2020-05-23 03:09:44 +02:00
|
|
|
if (user == target)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-02-24 03:49:40 +01:00
|
|
|
|
|
|
|
|
if (user.TryGetComponent<IActorComponent>(out var player))
|
|
|
|
|
{
|
|
|
|
|
if (!user.HasComponent<MindComponent>() || !target.HasComponent<MindComponent>())
|
2020-05-23 03:09:44 +02:00
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-02-24 03:49:40 +01:00
|
|
|
|
|
|
|
|
if (groupController.CanCommand(player.playerSession, "controlmob"))
|
2020-05-23 03:09:44 +02:00
|
|
|
{
|
|
|
|
|
data.Visibility = VerbVisibility.Visible;
|
2020-08-29 13:36:02 +02:00
|
|
|
data.Text = Loc.GetString("Control Mob");
|
2020-05-23 03:09:44 +02:00
|
|
|
data.CategoryData = VerbCategories.Debug;
|
|
|
|
|
}
|
2020-02-24 03:49:40 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Activate(IEntity user, IEntity target)
|
|
|
|
|
{
|
2020-05-23 03:09:44 +02:00
|
|
|
var groupController = IoCManager.Resolve<IConGroupController>();
|
|
|
|
|
|
|
|
|
|
var player = user.GetComponent<IActorComponent>().playerSession;
|
|
|
|
|
if (!groupController.CanCommand(player, "controlmob"))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var userMind = player.ContentData().Mind;
|
|
|
|
|
|
2020-02-24 03:49:40 +01:00
|
|
|
var targetMind = target.GetComponent<MindComponent>();
|
2020-04-17 19:28:08 +02:00
|
|
|
var oldEntity = userMind.CurrentEntity;
|
2020-02-24 03:49:40 +01:00
|
|
|
|
|
|
|
|
targetMind.Mind?.TransferTo(null);
|
|
|
|
|
userMind.TransferTo(target);
|
2020-04-17 19:28:08 +02:00
|
|
|
|
2020-05-23 03:09:44 +02:00
|
|
|
if (oldEntity.HasComponent<GhostComponent>())
|
2020-04-17 19:28:08 +02:00
|
|
|
oldEntity.Delete();
|
2020-02-24 03:49:40 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|