Merge remote-tracking branch 'upstream/master' into develop

This commit is contained in:
EvilFactory
2024-06-27 10:52:55 -03:00
32 changed files with 411 additions and 132 deletions
@@ -1,4 +1,6 @@
#nullable enable
using FarseerPhysics;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -117,24 +119,52 @@ namespace Barotrauma
{
if (inspectTimer > 0.0f)
{
character.SelectCharacter(Target);
Vector2 diff = Target.WorldPosition - character.WorldPosition;
float dist = diff.Length();
float maxDist = ConvertUnits.ToDisplayUnits(HumanoidAnimController.BreakFromGrabDistance);
if (dist > maxDist)
{
if (dist > maxDist * 2 || !character.CanSeeTarget(Target, seeThroughWindows: false))
{
//too far to reach by small manual movement, need to switch back to the earlier state
currentState = State.GotoTarget;
}
//move closer horizontally if the horizontal distance is the issue
else if (Math.Abs(diff.X) > Math.Abs(diff.Y) * 2.0f)
{
character.AIController.SteeringManager.SteeringManual(deltaTime, new Vector2(MathF.Sign(Target.WorldPosition.X - character.WorldPosition.X), 0.0f));
}
else
{
character.AIController.SteeringManager.Reset();
}
return;
}
else
{
if (dist < maxDist * 0.5f) { character.AIController.SteeringManager.Reset(); }
character.SelectCharacter(Target);
}
inspectTimer -= deltaTime;
if (inspectTimer < InspectTime - 1)
{
if (Target.AnimController.IsMovingFast)
if (Math.Abs(Target.AnimController.TargetMovement.X) > 1.0f)
{
ArrestFleeing();
}
else if (Math.Abs(Target.AnimController.TargetMovement.X) > 1.0f)
{
// If the target moves, reset the inspect timer and tell to hold still
// If the target moves, tell to hold still
character.Speak(TextManager.Get("dialogcheckstolenitems.holdstill").Value, identifier: "holdstill".ToIdentifier(), minDurationBetweenSimilar: 3f);
inspectTimer = InspectTime;
}
}
return;
}
if (character.SelectedCharacter != Target)
{
//target not selected -> must've escaped
Abandon = true;
return;
}
if (stolenItems.Any() &&
Rand.Range(0.0f, 1.0f, Rand.RandSync.Unsynced) < FindStolenItemsProbability)
{
@@ -155,13 +185,6 @@ namespace Barotrauma
if (warnTimer > 0.0f)
{
warnTimer -= deltaTime;
if (warnTimer < currentWarnDelay - 1)
{
if (Target.AnimController.IsMovingFast)
{
ArrestFleeing();
}
}
return;
}
var stolenItemsOnCharacter = stolenItems.Where(it => it.GetRootInventoryOwner() == Target);
@@ -189,14 +212,6 @@ namespace Barotrauma
IsCompleted = true;
}
private void ArrestFleeing()
{
character.Speak(TextManager.Get("dialogcheckstolenitems.arrest").Value);
currentState = State.Done;
IsCompleted = true;
Arrest(abortWhenItemsDropped: false, allowHoldFire: false);
}
private void Arrest(bool abortWhenItemsDropped, bool allowHoldFire)
{
bool isCriminal = Target.IsCriminal;
@@ -12,6 +12,8 @@ namespace Barotrauma
protected override float TargetUpdateTimeMultiplier => 0.2f;
public bool TargetCharactersInOtherSubs { get; init; }
protected override bool AllowInAnySub => TargetCharactersInOtherSubs;
public AIObjectiveFightIntruders(Character character, AIObjectiveManager objectiveManager, float priorityModifier = 1)
: base(character, objectiveManager, priorityModifier) { }
@@ -21,6 +21,8 @@ namespace Barotrauma
private const float MaxSpeedOnStairs = 1.7f;
private const float SteepSlopePushMagnitude = MaxSpeedOnStairs;
public const float BreakFromGrabDistance = 1.4f;
public override RagdollParams RagdollParams
{
get { return HumanRagdollParams; }
@@ -1844,7 +1846,7 @@ namespace Barotrauma
float dist = ConvertUnits.ToSimUnits(Vector2.Distance(target.WorldPosition, WorldPosition));
//let the target break free if it's moving away and gets far enough
if ((GameMain.NetworkMember == null || !GameMain.NetworkMember.IsClient) && dist > 1.4f && target.AllowInput &&
if ((GameMain.NetworkMember == null || !GameMain.NetworkMember.IsClient) && dist > BreakFromGrabDistance && target.AllowInput &&
Vector2.Dot(target.WorldPosition - WorldPosition, target.AnimController.TargetMovement) > 0)
{
character.DeselectCharacter();
@@ -299,6 +299,7 @@ namespace Barotrauma
public XElement OrderData;
public bool PermanentlyDead;
public bool RenamingEnabled = false;
private static ushort idCounter = 1;
private const string disguiseName = "???";
@@ -802,6 +803,7 @@ namespace Barotrauma
LoadTagsBackwardsCompatibility(infoElement, tags);
SpeciesName = infoElement.GetAttributeIdentifier("speciesname", "");
PermanentlyDead = infoElement.GetAttributeBool("permanentlydead", false);
RenamingEnabled = infoElement.GetAttributeBool("renamingenabled", false);
ContentXElement element;
if (!SpeciesName.IsEmpty)
{
@@ -1499,7 +1501,8 @@ namespace Barotrauma
new XAttribute("startitemsgiven", StartItemsGiven),
new XAttribute("personality", PersonalityTrait?.Identifier ?? Identifier.Empty),
new XAttribute("lastrewarddistribution", LastRewardDistribution.Match(some: value => value, none: () => -1).ToString()),
new XAttribute("permanentlydead", PermanentlyDead)
new XAttribute("permanentlydead", PermanentlyDead),
new XAttribute("renamingenabled", RenamingEnabled)
);
if (HumanPrefabIds != default)