Inline Transform

This commit is contained in:
Vera Aguilera Puerto
2021-12-03 14:20:34 +01:00
parent 69b270017b
commit a5b57c8e10
283 changed files with 742 additions and 709 deletions

View File

@@ -237,7 +237,7 @@ namespace Content.Server.GameTicking
var equipmentStr = startingGear.GetGear(slot, profile);
if (!string.IsNullOrEmpty(equipmentStr))
{
var equipmentEntity = EntityManager.SpawnEntity(equipmentStr, entity.Transform.Coordinates);
var equipmentEntity = EntityManager.SpawnEntity(equipmentStr, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity.Uid).Coordinates);
inventory.Equip(slot, IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(equipmentEntity.Uid));
}
}
@@ -248,7 +248,7 @@ namespace Content.Server.GameTicking
var inhand = startingGear.Inhand;
foreach (var (hand, prototype) in inhand)
{
var inhandEntity = EntityManager.SpawnEntity(prototype, entity.Transform.Coordinates);
var inhandEntity = EntityManager.SpawnEntity(prototype, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity.Uid).Coordinates);
handsComponent.TryPickupEntity(hand, inhandEntity, checkActionBlocker: false);
}
}

View File

@@ -47,7 +47,7 @@ namespace Content.Server.GameTicking.Presets
mind.UnVisit();
}
var position = playerEntity?.Transform.Coordinates ?? EntitySystem.Get<GameTicker>().GetObserverSpawnPoint();
var position = (playerEntity != null ? IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(playerEntity.Uid) : null).Coordinates ?? EntitySystem.Get<GameTicker>().GetObserverSpawnPoint();
// Ok, so, this is the master place for the logic for if ghosting is "too cheaty" to allow returning.
// There's no reason at this time to move it to any other place, especially given that the 'side effects required' situations would also have to be moved.
// + If CharacterDeadPhysically applies, we're physically dead. Therefore, ghosting OK, and we can return (this is critical for gibbing)

View File

@@ -92,15 +92,15 @@ namespace Content.Server.GameTicking.Presets
// Replace their items:
// pda
var newPDA = _entityManager.SpawnEntity(PDAPrototypeName, mind.OwnedEntity.Transform.Coordinates);
var newPDA = _entityManager.SpawnEntity(PDAPrototypeName, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(mind.OwnedEntity.Uid).Coordinates);
inventory.Equip(EquipmentSlotDefines.Slots.IDCARD, IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(newPDA.Uid));
// belt
var newTmp = _entityManager.SpawnEntity(BeltPrototypeName, mind.OwnedEntity.Transform.Coordinates);
var newTmp = _entityManager.SpawnEntity(BeltPrototypeName, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(mind.OwnedEntity.Uid).Coordinates);
inventory.Equip(EquipmentSlotDefines.Slots.BELT, IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(newTmp.Uid));
// backpack
newTmp = _entityManager.SpawnEntity(BackpackPrototypeName, mind.OwnedEntity.Transform.Coordinates);
newTmp = _entityManager.SpawnEntity(BackpackPrototypeName, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(mind.OwnedEntity.Uid).Coordinates);
inventory.Equip(EquipmentSlotDefines.Slots.BACKPACK, IoCManager.Resolve<IEntityManager>().GetComponent<ItemComponent>(newTmp.Uid));
// Like normal traitors, they need access to a traitor account.
@@ -123,7 +123,7 @@ namespace Content.Server.GameTicking.Presets
// Finally, it would be preferrable if they spawned as far away from other players as reasonably possible.
if (mind.OwnedEntity != null && FindAnyIsolatedSpawnLocation(mind, out var bestTarget))
{
mind.OwnedEntity.Transform.Coordinates = bestTarget;
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(mind.OwnedEntity.Uid).Coordinates = bestTarget;
}
else
{
@@ -162,7 +162,7 @@ namespace Content.Server.GameTicking.Presets
// Doesn't have mob state component. Assume something interesting is going on and don't count this as someone to avoid.
continue;
}
existingPlayerPoints.Add(avoidMeEntity.Transform.Coordinates);
existingPlayerPoints.Add(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(avoidMeEntity.Uid).Coordinates);
}
// Iterate over each possible spawn point, comparing to the existing player points.
@@ -176,18 +176,18 @@ namespace Content.Server.GameTicking.Presets
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
foreach (var entity in ents)
{
if (!atmosphereSystem.IsTileMixtureProbablySafe(entity.Transform.Coordinates))
if (!atmosphereSystem.IsTileMixtureProbablySafe(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity.Uid).Coordinates))
continue;
var distanceFromNearest = float.PositiveInfinity;
foreach (var existing in existingPlayerPoints)
{
if (entity.Transform.Coordinates.TryDistance(_entityManager, existing, out var dist))
if (IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity.Uid).Coordinates.TryDistance(_entityManager, existing, out var dist))
distanceFromNearest = Math.Min(distanceFromNearest, dist);
}
if (bestTargetDistanceFromNearest < distanceFromNearest)
{
bestTarget = entity.Transform.Coordinates;
bestTarget = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity.Uid).Coordinates;
bestTargetDistanceFromNearest = distanceFromNearest;
foundATarget = true;
}