(38b5d9aad) Experimental changes to syncing ragdolled (unconscious/dead) characters: - Higher error tolerance when syncing the positions. It's often hard to get the main limb exactly to the same position as the collider, because the positions of the limbs aren't synced and the pose of the ragdoll may differ between the server and clients. Increasing the tolerance makes it less likely for dead/unconscious characters to "twitch" when the game attempts to force the main limb to the position of the collider. - If the position of the ragdoll differs from the position of the collider so much that CheckDistFromCollider disables limb collisions, apply an additional force to all limbs to force the ragdoll to the correct position. Otherwise the ragdoll can occasionally start "hanging" midair, clipping through solid objects, because the main limb's pull joint doesn't necessarily have enough force to pull the entire ragdoll up to the collider.
This commit is contained in:
@@ -118,19 +118,6 @@ namespace Barotrauma
|
||||
instance = this;
|
||||
}
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
AnimParams.ForEach(a => a.Reset(true));
|
||||
RagdollParams.Reset(true);
|
||||
RagdollParams.ClearHistory();
|
||||
CurrentAnimation.ClearHistory();
|
||||
if (!character.Removed)
|
||||
{
|
||||
character.Remove();
|
||||
}
|
||||
character = null;
|
||||
}
|
||||
|
||||
public override void Deselect()
|
||||
{
|
||||
base.Deselect();
|
||||
@@ -141,7 +128,15 @@ namespace Barotrauma
|
||||
isEndlessRunner = false;
|
||||
if (character != null)
|
||||
{
|
||||
Reset();
|
||||
AnimParams.ForEach(a => a.Reset(true));
|
||||
RagdollParams.Reset(true);
|
||||
RagdollParams.ClearHistory();
|
||||
CurrentAnimation.ClearHistory();
|
||||
if (!character.Removed)
|
||||
{
|
||||
character.Remove();
|
||||
}
|
||||
character = null;
|
||||
}
|
||||
GameMain.World.ProcessChanges();
|
||||
}
|
||||
@@ -398,12 +393,6 @@ namespace Barotrauma
|
||||
}
|
||||
if (!isFreezed)
|
||||
{
|
||||
if (character.AnimController.Invalid)
|
||||
{
|
||||
Reset();
|
||||
SpawnCharacter(currentCharacterConfig);
|
||||
}
|
||||
|
||||
Submarine.MainSub.SetPrevTransform(Submarine.MainSub.Position);
|
||||
Submarine.MainSub.Update((float)deltaTime);
|
||||
|
||||
@@ -1226,7 +1215,7 @@ namespace Barotrauma
|
||||
Cam.Position = character.WorldPosition;
|
||||
}
|
||||
|
||||
private bool CreateCharacter(string name, string mainFolder, bool isHumanoid, params object[] ragdollConfig)
|
||||
private bool CreateCharacter(string name, bool isHumanoid, params object[] ragdollConfig)
|
||||
{
|
||||
var contentPackage = GameMain.Config.SelectedContentPackages.LastOrDefault();
|
||||
if (contentPackage == null)
|
||||
@@ -1239,22 +1228,23 @@ namespace Barotrauma
|
||||
#if !DEBUG
|
||||
if (vanilla != null && contentPackage == vanilla)
|
||||
{
|
||||
GUI.AddMessage(GetCharacterEditorTranslation("CannotEditVanillaCharacters"), Color.Red, font: GUI.LargeFont);
|
||||
GUI.AddMessage($"Cannot edit the Vanilla content!", Color.Red, font: GUI.LargeFont);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
string speciesName = name;
|
||||
string mainFolder = $"Content/Characters/{speciesName}";
|
||||
// Config file
|
||||
string configFilePath = Path.Combine(mainFolder, $"{speciesName}.xml").Replace(@"\", @"/");
|
||||
string configFilePath = $"{mainFolder}/{speciesName}.xml";
|
||||
if (ContentPackage.GetFilesOfType(GameMain.SelectedPackages, ContentType.Character).None(path => path.Contains(speciesName)))
|
||||
{
|
||||
// Create the config file
|
||||
XElement mainElement = new XElement("Character",
|
||||
new XAttribute("name", speciesName),
|
||||
new XAttribute("humanoid", isHumanoid),
|
||||
new XElement("ragdolls", new XAttribute("folder", Path.Combine(mainFolder, $"Ragdolls/").Replace(@"\", @"/"))),
|
||||
new XElement("animations", new XAttribute("folder", Path.Combine(mainFolder, $"Animations/").Replace(@"\", @"/"))),
|
||||
new XElement("ragdolls"),
|
||||
new XElement("animations"),
|
||||
new XElement("health"),
|
||||
new XElement("ai"));
|
||||
XDocument doc = new XDocument(mainElement);
|
||||
@@ -1269,13 +1259,13 @@ namespace Barotrauma
|
||||
DebugConsole.NewMessage(GetCharacterEditorTranslation("ContentPackageSaved").Replace("[path]", contentPackage.Path));
|
||||
}
|
||||
// Ragdoll
|
||||
string ragdollFolder = RagdollParams.GetFolder(speciesName);
|
||||
string ragdollFolder = RagdollParams.GetDefaultFolder(speciesName);
|
||||
string ragdollPath = RagdollParams.GetDefaultFile(speciesName);
|
||||
RagdollParams ragdollParams = isHumanoid
|
||||
? RagdollParams.CreateDefault<HumanRagdollParams>(ragdollPath, speciesName, ragdollConfig)
|
||||
: RagdollParams.CreateDefault<FishRagdollParams>(ragdollPath, speciesName, ragdollConfig) as RagdollParams;
|
||||
// Animations
|
||||
string animFolder = AnimationParams.GetFolder(speciesName);
|
||||
string animFolder = AnimationParams.GetDefaultFolder(speciesName);
|
||||
foreach (AnimationType animType in Enum.GetValues(typeof(AnimationType)))
|
||||
{
|
||||
if (animType != AnimationType.NotDefined)
|
||||
@@ -1879,7 +1869,7 @@ namespace Barotrauma
|
||||
#if !DEBUG
|
||||
if (VanillaCharacters != null && VanillaCharacters.Contains(currentCharacterConfig))
|
||||
{
|
||||
GUI.AddMessage(GetCharacterEditorTranslation("CannotEditVanillaCharacters"), Color.Red, font: GUI.LargeFont);
|
||||
GUI.AddMessage(GetCharacterEditorTranslation("CantEditVanillaContent"), Color.Red, font: GUI.LargeFont);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@@ -1894,7 +1884,7 @@ namespace Barotrauma
|
||||
#if !DEBUG
|
||||
if (VanillaCharacters != null && VanillaCharacters.Contains(currentCharacterConfig))
|
||||
{
|
||||
GUI.AddMessage(GetCharacterEditorTranslation("CannotEditVanillaCharacters"), Color.Red, font: GUI.LargeFont);
|
||||
GUI.AddMessage(GetCharacterEditorTranslation("CantEditVanillaContent"), Color.Red, font: GUI.LargeFont);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@@ -1966,7 +1956,7 @@ namespace Barotrauma
|
||||
#if !DEBUG
|
||||
if (VanillaCharacters != null && VanillaCharacters.Contains(currentCharacterConfig))
|
||||
{
|
||||
GUI.AddMessage(GetCharacterEditorTranslation("CannotEditVanillaCharacters"), Color.Red, font: GUI.LargeFont);
|
||||
GUI.AddMessage(GetCharacterEditorTranslation("CantEditVanillaContent"), Color.Red, font: GUI.LargeFont);
|
||||
box.Close();
|
||||
return false;
|
||||
}
|
||||
@@ -2099,7 +2089,7 @@ namespace Barotrauma
|
||||
#if !DEBUG
|
||||
if (VanillaCharacters != null && VanillaCharacters.Contains(currentCharacterConfig))
|
||||
{
|
||||
GUI.AddMessage(GetCharacterEditorTranslation("CannotEditVanillaCharacters"), Color.Red, font: GUI.LargeFont);
|
||||
GUI.AddMessage(GetCharacterEditorTranslation("CantEditVanillaContent"), Color.Red, font: GUI.LargeFont);
|
||||
box.Close();
|
||||
return false;
|
||||
}
|
||||
@@ -3928,7 +3918,7 @@ namespace Barotrauma
|
||||
|
||||
private void DrawJointLimitWidgets(SpriteBatch spriteBatch, Limb limb, LimbJoint joint, Vector2 drawPos, bool autoFreeze, bool allowPairEditing, float rotationOffset = 0)
|
||||
{
|
||||
rotationOffset += MathHelper.ToRadians(RagdollParams.SpritesheetOrientation);
|
||||
rotationOffset -= MathHelper.ToRadians(RagdollParams.SpritesheetOrientation);
|
||||
Color angleColor = joint.UpperLimit - joint.LowerLimit > 0 ? Color.LightGreen * 0.5f : Color.Red;
|
||||
DrawRadialWidget(spriteBatch, drawPos, MathHelper.ToDegrees(joint.UpperLimit), $"joint.jointParams.Name {GetCharacterEditorTranslation("UpperLimit")}", Color.Cyan, angle =>
|
||||
{
|
||||
@@ -4662,7 +4652,7 @@ namespace Barotrauma
|
||||
LimbXElements.Values,
|
||||
JointXElements
|
||||
};
|
||||
if (CharacterEditorScreen.instance.CreateCharacter(Name, Path.GetDirectoryName(XMLPath), IsHumanoid, ragdollParams))
|
||||
if (CharacterEditorScreen.instance.CreateCharacter(Name, IsHumanoid, ragdollParams))
|
||||
{
|
||||
GUI.AddMessage(GetCharacterEditorTranslation("CharacterCreated").Replace("[name]", Name), Color.Green, font: GUI.Font);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user