From c17ef0b3c869dbcec460782b416f9c1182768fac Mon Sep 17 00:00:00 2001
From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Date: Fri, 3 Dec 2021 20:31:14 +1100
Subject: [PATCH] Allow GhostTakeoverAvailable to use MakeSentient (#5616)
---
.../Ghost/Roles/Components/GhostRoleComponent.cs | 6 ++++++
.../Roles/Components/GhostRoleMobSpawnerComponent.cs | 9 ++-------
.../Roles/Components/GhostTakeoverAvailableComponent.cs | 4 ++++
3 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/Content.Server/Ghost/Roles/Components/GhostRoleComponent.cs b/Content.Server/Ghost/Roles/Components/GhostRoleComponent.cs
index d751b60dde..0701fcc1a3 100644
--- a/Content.Server/Ghost/Roles/Components/GhostRoleComponent.cs
+++ b/Content.Server/Ghost/Roles/Components/GhostRoleComponent.cs
@@ -14,6 +14,12 @@ namespace Content.Server.Ghost.Roles.Components
[DataField("rules")] private string _roleRules = "";
+ ///
+ /// Whether the should run on the mob.
+ ///
+ [ViewVariables(VVAccess.ReadWrite)] [DataField("makeSentient")]
+ protected bool MakeSentient = true;
+
// We do this so updating RoleName and RoleDescription in VV updates the open EUIs.
[ViewVariables(VVAccess.ReadWrite)]
diff --git a/Content.Server/Ghost/Roles/Components/GhostRoleMobSpawnerComponent.cs b/Content.Server/Ghost/Roles/Components/GhostRoleMobSpawnerComponent.cs
index 0dd659db36..27dc5b82a4 100644
--- a/Content.Server/Ghost/Roles/Components/GhostRoleMobSpawnerComponent.cs
+++ b/Content.Server/Ghost/Roles/Components/GhostRoleMobSpawnerComponent.cs
@@ -22,9 +22,6 @@ namespace Content.Server.Ghost.Roles.Components
[ViewVariables(VVAccess.ReadWrite)] [DataField("deleteOnSpawn")]
private bool _deleteOnSpawn = true;
- [ViewVariables(VVAccess.ReadWrite)] [DataField("makeSentient")]
- private bool _makeSentient = true;
-
[ViewVariables(VVAccess.ReadWrite)] [DataField("availableTakeovers")]
private int _availableTakeovers = 1;
@@ -41,12 +38,12 @@ namespace Content.Server.Ghost.Roles.Components
if (Taken)
return false;
- if(string.IsNullOrEmpty(Prototype))
+ if (string.IsNullOrEmpty(Prototype))
throw new NullReferenceException("Prototype string cannot be null or empty!");
var mob = Owner.EntityManager.SpawnEntity(Prototype, Owner.Transform.Coordinates);
- if(_makeSentient)
+ if (MakeSentient)
MakeSentientCommand.MakeSentient(mob.Uid, Owner.EntityManager);
mob.EnsureComponent();
@@ -62,9 +59,7 @@ namespace Content.Server.Ghost.Roles.Components
if (_deleteOnSpawn)
Owner.Delete();
-
return true;
-
}
}
}
diff --git a/Content.Server/Ghost/Roles/Components/GhostTakeoverAvailableComponent.cs b/Content.Server/Ghost/Roles/Components/GhostTakeoverAvailableComponent.cs
index d154244b6f..786ec1fdf7 100644
--- a/Content.Server/Ghost/Roles/Components/GhostTakeoverAvailableComponent.cs
+++ b/Content.Server/Ghost/Roles/Components/GhostTakeoverAvailableComponent.cs
@@ -1,4 +1,5 @@
using System;
+using Content.Server.Mind.Commands;
using Content.Server.Mind.Components;
using Content.Server.Players;
using Robust.Server.Player;
@@ -27,6 +28,9 @@ namespace Content.Server.Ghost.Roles.Components
if (mind.HasMind)
return false;
+ if (MakeSentient)
+ MakeSentientCommand.MakeSentient(OwnerUid, Owner.EntityManager);
+
var ghostRoleSystem = EntitySystem.Get();
ghostRoleSystem.GhostRoleInternalCreateMindAndTransfer(session, OwnerUid, OwnerUid, this);