Fix polymorphed null error (#11571)

This commit is contained in:
Leon Friedrich
2022-10-02 07:16:55 +13:00
committed by GitHub
parent 8389bde2c0
commit d43ed3210c
3 changed files with 43 additions and 23 deletions

View File

@@ -24,6 +24,7 @@ namespace Content.Server.Polymorph.Systems
[Dependency] private readonly ActionsSystem _actions = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly IComponentFactory _compFact = default!;
[Dependency] private readonly ServerInventorySystem _inventory = default!;
[Dependency] private readonly SharedHandsSystem _sharedHands = default!;
[Dependency] private readonly DamageableSystem _damageable = default!;
@@ -98,10 +99,11 @@ namespace Content.Server.Polymorph.Systems
var child = Spawn(proto.Entity, targetTransformComp.Coordinates);
MakeSentientCommand.MakeSentient(child, EntityManager);
var comp = EnsureComp<PolymorphedEntityComponent>(child);
var comp = _compFact.GetComponent<PolymorphedEntityComponent>();
comp.Owner = child;
comp.Parent = target;
comp.Prototype = proto;
RaiseLocalEvent(child, new PolymorphComponentSetupEvent(), true);
comp.Prototype = proto.ID;
EntityManager.AddComponent(child, comp);
var childXform = Transform(child);
childXform.LocalRotation = targetTransformComp.LocalRotation;
@@ -212,11 +214,6 @@ namespace Content.Server.Polymorph.Systems
}
}
/// <summary>
/// Used after the polymorphedEntity component has it's data set up.
/// </summary>
public sealed class PolymorphComponentSetupEvent : InstantActionEvent { };
public sealed class PolymorphActionEvent : InstantActionEvent
{
/// <summary>