(fb180d412) Merge branch 'dev' into human-ai

This commit is contained in:
Joonas Rikkonen
2019-05-16 06:17:45 +03:00
parent 2f0bd98f8f
commit 8b977ed5c0
23 changed files with 425 additions and 150 deletions
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using Barotrauma.Extensions;
using Microsoft.Xna.Framework;
@@ -87,7 +88,7 @@ namespace Barotrauma
}
}
// the timer is set between 1 and 10 seconds, depending on the priority
// the timer is set between 1 and 10 seconds, depending on the priority modifier and a random +-25%
private float SetTargetUpdateTimer() => targetUpdateTimer = 1 / MathHelper.Clamp(PriorityModifier * Rand.Range(0.75f, 1.25f), 0.1f, 1);
public override void Reset()
@@ -158,13 +159,18 @@ namespace Barotrauma
if (!Objectives.TryGetValue(target, out AIObjective objective))
{
objective = ObjectiveConstructor(target);
objective.Completed += () => ReportedTargets.Remove(target);
objective.Completed += () => OnObjectiveCompleted(objective, target);
Objectives.Add(target, objective);
AddSubObjective(objective);
if (!subObjectives.Contains(objective))
{
subObjectives.Add(objective);
}
}
}
}
protected abstract void OnObjectiveCompleted(AIObjective objective, T target);
/// <summary>
/// List of all possible items of the specified type. Used for filtering the removed objectives.
/// </summary>