diff --git a/Content.Server/Ghost/Roles/Components/GhostRoleComponent.cs b/Content.Server/Ghost/Roles/Components/GhostRoleComponent.cs index 93e7e9efaa..abb26a8c8b 100644 --- a/Content.Server/Ghost/Roles/Components/GhostRoleComponent.cs +++ b/Content.Server/Ghost/Roles/Components/GhostRoleComponent.cs @@ -11,7 +11,7 @@ namespace Content.Server.Ghost.Roles.Components [DataField("description")] private string _roleDescription = "Unknown"; - [DataField("rules")] private string _roleRules = ""; + [DataField("rules")] private string _roleRules = "ghost-role-component-default-rules"; [DataField("requirements")] public HashSet? Requirements; diff --git a/Content.Server/Ghost/Roles/GhostRoleSystem.cs b/Content.Server/Ghost/Roles/GhostRoleSystem.cs index cd04e3fb37..0649e68a31 100644 --- a/Content.Server/Ghost/Roles/GhostRoleSystem.cs +++ b/Content.Server/Ghost/Roles/GhostRoleSystem.cs @@ -56,7 +56,8 @@ namespace Content.Server.Ghost.Roles SubscribeLocalEvent(OnMindAdded); SubscribeLocalEvent(OnMindRemoved); SubscribeLocalEvent(OnMobStateChanged); - SubscribeLocalEvent(OnInit); + SubscribeLocalEvent(OnMapInit); + SubscribeLocalEvent(OnStartup); SubscribeLocalEvent(OnShutdown); SubscribeLocalEvent(OnPaused); SubscribeLocalEvent(OnUnpaused); @@ -317,17 +318,14 @@ namespace Content.Server.Ghost.Roles UpdateAllEui(); } - private void OnInit(Entity ent, ref ComponentInit args) + private void OnMapInit(Entity ent, ref MapInitEvent args) { - var role = ent.Comp; - if (role.Probability < 1f && !_random.Prob(role.Probability)) - { - RemComp(ent); - return; - } + if (ent.Comp.Probability < 1f && !_random.Prob(ent.Comp.Probability)) + RemCompDeferred(ent); + } - if (role.RoleRules == "") - role.RoleRules = Loc.GetString("ghost-role-component-default-rules"); + private void OnStartup(Entity ent, ref ComponentStartup args) + { RegisterGhostRole(ent); }