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

@@ -11,7 +11,7 @@ namespace Content.Server.Ghost.Roles.Components
[DataField("description")] private string _roleDescription = "Unknown"; [DataField("description")] private string _roleDescription = "Unknown";
[DataField("rules")] private string _roleRules = ""; [DataField("rules")] private string _roleRules = "ghost-role-component-default-rules";
[DataField("requirements")] [DataField("requirements")]
public HashSet<JobRequirement>? Requirements; public HashSet<JobRequirement>? Requirements;

View File

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