public override float GetPriority() { if (!IsAllowed) { Priority = 0; return(Priority); } // TODO: priority list? // Ignore items that are being repaired by someone else. if (Item.Repairables.Any(r => r.CurrentFixer != null && r.CurrentFixer != character)) { Priority = 0; } else { float distanceFactor = 1; if (!isPriority && Item.CurrentHull != character.CurrentHull) { float yDist = Math.Abs(character.WorldPosition.Y - Item.WorldPosition.Y); yDist = yDist > 100 ? yDist * 5 : 0; float dist = Math.Abs(character.WorldPosition.X - Item.WorldPosition.X) + yDist; distanceFactor = MathHelper.Lerp(1, 0.25f, MathUtils.InverseLerp(0, 5000, dist)); } float severity = isPriority ? 1 : AIObjectiveRepairItems.GetTargetPriority(Item, character); float isSelected = IsRepairing ? 50 : 0; float devotion = (CumulatedDevotion + isSelected) / 100; float max = MathHelper.Min(AIObjectiveManager.OrderPriority - 1, 90); Priority = MathHelper.Lerp(0, max, MathHelper.Clamp(devotion + (severity * distanceFactor * PriorityModifier), 0, 1)); } return(Priority); }
public override float GetPriority() { if (!IsAllowed) { Priority = 0; Abandon = true; return(Priority); } // TODO: priority list? // Ignore items that are being repaired by someone else. if (Item.Repairables.Any(r => r.CurrentFixer != null && r.CurrentFixer != character)) { Priority = 0; } else { float distanceFactor = 1; if (!isPriority && Item.CurrentHull != character.CurrentHull) { float yDist = Math.Abs(character.WorldPosition.Y - Item.WorldPosition.Y); yDist = yDist > 100 ? yDist * 5 : 0; float dist = Math.Abs(character.WorldPosition.X - Item.WorldPosition.X) + yDist; distanceFactor = MathHelper.Lerp(1, 0.25f, MathUtils.InverseLerp(0, 4000, dist)); } float requiredSuccessFactor = objectiveManager.IsCurrentOrder <AIObjectiveRepairItems>() ? 0 : AIObjectiveRepairItems.RequiredSuccessFactor; float severity = isPriority ? 1 : AIObjectiveRepairItems.GetTargetPriority(Item, character, requiredSuccessFactor) / 100; bool isSelected = IsRepairing(); float selectedBonus = isSelected ? 100 - MaxDevotion : 0; float devotion = (CumulatedDevotion + selectedBonus) / 100; float reduction = isPriority ? 1 : isSelected ? 2 : 3; float max = MathHelper.Min(AIObjectiveManager.OrderPriority - reduction, 90); Priority = MathHelper.Lerp(0, max, MathHelper.Clamp(devotion + (severity * distanceFactor * PriorityModifier), 0, 1)); } return(Priority); }
protected override float GetPriority() { if (!IsAllowed || Item.IgnoreByAI(character)) { Priority = 0; Abandon = true; if (IsRepairing()) { Item.Repairables.ForEach(r => r.StopRepairing(character)); } return(Priority); } if (HumanAIController.IsItemRepairedByAnother(Item, out _)) { Priority = 0; IsCompleted = true; } else { float distanceFactor = 1; if (!isPriority && Item.CurrentHull != character.CurrentHull) { float yDist = Math.Abs(character.WorldPosition.Y - Item.WorldPosition.Y); yDist = yDist > 100 ? yDist * 5 : 0; float dist = Math.Abs(character.WorldPosition.X - Item.WorldPosition.X) + yDist; distanceFactor = MathHelper.Lerp(1, 0.25f, MathUtils.InverseLerp(0, 4000, dist)); } float requiredSuccessFactor = objectiveManager.HasOrder <AIObjectiveRepairItems>() ? 0 : AIObjectiveRepairItems.RequiredSuccessFactor; float severity = isPriority ? 1 : AIObjectiveRepairItems.GetTargetPriority(Item, character, requiredSuccessFactor) / 100; bool isSelected = IsRepairing(); float selectedBonus = isSelected ? 100 - MaxDevotion : 0; float devotion = (CumulatedDevotion + selectedBonus) / 100; float reduction = isPriority ? 1 : isSelected ? 2 : 3; float max = AIObjectiveManager.LowestOrderPriority - reduction; float highestWeight = -1; foreach (string tag in Item.Prefab.Tags) { if (JobPrefab.ItemRepairPriorities.TryGetValue(tag, out float weight) && weight > highestWeight) { highestWeight = weight; } } if (highestWeight == -1) { // Predefined weight not found. highestWeight = 1; } Priority = MathHelper.Lerp(0, max, MathHelper.Clamp(devotion + (severity * distanceFactor * highestWeight * PriorityModifier), 0, 1)); } return(Priority); }