Refactor minds to be entities with components, make roles components (#19591)

Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com>
Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
This commit is contained in:
DrSmugleaf
2023-08-28 16:53:24 -07:00
committed by GitHub
parent e0ee397af7
commit 15c0211fb2
119 changed files with 1445 additions and 1289 deletions

View File

@@ -77,14 +77,17 @@ public sealed class PlayTimeTrackingSystem : EntitySystem
return state.CurrentState is MobState.Alive or MobState.Critical;
}
public IEnumerable<string> GetTimedRoles(Mind.Mind mind)
public IEnumerable<string> GetTimedRoles(EntityUid mindId)
{
foreach (var role in mind.AllRoles)
var ev = new MindGetAllRolesEvent(new List<RoleInfo>());
RaiseLocalEvent(ref ev);
foreach (var role in ev.Roles)
{
if (role is not IRoleTimer timer)
if (string.IsNullOrWhiteSpace(role.PlayTimeTrackerId))
continue;
yield return _prototypes.Index<PlayTimeTrackerPrototype>(timer.Timer).ID;
yield return _prototypes.Index<PlayTimeTrackerPrototype>(role.PlayTimeTrackerId).ID;
}
}
@@ -95,7 +98,7 @@ public sealed class PlayTimeTrackingSystem : EntitySystem
if (contentData?.Mind == null)
return Enumerable.Empty<string>();
return GetTimedRoles(contentData.Mind);
return GetTimedRoles(contentData.Mind.Value);
}
private void OnRoleRemove(RoleRemovedEvent ev)