The placement rule (HardpointAt) already finds the one hardpoint an item lies in at equip; TryEquip threw that answer away and eighteen readers recomputed it from the item's origin cell, which need not lie in the hardpoint (Soul's scenarios batch-4 P30). EquippedItem.Hardpoint now carries the answer, null for Tool gear and the hull, and every origin-cell lookup reads it instead: FireControl.ArcFor, the eleven weapon managers, EntityInstance, ShipInstance and ActionGameManager's articulation grouping. Entity.Hardpoints[,] stays the per-cell map for armour and display. TryFindSpace's hardpoint search tries every origin the fit rule can accept, including ones up and left of the hardpoint, so a design whose shape lacks its origin cell is found wherever ItemFits would place it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
33 lines
1.1 KiB
C#
33 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class ConstantLaserManager : ConstantWeaponEffectManager
|
|
{
|
|
public Prototype LaserPrototype;
|
|
|
|
private Dictionary<EquippedItem, ConstantLaser> _lasers = new Dictionary<EquippedItem, ConstantLaser>();
|
|
|
|
public override void StartFiring(WeaponData data, EquippedItem item, EntityInstance source, EntityInstance target)
|
|
{
|
|
var p = LaserPrototype.Instantiate<ConstantLaser>();
|
|
p.SourceEntity = source.Entity;
|
|
var hp = item.Hardpoint;
|
|
var barrel = source.GetBarrel(hp);
|
|
p.Range = item.Evaluate(data.Range);
|
|
var t = p.transform;
|
|
t.SetParent(barrel);
|
|
t.forward = barrel.forward;
|
|
t.position = barrel.position;
|
|
// Cut 4 (docs/fire-control-cut.md): FireControl already rolls this weapon's damage; the presentation
|
|
// only needs to know where to draw the beam.
|
|
p.TargetTransform = target != null ? target.transform : null;
|
|
_lasers.Add(item, p);
|
|
}
|
|
|
|
public override void StopFiring(EquippedItem item)
|
|
{
|
|
_lasers[item].Stop();
|
|
_lasers.Remove(item);
|
|
}
|
|
}
|