fix: make IdentityComp.IdentityEntitySlot optional (#39357)

* fix: make IdentityComp.IdentityEntitySlot optional

* Revert "fix: make IdentityComp.IdentityEntitySlot optional"

This reverts commit fa25263be916ed142bf2cff9871fca3e64c6da2b.

* fix conflicts

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
Perry Fraser
2025-10-21 11:33:59 -04:00
committed by GitHub
parent 43b9d71973
commit 5a0a984aa8
3 changed files with 24 additions and 7 deletions

View File

@@ -78,11 +78,17 @@ public sealed class IdentitySystem : EntitySystem
// Creates an identity entity, and store it in the identity container
private void OnMapInit(Entity<IdentityComponent> ent, ref MapInitEvent args)
{
if (ent.Comp.IdentityEntitySlot is not { } slot)
{
Log.Error($"Uninitialized IdentityEntitySlot for {ToPrettyString(ent.Owner)}.");
return;
}
var ident = Spawn(null, Transform(ent).Coordinates);
_metaData.SetEntityName(ident, "identity");
QueueIdentityUpdate(ent);
_container.Insert(ident, ent.Comp.IdentityEntitySlot);
_container.Insert(ident, slot);
}
private void OnComponentInit(Entity<IdentityComponent> ent, ref ComponentInit args)
@@ -132,7 +138,7 @@ public sealed class IdentitySystem : EntitySystem
/// </summary>
private void UpdateIdentityInfo(Entity<IdentityComponent> ent)
{
if (ent.Comp.IdentityEntitySlot.ContainedEntity is not { } ident)
if (ent.Comp.IdentityEntitySlot?.ContainedEntity is not { } ident)
return;
var representation = GetIdentityRepresentation(ent.Owner);