Add interaction tests (#15251)
This commit is contained in:
@@ -13,6 +13,7 @@ namespace Content.Server.Construction.Completions
|
||||
{
|
||||
[DataField("container")] public string Container { get; private set; } = string.Empty;
|
||||
|
||||
// TODO use or generalize ConstructionSystem.ChangeEntity();
|
||||
public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
|
||||
{
|
||||
if (!entityManager.TryGetComponent(uid, out ContainerManagerComponent? containerManager))
|
||||
@@ -62,8 +63,12 @@ namespace Content.Server.Construction.Completions
|
||||
// We only add this container. If some construction needs to take other containers into account, fix this.
|
||||
entityManager.EntitySysManager.GetEntitySystem<ConstructionSystem>().AddContainer(computer, Container);
|
||||
|
||||
var entChangeEv = new ConstructionChangeEntityEvent(computer, uid);
|
||||
entityManager.EventBus.RaiseLocalEvent(uid, entChangeEv);
|
||||
entityManager.EventBus.RaiseLocalEvent(computer, entChangeEv, broadcast: true);
|
||||
|
||||
// Delete the original entity.
|
||||
entityManager.DeleteEntity(uid);
|
||||
entityManager.QueueDeleteEntity(uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace Content.Server.Construction.Completions
|
||||
[DataDefinition]
|
||||
public sealed class BuildMachine : IGraphAction
|
||||
{
|
||||
// TODO use or generalize ConstructionSystem.ChangeEntity();
|
||||
public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
|
||||
{
|
||||
if (!entityManager.TryGetComponent(uid, out ContainerManagerComponent? containerManager))
|
||||
@@ -102,7 +103,10 @@ namespace Content.Server.Construction.Completions
|
||||
constructionSystem.RefreshParts(machineComp);
|
||||
}
|
||||
|
||||
entityManager.DeleteEntity(uid);
|
||||
var entChangeEv = new ConstructionChangeEntityEvent(machine, uid);
|
||||
entityManager.EventBus.RaiseLocalEvent(uid, entChangeEv);
|
||||
entityManager.EventBus.RaiseLocalEvent(machine, entChangeEv, broadcast: true);
|
||||
entityManager.QueueDeleteEntity(uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ public sealed class BuildMech : IGraphAction
|
||||
[DataField("container")]
|
||||
public string Container = "battery-container";
|
||||
|
||||
// TODO use or generalize ConstructionSystem.ChangeEntity();
|
||||
public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
|
||||
{
|
||||
if (!entityManager.TryGetComponent(uid, out ContainerManagerComponent? containerManager))
|
||||
@@ -64,8 +65,10 @@ public sealed class BuildMech : IGraphAction
|
||||
mechComp.BatterySlot.Insert(cell);
|
||||
}
|
||||
|
||||
// Delete the original entity.
|
||||
entityManager.DeleteEntity(uid);
|
||||
var entChangeEv = new ConstructionChangeEntityEvent(mech, uid);
|
||||
entityManager.EventBus.RaiseLocalEvent(uid, entChangeEv);
|
||||
entityManager.EventBus.RaiseLocalEvent(mech, entChangeEv, broadcast: true);
|
||||
entityManager.QueueDeleteEntity(uid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user