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

@@ -1,3 +1,4 @@
using Content.Server.Mind;
using Content.Server.Mind.Components;
using Content.Server.Objectives.Interfaces;
using Content.Shared.Humanoid;
@@ -9,27 +10,27 @@ namespace Content.Server.Objectives.Conditions;
[DataDefinition]
public sealed partial class KillRandomPersonCondition : KillPersonCondition
{
public override IObjectiveCondition GetAssigned(Mind.Mind mind)
public override IObjectiveCondition GetAssigned(EntityUid mindId, MindComponent mind)
{
var allHumans = new List<Mind.Mind>();
var allHumans = new List<EntityUid>();
var query = EntityManager.EntityQuery<MindContainerComponent, HumanoidAppearanceComponent>(true);
foreach (var (mc, _) in query)
{
var entity = mc.Mind?.OwnedEntity;
var entity = EntityManager.GetComponentOrNull<MindComponent>(mc.Mind)?.OwnedEntity;
if (entity == default)
continue;
if (EntityManager.TryGetComponent(entity, out MobStateComponent? mobState) &&
MobStateSystem.IsAlive(entity.Value, mobState) &&
mc.Mind != mind && mc.Mind != null)
mc.Mind != mindId && mc.Mind != null)
{
allHumans.Add(mc.Mind);
allHumans.Add(mc.Mind.Value);
}
}
if (allHumans.Count == 0)
return new DieCondition(); // I guess I'll die
return new KillRandomPersonCondition {Target = IoCManager.Resolve<IRobustRandom>().Pick(allHumans)};
return new KillRandomPersonCondition {TargetMindId = IoCManager.Resolve<IRobustRandom>().Pick(allHumans)};
}
}