]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix cognizine not working on entities with minds (#19951)
authorInterrobang01 <113810873+Interrobang01@users.noreply.github.com>
Sun, 10 Sep 2023 20:21:54 +0000 (13:21 -0700)
committerGitHub <noreply@github.com>
Sun, 10 Sep 2023 20:21:54 +0000 (12:21 -0800)
Content.Server/Chemistry/ReagentEffects/MakeSentient.cs

index 2e5529fbd267d9b4cd6f9a36cb10a583173d60ef..00266c39a85d638b20a2e5890c9bdfd063a7ab53 100644 (file)
@@ -16,38 +16,29 @@ public sealed partial class MakeSentient : ReagentEffect
         var entityManager = args.EntityManager;
         var uid = args.SolutionEntity;
 
-        // This makes it so it doesn't affect things that are already sentient
-        if (entityManager.HasComponent<MindContainerComponent>(uid))
-        {
-            return;
-        }
-
-        // This piece of code makes things able to speak "normally". One thing of note is that monkeys have a unique accent and won't be affected by this.
+        // Let affected entities speak normally to make this effect different from, say, the "random sentience" event
+        // This also works on entities that already have a mind
+        // We call this before the mind check to allow things like player-controlled mice to be able to benefit from the effect
         entityManager.RemoveComponent<ReplacementAccentComponent>(uid);
-
-        // Monke talk. This makes cognizine a cure to AMIV's long term damage funnily enough, do with this information what you will.
         entityManager.RemoveComponent<MonkeyAccentComponent>(uid);
 
-        // This makes it so it doesn't add a ghost role to things that are already sentient
+        // Stops from adding a ghost role to things like people who already have a mind
         if (entityManager.HasComponent<MindContainerComponent>(uid))
         {
             return;
         }
 
-        // No idea what anything past this point does
-        if (entityManager.TryGetComponent(uid, out GhostRoleComponent? ghostRole) ||
-            entityManager.TryGetComponent(uid, out GhostTakeoverAvailableComponent? takeOver))
+        // Don't add a ghost role to things that already have ghost roles
+        if (entityManager.TryGetComponent(uid, out GhostRoleComponent? ghostRole))
         {
             return;
         }
 
         ghostRole = entityManager.AddComponent<GhostRoleComponent>(uid);
-        entityManager.AddComponent<GhostTakeoverAvailableComponent>(uid);
+        entityManager.EnsureComponent<GhostTakeoverAvailableComponent>(uid);
 
         var entityData = entityManager.GetComponent<MetaDataComponent>(uid);
         ghostRole.RoleName = entityData.EntityName;
         ghostRole.RoleDescription = Loc.GetString("ghost-role-information-cognizine-description");
     }
 }
-
-// Original code written by areitpog on GitHub in Issue #7666, then I (Interrobang01) copied it and used my nonexistant C# skills to try to make it work again.