public ConsumableCellQuery(GasAndLiquidConsumerMonitor.Instance smi, int maxCost) { this.smi = smi ?? throw new ArgumentNullException(nameof(smi)); TargetCell = Grid.InvalidCell; TargetElement = null; // IsConsumableCell iterates the diet infos looking for a match, but IsMatch // already uses a fast Set, and the only ONI critters with gas and liquid diets // eat 1 element apiece bestCost = maxCost; }
private static void Prefix(GasAndLiquidConsumerMonitor.Instance __instance, Sim.MassConsumedCallback mcd) { LivingCrystal livingCrystal = __instance.GetComponent <LivingCrystal>(); if (livingCrystal == null) { return; } if (mcd.mass > 0.0f) { livingCrystal.AccumulateMass(mcd.mass, mcd.temperature); } }
/// <summary> /// Applied before FindFood runs. /// </summary> internal static bool Prefix(GasAndLiquidConsumerMonitor.Instance __instance) { int targetCell; // The original query limited to 25 results, pufts have a typical path cost of 2 // for a move and slicksters 1, but pufts can go 4 directions while slicksters only // 2. Go with a 15 cost limit which is 7 tiles (pufts) or 15 tiles (slicksters). var query = new ConsumableCellQuery(__instance, 15); __instance.navigator.RunQuery(query); targetCell = query.TargetCell; if (Grid.IsValidCell(targetCell)) { __instance.targetCell = targetCell; __instance.targetElement = query.TargetElement; } // Stop the slow original from running return(false); }