(b9babfcf6) Merge branch 'ragdoll-syncing-improvements' into dev
This commit is contained in:
@@ -88,13 +88,13 @@ namespace Barotrauma
|
|||||||
Collider.AngularVelocity = newAngularVelocity;
|
Collider.AngularVelocity = newAngularVelocity;
|
||||||
|
|
||||||
float distSqrd = Vector2.DistanceSquared(newPosition, Collider.SimPosition);
|
float distSqrd = Vector2.DistanceSquared(newPosition, Collider.SimPosition);
|
||||||
float errorTolerance = character.AllowInput ? 0.01f : 0.1f;
|
float errorTolerance = character.AllowInput ? 0.01f : 0.2f;
|
||||||
if (distSqrd > errorTolerance)
|
if (distSqrd > errorTolerance)
|
||||||
{
|
{
|
||||||
if (distSqrd > 10.0f || !character.AllowInput)
|
if (distSqrd > 10.0f || !character.AllowInput)
|
||||||
{
|
{
|
||||||
Collider.TargetRotation = newRotation;
|
Collider.TargetRotation = newRotation;
|
||||||
SetPosition(newPosition, lerp: distSqrd < 1.0f);
|
SetPosition(newPosition, lerp: distSqrd < 5.0f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -108,8 +108,15 @@ namespace Barotrauma
|
|||||||
// -> we need to correct it manually
|
// -> we need to correct it manually
|
||||||
if (!character.AllowInput)
|
if (!character.AllowInput)
|
||||||
{
|
{
|
||||||
MainLimb.PullJointWorldAnchorB = Collider.SimPosition;
|
float mainLimbDistSqrd = Vector2.DistanceSquared(MainLimb.PullJointWorldAnchorA, Collider.SimPosition);
|
||||||
MainLimb.PullJointEnabled = true;
|
float mainLimbErrorTolerance = 0.1f;
|
||||||
|
//if the main limb is roughly at the correct position and the collider isn't moving (much at least),
|
||||||
|
//don't attempt to correct the position.
|
||||||
|
if (mainLimbDistSqrd > mainLimbErrorTolerance || Collider.LinearVelocity.LengthSquared() > 0.05f)
|
||||||
|
{
|
||||||
|
MainLimb.PullJointWorldAnchorB = Collider.SimPosition;
|
||||||
|
MainLimb.PullJointEnabled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
character.MemLocalState.Clear();
|
character.MemLocalState.Clear();
|
||||||
|
|||||||
@@ -656,6 +656,13 @@ namespace Barotrauma
|
|||||||
msg.Timer -= deltaTime;
|
msg.Timer -= deltaTime;
|
||||||
msg.Pos += msg.Velocity * deltaTime;
|
msg.Pos += msg.Velocity * deltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (GUIMessage msg in messages)
|
||||||
|
{
|
||||||
|
if (!msg.WorldSpace) continue;
|
||||||
|
msg.Timer -= deltaTime;
|
||||||
|
msg.Pos += msg.Velocity * deltaTime;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
messages.RemoveAll(m => m.Timer <= 0.0f);
|
messages.RemoveAll(m => m.Timer <= 0.0f);
|
||||||
|
|||||||
@@ -1147,65 +1147,6 @@ namespace Barotrauma
|
|||||||
//skip the target if it's a room and the character is already inside a sub
|
//skip the target if it's a room and the character is already inside a sub
|
||||||
if (character.CurrentHull != null && target.Entity is Hull) continue;
|
if (character.CurrentHull != null && target.Entity is Hull) continue;
|
||||||
|
|
||||||
Door door = null;
|
|
||||||
if (target.Entity is Item item)
|
|
||||||
{
|
|
||||||
targetingTag = "dead";
|
|
||||||
if (targetCharacter.Submarine != Character.Submarine)
|
|
||||||
{
|
|
||||||
// In a different sub or the target is outside when we are inside or vice versa -> Ignore the target
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if (targetCharacter.CurrentHull != Character.CurrentHull)
|
|
||||||
{
|
|
||||||
// In the same sub, halve the priority, if not in the same hull.
|
|
||||||
valueModifier = 0.5f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (targetCharacter.AIController is EnemyAIController enemy)
|
|
||||||
{
|
|
||||||
if (enemy.combatStrength > combatStrength)
|
|
||||||
{
|
|
||||||
targetingTag = "stronger";
|
|
||||||
}
|
|
||||||
else if (enemy.combatStrength < combatStrength)
|
|
||||||
{
|
|
||||||
targetingTag = "weaker";
|
|
||||||
}
|
|
||||||
if (State == AIState.Escape && targetingTag == "stronger")
|
|
||||||
{
|
|
||||||
// Frightened
|
|
||||||
valueModifier = 2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (targetCharacter.Submarine != Character.Submarine)
|
|
||||||
{
|
|
||||||
// In a different sub or the target is outside when we are inside or vice versa -> Ignore the target
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if (targetCharacter.CurrentHull != Character.CurrentHull)
|
|
||||||
{
|
|
||||||
// In the same sub, halve the priority, if not in the same hull.
|
|
||||||
valueModifier = 0.5f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (targetCharacter.Submarine != null && Character.Submarine == null)
|
|
||||||
{
|
|
||||||
//target inside, AI outside -> we'll be attacking a wall between the characters so use the priority for attacking rooms
|
|
||||||
targetingTag = "room";
|
|
||||||
}
|
|
||||||
else if (targetingPriorities.ContainsKey(targetCharacter.SpeciesName.ToLowerInvariant()))
|
|
||||||
{
|
|
||||||
targetingTag = targetCharacter.SpeciesName.ToLowerInvariant();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (target.Entity != null)
|
|
||||||
{
|
|
||||||
//skip the target if it's a room and the character is already inside a sub
|
|
||||||
if (character.CurrentHull != null && target.Entity is Hull) continue;
|
|
||||||
|
|
||||||
Door door = null;
|
Door door = null;
|
||||||
if (target.Entity is Item item)
|
if (target.Entity is Item item)
|
||||||
{
|
{
|
||||||
@@ -1275,11 +1216,65 @@ namespace Barotrauma
|
|||||||
valueModifier = isOutdoor ? 1 : 0;
|
valueModifier = isOutdoor ? 1 : 0;
|
||||||
valueModifier *= isOpen ? 5 : 1;
|
valueModifier *= isOpen ? 5 : 1;
|
||||||
}
|
}
|
||||||
else if (targetCharacter.CurrentHull != Character.CurrentHull)
|
}
|
||||||
|
}
|
||||||
|
else if (targetCharacter.Submarine != null && Character.Submarine == null)
|
||||||
|
{
|
||||||
|
//target inside, AI outside -> we'll be attacking a wall between the characters so use the priority for attacking rooms
|
||||||
|
targetingTag = "room";
|
||||||
|
}
|
||||||
|
else if (targetingPriorities.ContainsKey(targetCharacter.SpeciesName.ToLowerInvariant()))
|
||||||
|
{
|
||||||
|
targetingTag = targetCharacter.SpeciesName.ToLowerInvariant();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (target.Entity != null)
|
||||||
|
{
|
||||||
|
//skip the target if it's a room and the character is already inside a sub
|
||||||
|
if (character.CurrentHull != null && target.Entity is Hull) continue;
|
||||||
|
|
||||||
|
Door door = null;
|
||||||
|
if (target.Entity is Item item)
|
||||||
|
{
|
||||||
|
targetingTag = "dead";
|
||||||
|
if (targetCharacter.Submarine != Character.Submarine)
|
||||||
|
{
|
||||||
|
// In a different sub or the target is outside when we are inside or vice versa -> Ignore the target
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (targetCharacter.CurrentHull != Character.CurrentHull)
|
||||||
|
{
|
||||||
|
// In the same sub, halve the priority, if not in the same hull.
|
||||||
|
valueModifier = 0.5f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (targetCharacter.AIController is EnemyAIController enemy)
|
||||||
|
{
|
||||||
|
if (enemy.combatStrength > combatStrength)
|
||||||
|
{
|
||||||
|
targetingTag = "stronger";
|
||||||
|
}
|
||||||
|
else if (enemy.combatStrength < combatStrength)
|
||||||
|
{
|
||||||
|
targetingTag = "weaker";
|
||||||
|
}
|
||||||
|
if (State == AIState.Escape && targetingTag == "stronger")
|
||||||
|
{
|
||||||
|
// Frightened
|
||||||
|
valueModifier = 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (targetCharacter.Submarine != Character.Submarine)
|
||||||
{
|
{
|
||||||
valueModifier = isOutdoor ? 0 : 1;
|
valueModifier = isOutdoor ? 0 : 1;
|
||||||
valueModifier *= isOpen ? 0 : 1;
|
valueModifier *= isOpen ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
else if (targetCharacter.CurrentHull != Character.CurrentHull)
|
||||||
|
{
|
||||||
|
// In the same sub, halve the priority, if not in the same hull.
|
||||||
|
valueModifier = 0.5f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (isOpen) //ignore broken and open doors
|
else if (isOpen) //ignore broken and open doors
|
||||||
{
|
{
|
||||||
@@ -1297,6 +1292,11 @@ namespace Barotrauma
|
|||||||
|
|
||||||
valueModifier *= targetingPriorities[targetingTag].Priority;
|
valueModifier *= targetingPriorities[targetingTag].Priority;
|
||||||
|
|
||||||
|
if (targetingTag == null) continue;
|
||||||
|
if (!targetingPriorities.ContainsKey(targetingTag)) continue;
|
||||||
|
|
||||||
|
valueModifier *= targetingPriorities[targetingTag].Priority;
|
||||||
|
|
||||||
if (valueModifier == 0.0f) continue;
|
if (valueModifier == 0.0f) continue;
|
||||||
|
|
||||||
Vector2 toTarget = target.WorldPosition - character.WorldPosition;
|
Vector2 toTarget = target.WorldPosition - character.WorldPosition;
|
||||||
|
|||||||
@@ -785,6 +785,39 @@ namespace Barotrauma
|
|||||||
|
|
||||||
AllowedLinks = element.GetAttributeStringArray("allowedlinks", new string[0], convertToLowerInvariant: true).ToList();
|
AllowedLinks = element.GetAttributeStringArray("allowedlinks", new string[0], convertToLowerInvariant: true).ToList();
|
||||||
|
|
||||||
|
if (sprite == null)
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError("Item \"" + Name + "\" has no sprite!");
|
||||||
|
#if SERVER
|
||||||
|
sprite = new Sprite("", Vector2.Zero);
|
||||||
|
sprite.SourceRect = new Rectangle(0, 0, 32, 32);
|
||||||
|
#else
|
||||||
|
sprite = new Sprite(TextureLoader.PlaceHolderTexture, null, null)
|
||||||
|
{
|
||||||
|
Origin = TextureLoader.PlaceHolderTexture.Bounds.Size.ToVector2() / 2
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
size = sprite.size;
|
||||||
|
sprite.EntityID = identifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!category.HasFlag(MapEntityCategory.Legacy) && string.IsNullOrEmpty(identifier))
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError(
|
||||||
|
"Item prefab \"" + name + "\" has no identifier. All item prefabs have a unique identifier string that's used to differentiate between items during saving and loading.");
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(identifier))
|
||||||
|
{
|
||||||
|
MapEntityPrefab existingPrefab = List.Find(e => e.Identifier == identifier);
|
||||||
|
if (existingPrefab != null)
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError(
|
||||||
|
"Map entity prefabs \"" + name + "\" and \"" + existingPrefab.Name + "\" have the same identifier!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AllowedLinks = element.GetAttributeStringArray("allowedlinks", new string[0], convertToLowerInvariant: true).ToList();
|
||||||
|
|
||||||
List.Add(this);
|
List.Add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user