[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<JobRequirement>? Requirements;
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);
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);
}