public Resupply(Actor self, Actor host, WDist closeEnough) { this.host = Target.FromActor(host); this.closeEnough = closeEnough; allRepairsUnits = host.TraitsImplementing <RepairsUnits>().ToArray(); health = self.TraitOrDefault <IHealth>(); repairable = self.TraitOrDefault <Repairable>(); repairableNear = self.TraitOrDefault <RepairableNear>(); rearmable = self.TraitOrDefault <Rearmable>(); notifyResupplies = host.TraitsImplementing <INotifyResupply>().ToArray(); var cannotRepairAtHost = health == null || health.DamageState == DamageState.Undamaged || !allRepairsUnits.Any() || ((repairable == null || !repairable.Info.RepairActors.Contains(host.Info.Name)) && (repairableNear == null || !repairableNear.Info.RepairActors.Contains(host.Info.Name))); if (!cannotRepairAtHost) { activeResupplyTypes |= ResupplyType.Repair; } var cannotRearmAtHost = rearmable == null || !rearmable.Info.RearmActors.Contains(host.Info.Name) || rearmable.RearmableAmmoPools.All(p => p.FullAmmo()); if (!cannotRearmAtHost) { activeResupplyTypes |= ResupplyType.Rearm; } }
public Resupply(Actor self, Actor host, WDist closeEnough, bool stayOnResupplier = false) { this.host = Target.FromActor(host); this.closeEnough = closeEnough; this.stayOnResupplier = stayOnResupplier; allRepairsUnits = host.TraitsImplementing <RepairsUnits>().ToArray(); health = self.TraitOrDefault <IHealth>(); repairable = self.TraitOrDefault <Repairable>(); repairableNear = self.TraitOrDefault <RepairableNear>(); rearmable = self.TraitOrDefault <Rearmable>(); notifyResupplies = host.TraitsImplementing <INotifyResupply>().ToArray(); notifyBeingResupplied = self.TraitsImplementing <INotifyBeingResupplied>().ToArray(); transportCallers = self.TraitsImplementing <ICallForTransport>().ToArray(); move = self.Trait <IMove>(); aircraft = move as Aircraft; moveInfo = self.Info.TraitInfo <IMoveInfo>(); playerResources = self.Owner.PlayerActor.Trait <PlayerResources>(); var valued = self.Info.TraitInfoOrDefault <ValuedInfo>(); unitCost = valued != null ? valued.Cost : 0; var cannotRepairAtHost = health == null || health.DamageState == DamageState.Undamaged || !allRepairsUnits.Any() || ((repairable == null || !repairable.Info.RepairActors.Contains(host.Info.Name)) && (repairableNear == null || !repairableNear.Info.RepairActors.Contains(host.Info.Name))); if (!cannotRepairAtHost) { activeResupplyTypes |= ResupplyType.Repair; // HACK: Reservable logic can't handle repairs, so force a take-off if resupply included repairs. // TODO: Make reservation logic or future docking logic properly handle this. wasRepaired = true; } var cannotRearmAtHost = rearmable == null || !rearmable.Info.RearmActors.Contains(host.Info.Name) || rearmable.RearmableAmmoPools.All(p => p.HasFullAmmo); if (!cannotRearmAtHost) { activeResupplyTypes |= ResupplyType.Rearm; } }