(50c25dbf6) Added a "back" button that closes the credits, minor credits tweaks

This commit is contained in:
Joonas Rikkonen
2019-05-16 05:50:39 +03:00
parent ef374ada71
commit fd7dfebd3a
49 changed files with 1733 additions and 1873 deletions
@@ -4,18 +4,21 @@ using Barotrauma.Extensions;
namespace Barotrauma
{
class AIObjectiveRescueAll : AIObjectiveLoop<Character>
class AIObjectiveRescueAll : AIObjective
{
public override string DebugTag => "rescue all";
public override bool ForceRun => true;
//only treat characters whose vitality is below this (0.9 = 90% of max vitality)
public const float VitalityThreshold = 0.9f;
public override bool KeepDivingGearOn => true;
//only treat characters whose vitality is below this (0.8 = 80% of max vitality)
public const float VitalityThreshold = 0.8f;
private List<Character> rescueTargets;
public AIObjectiveRescueAll(Character character, AIObjectiveManager objectiveManager, float priorityModifier = 1)
: base(character, objectiveManager, priorityModifier) { }
public override bool IsDuplicate(AIObjective otherObjective) => otherObjective is AIObjectiveRescueAll;
public AIObjectiveRescueAll(Character character) : base (character, "")
{
rescueTargets = new List<Character>();
}
protected override void FindTargets()
{
@@ -26,13 +29,31 @@ namespace Barotrauma
}
}
protected override bool Filter(Character target) => IsValidTarget(target, character);
public override float GetPriority(AIObjectiveManager objectiveManager)
{
if (character.Submarine == null) { return 0; }
GetRescueTargets();
if (!rescueTargets.Any()) { return 0.0f; }
if (objectiveManager.CurrentOrder == this)
{
return AIObjectiveManager.OrderPriority;
}
protected override IEnumerable<Character> GetList() => Character.CharacterList;
//if there are targets to rescue, the priority is slightly less
//than the priority of explicit orders given to the character
return AIObjectiveManager.OrderPriority - 5.0f;
}
protected override AIObjective ObjectiveConstructor(Character target) => new AIObjectiveRescue(character, target, objectiveManager, PriorityModifier);
protected override float TargetEvaluation() => targets.Max(t => GetVitalityFactor(t)) * 100;
private void GetRescueTargets()
{
rescueTargets = Character.CharacterList.FindAll(c =>
c.AIController is HumanAIController &&
c.TeamID == character.TeamID &&
c != character &&
!c.IsDead &&
c.Vitality / c.MaxVitality < VitalityThreshold);
}
public static float GetVitalityFactor(Character character) => (character.MaxVitality - character.Vitality) / character.MaxVitality;
@@ -48,5 +69,8 @@ namespace Barotrauma
if (character.Submarine != null && !character.Submarine.IsEntityFoundOnThisSub(target.CurrentHull, true)) { return false; }
return true;
}
public override bool IsCompleted() => false;
public override bool CanBeCompleted => true;
}
}