Item facing has one owner: EquippedItem.Orient
Behavior.Direction, FireControl.MountDirection and Thruster's column and torque derive an item's facing through Orient instead of each rotating by EquippableItem.Rotation. Thruster.Torque is a live read over a cached lever direction. Behaviour-neutral; ItemFacingOwnerTests compares bit for bit with the base expressions and passes unchanged on the base commit. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
6d4e894990
commit
1b0d085dae
5 changed files with 155 additions and 6 deletions
|
|
@ -28,7 +28,7 @@ public abstract class Behavior
|
|||
{
|
||||
if(Item != null)
|
||||
{
|
||||
var itemDirection = Entity.Direction.Rotate(Item.EquippableItem.Rotation);
|
||||
var itemDirection = Item.Orient(Entity.Direction);
|
||||
return float3(itemDirection.x, 0, itemDirection.y);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,11 @@ 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 { get; }
|
||||
public float Torque => Item == null ? 0f : -dot(_lever, 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;
|
||||
|
||||
// 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
|
||||
|
|
@ -57,7 +61,7 @@ public class Thruster : Behavior, IPowerConsumer
|
|||
public float3 Column(float thrust)
|
||||
{
|
||||
if (Item == null || !Item.Active.Value) return default;
|
||||
var push = -float2(0, 1).Rotate(Item.EquippableItem.Rotation) * thrust * ItemManager.GameplaySettings.ThrustScale / Entity.Mass;
|
||||
var push = -Item.Orient(float2(0, 1)) * thrust * ItemManager.GameplaySettings.ThrustScale / Entity.Mass;
|
||||
return float3(push.x, push.y, Torque * thrust * ItemManager.GameplaySettings.TorqueMultiplier / Entity.Mass);
|
||||
}
|
||||
|
||||
|
|
@ -85,13 +89,12 @@ public class Thruster : Behavior, IPowerConsumer
|
|||
var itemData = ItemManager.GetData(item.EquippableItem);
|
||||
var itemCenter = hullData.Shape.Inset(itemData.Shape, item.Position, item.EquippableItem.Rotation).CenterOfMass;
|
||||
var toCenter = hullCenter - itemCenter;
|
||||
Torque = -dot(normalize(toCenter), float2(1, 0).Rotate(item.EquippableItem.Rotation));
|
||||
_lever = normalize(toCenter);
|
||||
}
|
||||
|
||||
public Thruster(ThrusterData data, ConsumableItemEffect item) : base(data, item)
|
||||
{
|
||||
_data = data;
|
||||
Torque = 0;
|
||||
}
|
||||
|
||||
// Cut 3 (docs/stats-and-power-cut.md): the resolved stat times the behaviour-supplied throttle scalar (§1.2),
|
||||
|
|
|
|||
Loading…
Reference in a new issue