Restrict ghost role speech/movement to component flags (#11183)

This commit is contained in:
Flipp Syder
2022-09-13 20:46:49 -07:00
committed by GitHub
parent dcd72cccba
commit f9922d9160
11 changed files with 45 additions and 10 deletions

View File

@@ -39,19 +39,27 @@ namespace Content.Server.Mind.Commands
return;
}
MakeSentient(entId, entityManager);
MakeSentient(entId, entityManager, true, true);
}
public static void MakeSentient(EntityUid uid, IEntityManager entityManager)
public static void MakeSentient(EntityUid uid, IEntityManager entityManager, bool allowMovement = true, bool allowSpeech = true)
{
entityManager.RemoveComponent<NPCComponent>(uid);
entityManager.EnsureComponent<MindComponent>(uid);
entityManager.EnsureComponent<InputMoverComponent>(uid);
entityManager.EnsureComponent<MobMoverComponent>(uid);
entityManager.EnsureComponent<MovementSpeedModifierComponent>(uid);
entityManager.EnsureComponent<SharedSpeechComponent>(uid);
entityManager.EnsureComponent<SharedEmotingComponent>(uid);
if (allowMovement)
{
entityManager.EnsureComponent<InputMoverComponent>(uid);
entityManager.EnsureComponent<MobMoverComponent>(uid);
entityManager.EnsureComponent<MovementSpeedModifierComponent>(uid);
}
if (allowSpeech)
{
entityManager.EnsureComponent<SharedSpeechComponent>(uid);
entityManager.EnsureComponent<SharedEmotingComponent>(uid);
}
entityManager.EnsureComponent<ExaminerComponent>(uid);
}
}