Use typed hull facets in motion consumers
This commit is contained in:
parent
710a98bc8d
commit
64214c5dd8
7 changed files with 34 additions and 14 deletions
Binary file not shown.
|
|
@ -83,7 +83,7 @@ public class CombatState : BaseState
|
|||
var testWeapon = _agent.Ship.WeaponGroups[selectedGroup].weapons.First();
|
||||
if(testWeapon.Velocity > 1)
|
||||
{
|
||||
var targetHullData = _agent.ItemManager.GetData(target.Hull) as HullData;
|
||||
var targetHull = _agent.ItemManager.GetRuntimeItem(target.Hull);
|
||||
var targetVelocity = float3(target.Velocity.x, 0, target.Velocity.y);
|
||||
var shipVelocity = float3(_agent.Ship.Velocity.x, 0, _agent.Ship.Velocity.y);
|
||||
var predictedPosition = AetheriaMath.FirstOrderIntercept(
|
||||
|
|
@ -93,7 +93,7 @@ public class CombatState : BaseState
|
|||
target.Position,
|
||||
targetVelocity
|
||||
);
|
||||
predictedPosition.y = _agent.Ship.Zone.GetHeight(predictedPosition.xz) + targetHullData.GridOffset;
|
||||
predictedPosition.y = _agent.Ship.Zone.GetHeight(predictedPosition.xz) + (float)(targetHull?.HullGridOffset ?? 0);
|
||||
toTarget = normalize(predictedPosition - _agent.Ship.Position);
|
||||
}
|
||||
|
||||
|
|
@ -148,4 +148,4 @@ public class CombatState : BaseState
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,10 +52,10 @@ public class Thruster : Behavior, IAnalogBehavior
|
|||
public Thruster(ThrusterData data, EquippedItem item) : base(data, item)
|
||||
{
|
||||
_data = data;
|
||||
var hullData = ItemManager.GetData(Entity.Hull) as HullData;
|
||||
var hullCenter = hullData.Shape.CenterOfMass;
|
||||
var itemData = ItemManager.GetData(item.EquippableItem);
|
||||
var itemCenter = hullData.Shape.Inset(itemData.Shape, item.Position, item.EquippableItem.Rotation).CenterOfMass;
|
||||
var hullShape = ItemManager.GetRuntimeShape(Entity.Hull);
|
||||
var itemShape = ItemManager.GetRuntimeShape(item.EquippableItem);
|
||||
var hullCenter = hullShape.CenterOfMass;
|
||||
var itemCenter = hullShape.Inset(itemShape, item.Position, item.EquippableItem.Rotation).CenterOfMass;
|
||||
var toCenter = hullCenter - itemCenter;
|
||||
Torque = -dot(normalize(toCenter), float2(1, 0).Rotate(item.EquippableItem.Rotation));
|
||||
Thrust = Evaluate(_data.Thrust);
|
||||
|
|
|
|||
|
|
@ -60,13 +60,13 @@ public class TurretController : Behavior, IInitializableBehavior
|
|||
var diff = Entity.Target.Value.Position - Entity.Position;
|
||||
if (_predictShots)
|
||||
{
|
||||
var targetHullData = Entity.ItemManager.GetData(Entity.Target.Value.Hull) as HullData;
|
||||
var targetHull = Entity.ItemManager.GetRuntimeItem(Entity.Target.Value.Hull);
|
||||
var targetVelocity = float3(Entity.Target.Value.Velocity.x, 0, Entity.Target.Value.Velocity.y);
|
||||
var predictedPosition = AetheriaMath.FirstOrderIntercept(
|
||||
Entity.Position, float3.zero, _shotSpeed,
|
||||
Entity.Target.Value.Position, targetVelocity
|
||||
);
|
||||
predictedPosition.y = Entity.Zone.GetHeight(predictedPosition.xz) + targetHullData.GridOffset;
|
||||
predictedPosition.y = Entity.Zone.GetHeight(predictedPosition.xz) + (float)(targetHull?.HullGridOffset ?? 0);
|
||||
Entity.LookDirection = normalize(predictedPosition - Entity.Position);
|
||||
}
|
||||
else
|
||||
|
|
@ -98,4 +98,4 @@ public class TurretController : Behavior, IInitializableBehavior
|
|||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,6 +64,23 @@ public class ItemManager
|
|||
return itemId == Guid.Empty ? null : _itemProjections.GetRuntimeItem(itemId);
|
||||
}
|
||||
|
||||
public Shape GetRuntimeShape(ItemInstance item)
|
||||
{
|
||||
var typedItem = GetRuntimeItem(item);
|
||||
return ToShape(typedItem?.ShapeWidth ?? 1, typedItem?.ShapeHeight ?? 1, typedItem?.ShapeCells);
|
||||
}
|
||||
|
||||
private static Shape ToShape(int width, int height, IReadOnlyList<AetheriaRuntimeShapeCell> cells)
|
||||
{
|
||||
var shape = new Shape(Math.Max(width, 1), Math.Max(height, 1));
|
||||
if (cells == null) return shape;
|
||||
|
||||
foreach (var cell in cells)
|
||||
shape[new int2(cell.X, cell.Y)] = true;
|
||||
|
||||
return shape;
|
||||
}
|
||||
|
||||
public RuntimeItemReference CreateReference(ItemData item)
|
||||
{
|
||||
return new RuntimeItemReference(item);
|
||||
|
|
|
|||
|
|
@ -284,7 +284,7 @@ public class Ship : Entity
|
|||
|
||||
var velocityMagnitude = length(Velocity);
|
||||
if(velocityMagnitude > .01f)
|
||||
Velocity = normalize(Velocity) * AetheriaMath.Decay(velocityMagnitude, HullData.Drag, delta);
|
||||
Velocity = normalize(Velocity) * AetheriaMath.Decay(velocityMagnitude, (float)(ItemManager.GetRuntimeItem(Hull)?.HullDrag ?? 0), delta);
|
||||
|
||||
Position.xz += Velocity * delta;
|
||||
|
||||
|
|
|
|||
|
|
@ -186,9 +186,10 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted.
|
|||
`Entity.UnoccupiedSpace`, grid-offset placement, and `Entity.UpdateTemperature`
|
||||
also read typed hull shape/interior, hardpoints, base armor, mass, specific
|
||||
heat, and conductivity from runtime catalog rows. `EquippedItem` inset-shape
|
||||
and behavior construction, docking bay max-size, ship drag, combat/turret
|
||||
prediction, thruster behavior, and loadout generator helper predicates still
|
||||
belong to legacy simulation projections until those owners are rebuilt.
|
||||
and behavior construction, docking bay max-size, and loadout generator helper
|
||||
predicates still belong to legacy simulation projections until those owners
|
||||
are rebuilt. Ship drag, combat/turret shot prediction height, and thruster
|
||||
torque geometry now consume typed hull facets and typed shape masks.
|
||||
The item properties panel also reads typed catalog title names, descriptions,
|
||||
manufacturer, base mass, max durability, thermal bounds, and thermal
|
||||
performance curve keys for basic item presentation without hydrating legacy
|
||||
|
|
@ -708,6 +709,8 @@ First Aetheria surfaces to publish:
|
|||
checked-in `.cc` catalog, and move `Entity.MapEntity`,
|
||||
`Entity.UnoccupiedSpace`, grid-offset placement, and
|
||||
`Entity.UpdateTemperature` onto typed runtime hull rows.
|
||||
- Done: move `Ship` drag, combat/turret predicted shot height, and thruster
|
||||
torque geometry onto typed hull facets and typed shape masks.
|
||||
- Done: delete the console `give` command instead of preserving a debug
|
||||
operator path that hydrated typed item rows back into legacy item DTOs.
|
||||
- Done: delete `ItemManager.GetCatalogEntries<T>` after all live callers
|
||||
|
|
|
|||
Loading…
Reference in a new issue