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.Mind.Components ;
using Content.Server.Speech.Components ;
using Content.Shared.Chemistry.Reagent ;
2023-06-04 16:45:02 -04:00
using Content.Server.Ghost.Roles.Components ;
using Robust.Shared.Prototypes ;
2022-10-22 15:05:06 -07:00
namespace Content.Server.Chemistry.ReagentEffects ;
public sealed class MakeSentient : ReagentEffect
{
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 ) ) ;
2022-10-22 15:05:06 -07:00
public override void Effect ( ReagentEffectArgs args )
{
var entityManager = args . EntityManager ;
var uid = args . SolutionEntity ;
2023-06-18 11:33:19 -07:00
// This makes it so it doesn't affect things that are already sentient
if ( entityManager . HasComponent < MindContainerComponent > ( uid ) )
{
return ;
}
2022-10-22 15:05:06 -07:00
// 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.
entityManager . RemoveComponent < ReplacementAccentComponent > ( uid ) ;
2023-03-20 00:47:06 +00:00
// Monke talk. This makes cognizine a cure to AMIV's long term damage funnily enough, do with this information what you will.
2022-11-14 18:02:46 -08:00
entityManager . RemoveComponent < MonkeyAccentComponent > ( uid ) ;
2023-03-20 00:47:06 +00:00
// This makes it so it doesn't add a ghost role to things that are already sentient
2023-06-18 11:33:19 -07:00
if ( entityManager . HasComponent < MindContainerComponent > ( uid ) )
2023-03-20 00:47:06 +00:00
{
return ;
}
2022-10-22 15:05:06 -07:00
// No idea what anything past this point does
2023-04-12 06:32:14 -07:00
if ( entityManager . TryGetComponent ( uid , out GhostRoleComponent ? ghostRole ) | |
entityManager . TryGetComponent ( uid , out GhostTakeoverAvailableComponent ? takeOver ) )
2022-10-22 15:05:06 -07:00
{
return ;
}
2023-04-12 06:32:14 -07:00
ghostRole = entityManager . AddComponent < GhostRoleComponent > ( uid ) ;
entityManager . AddComponent < 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
}
}
// 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.