One loose fit rule for hardpoint gear
Operator ruling, 2026-09-30: "Hardpoint fit is loose: nobody's gonna stop you from putting a small reactor in a large reactor's hardpoint." There is one rule, HardpointData.Takes: gear of the hardpoint's type fits when its shape, at the hardpoint's rotation, lies within the hardpoint's cells. TakesAt is the same rule at one offset, and Entity.ItemFits (equipping, save load, presets) now asks it instead of repeating the containment test. Generation's hardpoint picks, HasHome (so station stock and loadouts), product reuse and `AetherDb hardpoint-fit` all read Takes. Generation keeps its own placement preference, named IsFilledBy and not a fit rule: it offers gear that fills the hardpoint when any is on offer and falls back to anything that fits only when none is, so loadouts change only where a hardpoint used to stay empty. RestoredHullsTests pick fillers through IsFilledBy. Consequence: the Autocannon, Vulcan, scorched void policy, Notorious, pretty pretty bang bang, Manhattan, plight, DeathCluster, Small Drive and pswarm now have a home and are offered. Still homeless: CShot RainbowLite Lazer, ChargeBlast SG, ChargeBlast+-, OK Disperser. Tests: generation offers exactly the sold hardpoint gear some hull fits; a 7x7 design no hull fits is offered only once a hull that takes it exists; a 5x5 Reactor hardpoint nothing fills still gets a reactor; equipping and the rule agree for every hull, hardpoint and design; the homeless list is stated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
87fae6e4f0
commit
072a56f0b4
5 changed files with 149 additions and 52 deletions
|
|
@ -814,30 +814,14 @@ public abstract class Entity
|
|||
// If there's no hardpoint there, it won't fit
|
||||
if (hardpoint == null) return false;
|
||||
|
||||
// If the hardpoint type doesn't match the item, it won't fit
|
||||
if (hardpoint.Type != itemData.HardpointType) return false;
|
||||
|
||||
// Items placed in hardpoints are automatically aligned to hardpoint rotation
|
||||
// The one fit rule, at this placement: the item, aligned to the hardpoint's rotation, lies within its cells
|
||||
if (!hardpoint.TakesAt(itemData, hullCoord - hardpoint.Position)) return false;
|
||||
item.Rotation = hardpoint.Rotation;
|
||||
|
||||
// Inset the shapes of both item and hardpoint
|
||||
var itemShapeInset = hullData.Shape.Inset(itemData.Shape, hullCoord, item.Rotation);
|
||||
var hardpointShapeInset = hullData.Shape.Inset(hardpoint.Shape, hardpoint.Position);
|
||||
|
||||
// Check every cell of the hardpoint shape for existing items
|
||||
foreach(var v in hardpointShapeInset.Coordinates)
|
||||
// One item per hardpoint: every cell of it is free (and so every cell of the item)
|
||||
foreach (var v in hullData.Shape.Inset(hardpoint.Shape, hardpoint.Position).Coordinates)
|
||||
if (GearOccupancy[v.x, v.y] != null)
|
||||
return false;
|
||||
|
||||
// Check every cell of the item's shape
|
||||
foreach (var i in itemShapeInset.Coordinates)
|
||||
{
|
||||
// If the hardpoint does not have a matching cell, it wont fit
|
||||
if (!hardpointShapeInset[i]) return false;
|
||||
|
||||
// If there is any gear already occupying that space, it won't fit
|
||||
if (GearOccupancy[i.x, i.y] != null) return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -204,14 +204,7 @@ public class Shape
|
|||
for (int y = 0; y < other.Height - height + 1; y++)
|
||||
{
|
||||
position = int2(x, y);
|
||||
var fits = true;
|
||||
foreach (var v in Coordinates)
|
||||
{
|
||||
fits = fits && other[Rotate(v, rotation) + position];
|
||||
if (!fits) break;
|
||||
}
|
||||
|
||||
if (fits) return true;
|
||||
if (FitsAt(other, rotation, position)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -219,6 +212,14 @@ public class Shape
|
|||
return false;
|
||||
}
|
||||
|
||||
// Whether this shape, turned to a rotation and placed at a position, lies wholly within another shape's cells
|
||||
public bool FitsAt(Shape other, ItemRotation rotation, int2 position)
|
||||
{
|
||||
foreach (var v in Coordinates)
|
||||
if (!other[Rotate(v, rotation) + position]) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Set every cell on the line from a to b to true according to Bresenham's Line Algorithm
|
||||
public void SetLine(float2 a, float2 b)
|
||||
{
|
||||
|
|
@ -567,11 +568,19 @@ public class HardpointData
|
|||
return $"{Enum.GetName(typeof(HardpointType), Type)} Hardpoint {Rotation.Arrow()}";
|
||||
}
|
||||
|
||||
// The one fit rule for hardpoint gear: its type, laid in at this hardpoint's rotation, filling every cell.
|
||||
// The one fit rule for hardpoint gear (operator, 2026-09-30: "Hardpoint fit is loose: nobody's gonna stop you
|
||||
// from putting a small reactor in a large reactor's hardpoint"): gear of this hardpoint's type fits when its shape,
|
||||
// laid in at the hardpoint's rotation, lies within the hardpoint's cells. TakesAt is the same rule at one offset
|
||||
// from the hardpoint's origin, which is where equipping places it.
|
||||
public bool Takes(EquippableItemData design) =>
|
||||
design.HardpointType == Type &&
|
||||
design.Shape.FitsWithin(Shape, Rotation, out _) &&
|
||||
design.Shape.Coordinates.Length == Shape.Coordinates.Length;
|
||||
design.HardpointType == Type && design.Shape.FitsWithin(Shape, Rotation, out _);
|
||||
|
||||
public bool TakesAt(EquippableItemData design, int2 offset) =>
|
||||
design.HardpointType == Type && design.Shape.FitsAt(Shape, Rotation, offset);
|
||||
|
||||
// Generation's placement preference, not a fit rule: gear that fits and fills every cell of the hardpoint.
|
||||
public bool IsFilledBy(EquippableItemData design) =>
|
||||
Takes(design) && design.Shape.Coordinates.Length == Shape.Coordinates.Length;
|
||||
|
||||
[IgnoreMember]
|
||||
public float3 TintColor
|
||||
|
|
|
|||
|
|
@ -201,6 +201,10 @@ public class LoadoutGenerator
|
|||
|
||||
public (FactionProductData product, T design) RandomProduct<T>(HardpointData hardpoint, float sizeExponent, Predicate<T> filter = null, bool required = false) where T : EquippableItemData
|
||||
{
|
||||
// Every candidate passes the one fit rule, HardpointData.Takes. Generation prefers gear that fills the hardpoint
|
||||
// and falls back to anything that fits only when nothing that fills it is on offer.
|
||||
var filling = RandomProduct<T>(sizeExponent, item => hardpoint.IsFilledBy(item) && (filter?.Invoke(item) ?? true));
|
||||
if (filling.design != null) return filling;
|
||||
return RandomProduct<T>(sizeExponent, item => hardpoint.Takes(item) && (filter?.Invoke(item) ?? true), required);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue