Consumable AI: agents vent when locked and overdrive to close, with tests
CombatState activates a vapour dump when an enemy lock on the ship passes .5, else a throttle lock when the target is past twice the optimum range and ahead within 15 degrees. Consumables are picked by behaviour kind through Entity.FirstCarriedConsumable and activated through TryActivateConsumable. Work in progress: tests not yet run (this commit may not pass them). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e71540be5b
commit
f270529f9b
3 changed files with 387 additions and 0 deletions
|
|
@ -885,6 +885,13 @@ public abstract class Entity
|
|||
return data.Stackable || FindActiveConsumable(data) == null;
|
||||
}
|
||||
|
||||
// The first consumable design in cargo with a behaviour of the asked kind, or null. Callers ask by kind, never
|
||||
// by name: a design's name is a label and its behaviours are what it does.
|
||||
public ConsumableItemData FirstCarriedConsumable(Predicate<BehaviorData> kind) =>
|
||||
CargoBays.SelectMany(bay => bay.Cargo.Keys).OfType<ConsumableItem>()
|
||||
.Select(item => ItemManager.GetData(item) as ConsumableItemData)
|
||||
.FirstOrDefault(data => data != null && data.Behaviors.Any(b => kind(b)));
|
||||
|
||||
public bool TryActivateConsumable(ConsumableItemData data)
|
||||
{
|
||||
if (!CanActivateConsumable(data)) return false;
|
||||
|
|
|
|||
Loading…
Reference in a new issue