(0b29f1236) Added: Scaling to mouse cursor size

This commit is contained in:
Joonas Rikkonen
2019-05-18 17:34:53 +03:00
parent 52f773027b
commit 65a914e5ed
22 changed files with 114 additions and 169 deletions
@@ -46,7 +46,7 @@ namespace Barotrauma
if (character.CurrentHull == null)
{
currenthullSafety = 0;
Priority = objectiveManager.CurrentOrder is AIObjectiveGoTo ? 0 : 100;
Priority = 100;
return;
}
if (character.OxygenAvailable < CharacterHealth.LowOxygenThreshold) { Priority = 100; }
@@ -68,8 +68,6 @@ namespace Barotrauma
}
}
private Hull currentSafeHull;
private Hull previousSafeHull;
protected override void Act(float deltaTime)
{
var currentHull = character.AnimController.CurrentHull;
@@ -109,20 +107,15 @@ namespace Barotrauma
else
{
searchHullTimer = SearchHullInterval;
previousSafeHull = currentSafeHull;
currentSafeHull = FindBestHull();
if (currentSafeHull == null)
var bestHull = FindBestHull();
if (bestHull != null && bestHull != currentHull)
{
currentSafeHull = previousSafeHull;
}
if (currentSafeHull != null && currentSafeHull != currentHull)
{
if (goToObjective?.Target != currentSafeHull)
if (goToObjective?.Target != bestHull)
{
goToObjective = null;
}
TryAddSubObjective(ref goToObjective,
constructor: () => new AIObjectiveGoTo(currentSafeHull, character, objectiveManager, getDivingGearIfNeeded: false)
constructor: () => new AIObjectiveGoTo(bestHull, character, objectiveManager, getDivingGearIfNeeded: false)
{
// If we need diving gear, we should already have it, if possible.
AllowGoingOutside = HumanAIController.HasDivingSuit(character)
@@ -134,15 +127,7 @@ namespace Barotrauma
goToObjective = null;
}
}
if (goToObjective != null)
{
if (goToObjective.IsCompleted())
{
objectiveManager.GetObjective<AIObjectiveIdle>()?.Wander(deltaTime);
}
Priority = 0;
return;
}
if (goToObjective != null) { return; }
if (currentHull == null) { return; }
//goto objective doesn't exist (a safe hull not found, or a path to a safe hull not found)
// -> attempt to manually steer away from hazards
@@ -181,8 +166,7 @@ namespace Barotrauma
}
else
{
Priority = 0;
objectiveManager.GetObjective<AIObjectiveIdle>()?.Wander(deltaTime);
character.AIController.SteeringManager.Reset();
}
}
}
@@ -195,11 +179,11 @@ namespace Barotrauma
{
if (hull.Submarine == null) { continue; }
if (ignoredHulls != null && ignoredHulls.Contains(hull)) { continue; }
if (unreachable.Contains(hull)) { continue; }
float hullSafety = 0;
if (character.CurrentHull != null)
if (character.Submarine != null && SteeringManager == PathSteering)
{
// Inside
// Inside or outside near the sub
if (unreachable.Contains(hull)) { continue; }
if (!character.Submarine.IsConnectedTo(hull.Submarine)) { continue; }
hullSafety = HumanAIController.GetHullSafety(hull, character);
// Vertical distance matters more than horizontal (climbing up/down is harder than moving horizontally)
@@ -228,7 +212,7 @@ namespace Barotrauma
else
{
// Outside
if (hull.RoomName != null && hull.RoomName.ToLowerInvariant().Contains("airlock"))
if (hull.RoomName?.ToLowerInvariant() == "airlock")
{
hullSafety = 100;
}
@@ -237,14 +221,13 @@ namespace Barotrauma
// TODO: could also target gaps that get us inside?
foreach (Item item in Item.ItemList)
{
if (item.CurrentHull != hull && item.HasTag("airlock"))
if (item.CurrentHull == hull && item.HasTag("airlock"))
{
hullSafety = 100;
break;
}
}
}
// TODO: could we get a closest door to the outside and target the flowing hull if no airlock is found?
// Huge preference for closer targets
float distance = Vector2.DistanceSquared(character.WorldPosition, hull.WorldPosition);
float distanceFactor = MathHelper.Lerp(1, 0.2f, MathUtils.InverseLerp(0, MathUtils.Pow(100000, 2), distance));