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:
@@ -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)
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Content.Server.Players
|
||||
/// DO NOT DIRECTLY SET THIS UNLESS YOU KNOW WHAT YOU'RE DOING.
|
||||
/// </summary>
|
||||
[ViewVariables, Access(typeof(MindSystem), typeof(GameTicker))]
|
||||
public Mind.Mind? Mind { get; set; }
|
||||
public EntityUid? Mind { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If true, the player is an admin and they explicitly de-adminned mid-game,
|
||||
@@ -65,7 +65,7 @@ namespace Content.Server.Players
|
||||
/// <summary>
|
||||
/// Gets the mind that is associated with this player.
|
||||
/// </summary>
|
||||
public static Mind.Mind? GetMind(this IPlayerSession session)
|
||||
public static EntityUid? GetMind(this IPlayerSession session)
|
||||
{
|
||||
return session.Data.ContentData()?.Mind;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user