Thruster torque derives its lever on read; Orient cites the actuated-assemblies ruling
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1b0d085dae
commit
e58042149e
2 changed files with 12 additions and 11 deletions
|
|
@ -49,11 +49,13 @@ public class Thruster : Behavior, IPowerConsumer
|
|||
// Thrust at a full grant, the same stat read without the power-supply term: what a column promises. Live, like Thrust.
|
||||
public float NominalThrust => EvaluateNominalPower(_data.Thrust);
|
||||
// GameplaySettings.ThrustScale scales the push alone: it tunes how hard ships fight gravity, and turning does not.
|
||||
public float Torque => Item == null ? 0f : -dot(_lever, Item.Orient(float2(1, 0)));
|
||||
public float Torque => Item == null ? 0f : -dot(normalize(_hullCenter - _itemCenter), Item.Orient(float2(1, 0)));
|
||||
|
||||
// Unit vector from the thruster to the hull's centre of mass: placement, fixed at construction. Which way the
|
||||
// thruster faces is not cached with it; Torque reads that live from EquippedItem.Orient.
|
||||
private readonly float2 _lever;
|
||||
// Placement, fixed at construction: the hull's centre of mass and the item's own centre, both in cell space. The
|
||||
// lever (the direction from one to the other) and the facing it is dotted with are derived on every Torque read,
|
||||
// so a later change to where the item sits or which way it faces moves the torque without a second owner.
|
||||
private readonly float2 _hullCenter;
|
||||
private readonly float2 _itemCenter;
|
||||
|
||||
// This thruster's effect per unit throttle at the given thrust, in the body frame: xy is the push (x starboard, y
|
||||
// forward), z the clockwise yaw rate in rad/s. Zero when the item is absent or offline. The one geometry owner for
|
||||
|
|
@ -85,11 +87,9 @@ public class Thruster : Behavior, IPowerConsumer
|
|||
{
|
||||
_data = data;
|
||||
var hullData = ItemManager.GetData(Entity.Hull) as HullData;
|
||||
var hullCenter = hullData.Shape.CenterOfMass;
|
||||
_hullCenter = hullData.Shape.CenterOfMass;
|
||||
var itemData = ItemManager.GetData(item.EquippableItem);
|
||||
var itemCenter = hullData.Shape.Inset(itemData.Shape, item.Position, item.EquippableItem.Rotation).CenterOfMass;
|
||||
var toCenter = hullCenter - itemCenter;
|
||||
_lever = normalize(toCenter);
|
||||
_itemCenter = hullData.Shape.Inset(itemData.Shape, item.Position, item.EquippableItem.Rotation).CenterOfMass;
|
||||
}
|
||||
|
||||
public Thruster(ThrusterData data, ConsumableItemEffect item) : base(data, item)
|
||||
|
|
|
|||
Loading…
Reference in a new issue