2023-04-12 06:32:14 -07:00
|
|
|
using Content.Server.Ghost.Roles.Components;
|
2022-10-22 15:05:06 -07:00
|
|
|
using Content.Server.Speech.Components;
|
2024-06-30 05:43:43 +02:00
|
|
|
using Content.Shared.EntityEffects;
|
2023-08-30 21:46:11 -07:00
|
|
|
using Content.Shared.Mind.Components;
|
2023-06-04 16:45:02 -04:00
|
|
|
using Robust.Shared.Prototypes;
|
2022-10-22 15:05:06 -07:00
|
|
|
|
2024-06-30 05:43:43 +02:00
|
|
|
namespace Content.Server.EntityEffects.Effects;
|
2022-10-22 15:05:06 -07:00
|
|
|
|
2024-06-30 05:43:43 +02:00
|
|
|
public sealed partial class MakeSentient : EntityEffect
|
2022-10-22 15:05:06 -07:00
|
|
|
{
|
2023-06-04 16:45:02 -04:00
|
|
|
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
|
|
|
|
|
=> Loc.GetString("reagent-effect-guidebook-make-sentient", ("chance", Probability));
|
|
|
|
|
|
2024-06-30 05:43:43 +02:00
|
|
|
public override void Effect(EntityEffectBaseArgs args)
|
2022-10-22 15:05:06 -07:00
|
|
|
{
|
|
|
|
|
var entityManager = args.EntityManager;
|
2024-06-30 05:43:43 +02:00
|
|
|
var uid = args.TargetEntity;
|
2022-10-22 15:05:06 -07:00
|
|
|
|
2023-09-10 13:21:54 -07:00
|
|
|
// 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
|
2022-10-22 15:05:06 -07:00
|
|
|
entityManager.RemoveComponent<ReplacementAccentComponent>(uid);
|
2022-11-14 18:02:46 -08:00
|
|
|
entityManager.RemoveComponent<MonkeyAccentComponent>(uid);
|
|
|
|
|
|
2023-09-10 13:21:54 -07:00
|
|
|
// Stops from adding a ghost role to things like people who already have a mind
|
2023-09-30 18:53:21 +01:00
|
|
|
if (entityManager.TryGetComponent<MindContainerComponent>(uid, out var mindContainer) && mindContainer.HasMind)
|
2023-03-20 00:47:06 +00:00
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-10 13:21:54 -07:00
|
|
|
// Don't add a ghost role to things that already have ghost roles
|
|
|
|
|
if (entityManager.TryGetComponent(uid, out GhostRoleComponent? ghostRole))
|
2022-10-22 15:05:06 -07:00
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-12 06:32:14 -07:00
|
|
|
ghostRole = entityManager.AddComponent<GhostRoleComponent>(uid);
|
2023-09-10 13:21:54 -07:00
|
|
|
entityManager.EnsureComponent<GhostTakeoverAvailableComponent>(uid);
|
2022-10-22 15:05:06 -07:00
|
|
|
|
|
|
|
|
var entityData = entityManager.GetComponent<MetaDataComponent>(uid);
|
2023-04-12 06:32:14 -07:00
|
|
|
ghostRole.RoleName = entityData.EntityName;
|
|
|
|
|
ghostRole.RoleDescription = Loc.GetString("ghost-role-information-cognizine-description");
|
2022-10-22 15:05:06 -07:00
|
|
|
}
|
|
|
|
|
}
|