Remove stamina + damageable .Owner (#14602)

* Remove stamina + damageable .Owner

* More
This commit is contained in:
metalgearsloth
2023-03-13 00:19:05 +11:00
committed by GitHub
parent 058c732db1
commit 49c7c0f9a7
12 changed files with 70 additions and 59 deletions

View File

@@ -193,9 +193,9 @@ namespace Content.IntegrationTests.Tests.Damageable
Assert.That(sDamageableComponent.TotalDamage, Is.EqualTo(FixedPoint2.Zero));
// Test SetAll function
sDamageableSystem.SetAllDamage(sDamageableComponent, 10);
sDamageableSystem.SetAllDamage(sDamageableEntity, sDamageableComponent, 10);
Assert.That(sDamageableComponent.TotalDamage, Is.EqualTo(FixedPoint2.New(10 * sDamageableComponent.Damage.DamageDict.Count())));
sDamageableSystem.SetAllDamage(sDamageableComponent, 0);
sDamageableSystem.SetAllDamage(sDamageableEntity, sDamageableComponent, 0);
Assert.That(sDamageableComponent.TotalDamage, Is.EqualTo(FixedPoint2.Zero));
// Test 'wasted' healing

View File

@@ -39,7 +39,7 @@ namespace Content.IntegrationTests.Tests.Destructible
var coordinates = testMap.GridCoords;
sDestructibleEntity = sEntityManager.SpawnEntity(DestructibleDamageGroupEntityId, coordinates);
sDamageableComponent = IoCManager.Resolve<IEntityManager>().GetComponent<DamageableComponent>(sDestructibleEntity);
sDamageableComponent = sEntityManager.GetComponent<DamageableComponent>(sDestructibleEntity);
sTestThresholdListenerSystem = sEntitySystemManager.GetEntitySystem<TestDestructibleListenerSystem>();
sTestThresholdListenerSystem.ThresholdsReached.Clear();
@@ -125,7 +125,7 @@ namespace Content.IntegrationTests.Tests.Destructible
sTestThresholdListenerSystem.ThresholdsReached.Clear();
// Heal both classes of damage to 0
sDamageableSystem.SetAllDamage(sDamageableComponent, 0);
sDamageableSystem.SetAllDamage(sDestructibleEntity, sDamageableComponent, 0);
// No new thresholds reached, healing should not trigger it
Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
@@ -163,7 +163,7 @@ namespace Content.IntegrationTests.Tests.Destructible
threshold.TriggersOnce = true;
// Heal brute and burn back to 0
sDamageableSystem.SetAllDamage(sDamageableComponent, 0);
sDamageableSystem.SetAllDamage(sDestructibleEntity, sDamageableComponent, 0);
// No new thresholds reached from healing
Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);

View File

@@ -30,6 +30,7 @@ namespace Content.IntegrationTests.Tests.Destructible
var sEntityManager = server.ResolveDependency<IEntityManager>();
var sPrototypeManager = server.ResolveDependency<IPrototypeManager>();
var sEntitySystemManager = server.ResolveDependency<IEntitySystemManager>();
var audio = sEntitySystemManager.GetEntitySystem<SharedAudioSystem>();
var testMap = await PoolManager.CreateTestMap(pairTracker);
@@ -44,8 +45,8 @@ namespace Content.IntegrationTests.Tests.Destructible
var coordinates = testMap.GridCoords;
sDestructibleEntity = sEntityManager.SpawnEntity(DestructibleEntityId, coordinates);
sDamageableComponent = IoCManager.Resolve<IEntityManager>().GetComponent<DamageableComponent>(sDestructibleEntity);
sDestructibleComponent = IoCManager.Resolve<IEntityManager>().GetComponent<DestructibleComponent>(sDestructibleEntity);
sDamageableComponent = sEntityManager.GetComponent<DamageableComponent>(sDestructibleEntity);
sDestructibleComponent = sEntityManager.GetComponent<DestructibleComponent>(sDestructibleEntity);
sTestThresholdListenerSystem = sEntitySystemManager.GetEntitySystem<TestDestructibleListenerSystem>();
sTestThresholdListenerSystem.ThresholdsReached.Clear();
@@ -102,9 +103,9 @@ namespace Content.IntegrationTests.Tests.Destructible
var actsThreshold = (DoActsBehavior) threshold.Behaviors[2];
Assert.That(actsThreshold.Acts, Is.EqualTo(ThresholdActs.Breakage));
Assert.That(soundThreshold.Sound.GetSound(), Is.EqualTo("/Audio/Effects/woodhit.ogg"));
Assert.That(audio.GetSound(soundThreshold.Sound), Is.EqualTo("/Audio/Effects/woodhit.ogg"));
Assert.That(spawnThreshold.Spawn, Is.Not.Null);
Assert.That(spawnThreshold.Spawn.Count, Is.EqualTo(1));
Assert.That(spawnThreshold.Spawn, Has.Count.EqualTo(1));
Assert.That(spawnThreshold.Spawn.Single().Key, Is.EqualTo(SpawnedEntityId));
Assert.That(spawnThreshold.Spawn.Single().Value.Min, Is.EqualTo(1));
Assert.That(spawnThreshold.Spawn.Single().Value.Max, Is.EqualTo(1));
@@ -120,7 +121,7 @@ namespace Content.IntegrationTests.Tests.Destructible
Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
// Set damage to 0
sDamageableSystem.SetAllDamage(sDamageableComponent, 0);
sDamageableSystem.SetAllDamage(sDestructibleEntity, sDamageableComponent, 0);
// Damage for 100, up to 100
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage*10, true);
@@ -166,7 +167,7 @@ namespace Content.IntegrationTests.Tests.Destructible
// Check that it matches the YAML prototype
Assert.That(actsThreshold.Acts, Is.EqualTo(ThresholdActs.Breakage));
Assert.That(soundThreshold.Sound.GetSound(), Is.EqualTo("/Audio/Effects/woodhit.ogg"));
Assert.That(audio.GetSound(soundThreshold.Sound), Is.EqualTo("/Audio/Effects/woodhit.ogg"));
Assert.That(spawnThreshold.Spawn, Is.Not.Null);
Assert.That(spawnThreshold.Spawn.Count, Is.EqualTo(1));
Assert.That(spawnThreshold.Spawn.Single().Key, Is.EqualTo(SpawnedEntityId));
@@ -179,7 +180,7 @@ namespace Content.IntegrationTests.Tests.Destructible
sTestThresholdListenerSystem.ThresholdsReached.Clear();
// Heal all damage
sDamageableSystem.SetAllDamage(sDamageableComponent, 0);
sDamageableSystem.SetAllDamage(sDestructibleEntity, sDamageableComponent, 0);
// Damage up to 50
sDamageableSystem.TryChangeDamage(sDestructibleEntity, bluntDamage*5, true);
@@ -219,7 +220,7 @@ namespace Content.IntegrationTests.Tests.Destructible
Assert.That(actsThreshold.Acts, Is.EqualTo(ThresholdActs.Breakage));
Assert.That(soundThreshold.Sound.GetSound(), Is.EqualTo("/Audio/Effects/woodhit.ogg"));
Assert.That(spawnThreshold.Spawn, Is.Not.Null);
Assert.That(spawnThreshold.Spawn.Count, Is.EqualTo(1));
Assert.That(spawnThreshold.Spawn, Has.Count.EqualTo(1));
Assert.That(spawnThreshold.Spawn.Single().Key, Is.EqualTo(SpawnedEntityId));
Assert.That(spawnThreshold.Spawn.Single().Value.Min, Is.EqualTo(1));
Assert.That(spawnThreshold.Spawn.Single().Value.Max, Is.EqualTo(1));
@@ -230,7 +231,7 @@ namespace Content.IntegrationTests.Tests.Destructible
sTestThresholdListenerSystem.ThresholdsReached.Clear();
// Heal the entity completely
sDamageableSystem.SetAllDamage(sDamageableComponent, 0);
sDamageableSystem.SetAllDamage(sDestructibleEntity, sDamageableComponent, 0);
// Check that the entity has 0 damage
Assert.That(sDamageableComponent.TotalDamage, Is.EqualTo(FixedPoint2.Zero));

View File

@@ -24,6 +24,7 @@ namespace Content.IntegrationTests.Tests
var mapManager = server.ResolveDependency<IMapManager>();
var sEntities = server.ResolveDependency<IEntityManager>();
var mapLoader = sEntities.System<MapLoaderSystem>();
var xformSystem = sEntities.EntitySysManager.GetEntitySystem<SharedTransformSystem>();
var resManager = server.ResolveDependency<IResourceManager>();
await server.WaitPost(() =>
@@ -36,13 +37,13 @@ namespace Content.IntegrationTests.Tests
{
var mapGrid = mapManager.CreateGrid(mapId);
var mapGridEnt = mapGrid.Owner;
sEntities.GetComponent<TransformComponent>(mapGridEnt).WorldPosition = new Vector2(10, 10);
xformSystem.SetWorldPosition(mapGridEnt, new Vector2(10, 10));
mapGrid.SetTile(new Vector2i(0,0), new Tile(1, (TileRenderFlag)1, 255));
}
{
var mapGrid = mapManager.CreateGrid(mapId);
var mapGridEnt = mapGrid.Owner;
sEntities.GetComponent<TransformComponent>(mapGridEnt).WorldPosition = new Vector2(-8, -8);
xformSystem.SetWorldPosition(mapGridEnt, new Vector2(-8, -8));
mapGrid.SetTile(new Vector2i(0, 0), new Tile(2, (TileRenderFlag)1, 254));
}
@@ -67,7 +68,7 @@ namespace Content.IntegrationTests.Tests
return;
}
Assert.That(gridXform.WorldPosition, Is.EqualTo(new Vector2(10, 10)));
Assert.That(xformSystem.GetWorldPosition(gridXform), Is.EqualTo(new Vector2(10, 10)));
Assert.That(mapGrid.GetTileRef(new Vector2i(0, 0)).Tile, Is.EqualTo(new Tile(1, (TileRenderFlag)1, 255)));
}
@@ -79,7 +80,7 @@ namespace Content.IntegrationTests.Tests
return;
}
Assert.That(gridXform.WorldPosition, Is.EqualTo(new Vector2(-8, -8)));
Assert.That(xformSystem.GetWorldPosition(gridXform), Is.EqualTo(new Vector2(-8, -8)));
Assert.That(mapGrid.GetTileRef(new Vector2i(0, 0)).Tile, Is.EqualTo(new Tile(2, (TileRenderFlag)1, 254)));
}
});