Fix GhostRoleComponent performing randomization on ComponentInit (#26466)

* Fix ghostrole ComponentInit

* A

* a
This commit is contained in:
Leon Friedrich
2024-03-27 17:31:26 +13:00
committed by GitHub
parent fbea150b53
commit cb8f145975
2 changed files with 9 additions and 11 deletions

View File

@@ -56,7 +56,8 @@ namespace Content.Server.Ghost.Roles
SubscribeLocalEvent<GhostTakeoverAvailableComponent, MindAddedMessage>(OnMindAdded);
SubscribeLocalEvent<GhostTakeoverAvailableComponent, MindRemovedMessage>(OnMindRemoved);
SubscribeLocalEvent<GhostTakeoverAvailableComponent, MobStateChangedEvent>(OnMobStateChanged);
SubscribeLocalEvent<GhostRoleComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<GhostRoleComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<GhostRoleComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<GhostRoleComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<GhostRoleComponent, EntityPausedEvent>(OnPaused);
SubscribeLocalEvent<GhostRoleComponent, EntityUnpausedEvent>(OnUnpaused);
@@ -317,17 +318,14 @@ namespace Content.Server.Ghost.Roles
UpdateAllEui();
}
private void OnInit(Entity<GhostRoleComponent> ent, ref ComponentInit args)
private void OnMapInit(Entity<GhostRoleComponent> ent, ref MapInitEvent args)
{
var role = ent.Comp;
if (role.Probability < 1f && !_random.Prob(role.Probability))
{
RemComp<GhostRoleComponent>(ent);
return;
}
if (ent.Comp.Probability < 1f && !_random.Prob(ent.Comp.Probability))
RemCompDeferred<GhostRoleComponent>(ent);
}
if (role.RoleRules == "")
role.RoleRules = Loc.GetString("ghost-role-component-default-rules");
private void OnStartup(Entity<GhostRoleComponent> ent, ref ComponentStartup args)
{
RegisterGhostRole(ent);
}