Use typed hull facets in motion consumers

This commit is contained in:
Meta Vens 2026-06-14 05:15:18 +01:00
commit 64214c5dd8
7 changed files with 34 additions and 14 deletions

View file

@ -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);

View file

@ -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;
}
}
}