(b0f5305f2) Unstable v0.9.10.0
This commit is contained in:
@@ -559,7 +559,7 @@ namespace Barotrauma
|
||||
if (item.CurrentHull != hull) { continue; }
|
||||
if (AIObjectiveRepairItems.IsValidTarget(item, Character))
|
||||
{
|
||||
if (item.Repairables.All(r => item.ConditionPercentage > r.AIRepairThreshold)) { continue; }
|
||||
if (item.Repairables.All(r => item.ConditionPercentage > r.RepairThreshold)) { continue; }
|
||||
if (AddTargets<AIObjectiveRepairItems, Item>(Character, item) && newOrder == null && !ObjectiveManager.HasActiveObjective<AIObjectiveRepairItem>())
|
||||
{
|
||||
var orderPrefab = Order.GetPrefab("reportbrokendevices");
|
||||
@@ -609,9 +609,13 @@ namespace Barotrauma
|
||||
if (ObjectiveManager.CurrentObjective is AIObjectiveFightIntruders) { return; }
|
||||
if (attacker == null || attacker.IsDead || attacker.Removed)
|
||||
{
|
||||
// Don't react on the damage if there's no attacker.
|
||||
// We might consider launching the retreat combat objective in some cases, so that the bot does not just stand somewhere getting damaged and dying.
|
||||
// But fires and enemies should already be handled by the FindSafetyObjective.
|
||||
return;
|
||||
// Ignore damage from falling etc that we shouldn't react to.
|
||||
if (Character.LastDamageSource == null) { return; }
|
||||
AddCombatObjective(AIObjectiveCombat.CombatMode.Retreat, Rand.Range(0.5f, 1f, Rand.RandSync.Unsynced));
|
||||
//if (Character.LastDamageSource == null) { return; }
|
||||
//AddCombatObjective(AIObjectiveCombat.CombatMode.Retreat, Rand.Range(0.5f, 1f, Rand.RandSync.Unsynced));
|
||||
}
|
||||
else if (IsFriendly(attacker))
|
||||
{
|
||||
@@ -827,7 +831,7 @@ namespace Barotrauma
|
||||
if (item.CurrentHull != hull) { continue; }
|
||||
if (AIObjectiveRepairItems.IsValidTarget(item, character))
|
||||
{
|
||||
if (item.Repairables.All(r => item.ConditionPercentage >= r.AIRepairThreshold)) { continue; }
|
||||
if (item.Repairables.All(r => item.ConditionPercentage >= r.RepairThreshold)) { continue; }
|
||||
AddTargets<AIObjectiveRepairItems, Item>(character, item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -412,7 +412,11 @@ namespace Barotrauma
|
||||
{
|
||||
//the node we're heading towards is the last one in the path, and at a door
|
||||
//the door needs to be open for the character to reach the node
|
||||
shouldBeOpen = true;
|
||||
if (currentWaypoint.ConnectedDoor.LinkedGap != null && currentWaypoint.ConnectedDoor.LinkedGap.IsRoomToRoom)
|
||||
{
|
||||
shouldBeOpen = true;
|
||||
door = currentWaypoint.ConnectedDoor;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+7
-13
@@ -194,24 +194,18 @@ namespace Barotrauma
|
||||
{
|
||||
if (CurrentOrder != null)
|
||||
{
|
||||
#if DEBUG
|
||||
// Note: don't automatically remove orders here. Removing orders needs to be done via dismissing.
|
||||
if (CurrentOrder.IsCompleted)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.NewMessage($"{character.Name}: Removing order {CurrentOrder.DebugTag}, because it is completed.", Color.LightGreen);
|
||||
#endif
|
||||
CurrentOrder = null;
|
||||
DebugConsole.NewMessage($"{character.Name}: ORDER {CurrentOrder.DebugTag} IS COMPLETED. CURRENTLY ALL ORDERS SHOULD BE LOOPING.", Color.Red);
|
||||
}
|
||||
else if (!CurrentOrder.CanBeCompleted)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.NewMessage($"{character.Name}: Removing order {CurrentOrder.DebugTag}, because it cannot be completed.", Color.Red);
|
||||
DebugConsole.NewMessage($"{character.Name}: ORDER {CurrentOrder.DebugTag}, CANNOT BE COMPLETED.", Color.Red);
|
||||
}
|
||||
#endif
|
||||
CurrentOrder = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentOrder.Update(deltaTime);
|
||||
}
|
||||
CurrentOrder.Update(deltaTime);
|
||||
}
|
||||
if (WaitTimer > 0)
|
||||
{
|
||||
@@ -379,7 +373,7 @@ namespace Barotrauma
|
||||
newObjective = new AIObjectiveOperateItem(order.TargetItemComponent, character, this, option,
|
||||
requireEquip: false, useController: order.UseController, controller: order.ConnectedController, priorityModifier: priorityModifier)
|
||||
{
|
||||
IsLoop = option != "shutdown",
|
||||
IsLoop = true,
|
||||
// Don't override unless it's an order by a player
|
||||
Override = orderGiver != null && orderGiver.IsPlayer
|
||||
};
|
||||
|
||||
+27
-22
@@ -28,6 +28,7 @@ namespace Barotrauma
|
||||
public ItemComponent GetTarget() => useController ? controller : component;
|
||||
|
||||
public Func<bool> completionCondition;
|
||||
private bool isDoneOperating;
|
||||
|
||||
public override float GetPriority()
|
||||
{
|
||||
@@ -51,30 +52,34 @@ namespace Barotrauma
|
||||
if (targetItem == null)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError("Item or component of AI Objective Operate item wass null. This shouldn't happen.");
|
||||
DebugConsole.ThrowError("Item or component of AI Objective Operate item was null. This shouldn't happen.");
|
||||
#endif
|
||||
Abandon = true;
|
||||
Priority = 0;
|
||||
return Priority;
|
||||
}
|
||||
switch (Option)
|
||||
var reactor = component?.Item.GetComponent<Reactor>();
|
||||
if (reactor != null)
|
||||
{
|
||||
case "shutdown":
|
||||
var powered = component?.Item.GetComponent<Powered>();
|
||||
if (powered != null && !powered.IsActive)
|
||||
{
|
||||
Priority = 0;
|
||||
return Priority;
|
||||
}
|
||||
break;
|
||||
case "powerup":
|
||||
// Check that we don't already have another order that is targeting the same item.
|
||||
if (objectiveManager.CurrentOrder is AIObjectiveOperateItem operateOrder && operateOrder != this && operateOrder.GetTarget() == target)
|
||||
{
|
||||
Priority = 0;
|
||||
return Priority;
|
||||
}
|
||||
break;
|
||||
switch (Option)
|
||||
{
|
||||
case "shutdown":
|
||||
if (!reactor.PowerOn)
|
||||
{
|
||||
Priority = 0;
|
||||
return Priority;
|
||||
}
|
||||
break;
|
||||
case "powerup":
|
||||
// Check that we don't already have another order that is targeting the same item.
|
||||
// Without this the autonomous objective will tell the bot to turn the reactor on again.
|
||||
if (objectiveManager.CurrentOrder is AIObjectiveOperateItem operateOrder && operateOrder != this && operateOrder.GetTarget() == target)
|
||||
{
|
||||
Priority = 0;
|
||||
return Priority;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (targetItem.CurrentHull == null || targetItem.CurrentHull.FireSources.Any() || HumanAIController.IsItemOperatedByAnother(target, out _))
|
||||
{
|
||||
@@ -87,7 +92,7 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
float value = CumulatedDevotion + (AIObjectiveManager.OrderPriority * PriorityModifier);
|
||||
float max = objectiveManager.CurrentOrder == this ? MathHelper.Min(AIObjectiveManager.OrderPriority - 1, 90) : AIObjectiveManager.RunPriority - 1;
|
||||
float max = objectiveManager.CurrentOrder == this ? MathHelper.Min(AIObjectiveManager.OrderPriority, 90) : AIObjectiveManager.RunPriority - 1;
|
||||
Priority = MathHelper.Clamp(value, 0, max);
|
||||
}
|
||||
}
|
||||
@@ -148,7 +153,7 @@ namespace Barotrauma
|
||||
}
|
||||
if (component.AIOperate(deltaTime, character, this))
|
||||
{
|
||||
IsCompleted = completionCondition == null || completionCondition();
|
||||
isDoneOperating = completionCondition == null || completionCondition();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -215,12 +220,12 @@ namespace Barotrauma
|
||||
}
|
||||
if (component.AIOperate(deltaTime, character, this))
|
||||
{
|
||||
IsCompleted = completionCondition == null || completionCondition();
|
||||
isDoneOperating = completionCondition == null || completionCondition();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool Check() => IsCompleted && !IsLoop;
|
||||
protected override bool Check() => isDoneOperating && !IsLoop;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ namespace Barotrauma
|
||||
if (item != character.SelectedConstruction)
|
||||
{
|
||||
float condition = item.ConditionPercentage;
|
||||
if (item.Repairables.All(r => condition >= r.AIRepairThreshold)) { return false; }
|
||||
if (item.Repairables.All(r => condition >= r.RepairThreshold)) { return false; }
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(RelevantSkill))
|
||||
|
||||
+1
-1
@@ -279,7 +279,7 @@ namespace Barotrauma
|
||||
ic.PlaySound(ActionType.OnUse, character);
|
||||
#endif
|
||||
ic.WasUsed = true;
|
||||
ic.ApplyStatusEffects(ActionType.OnUse, 1.0f, targetCharacter, targetLimb);
|
||||
ic.ApplyStatusEffects(ActionType.OnUse, 1.0f, targetCharacter, targetLimb, user: character);
|
||||
if (ic.DeleteOnUse)
|
||||
{
|
||||
remove = true;
|
||||
|
||||
+5
-5
@@ -1713,7 +1713,7 @@ namespace Barotrauma
|
||||
|
||||
if (holdable.ControlPose)
|
||||
{
|
||||
head.body.SmoothRotate(itemAngle);
|
||||
head?.body.SmoothRotate(itemAngle);
|
||||
|
||||
if (TargetMovement == Vector2.Zero && inWater)
|
||||
{
|
||||
@@ -1735,13 +1735,13 @@ namespace Barotrauma
|
||||
{
|
||||
if (character.SelectedItems[0] == item)
|
||||
{
|
||||
if (rightHand.IsSevered) return;
|
||||
if (rightHand == null || rightHand.IsSevered) { return; }
|
||||
transformedHoldPos = rightHand.PullJointWorldAnchorA - transformedHandlePos[0];
|
||||
itemAngle = (rightHand.Rotation + (holdAngle - MathHelper.PiOver2) * Dir);
|
||||
}
|
||||
else if (character.SelectedItems[1] == item)
|
||||
{
|
||||
if (leftHand.IsSevered) return;
|
||||
if (leftHand == null || leftHand.IsSevered) { return; }
|
||||
transformedHoldPos = leftHand.PullJointWorldAnchorA - transformedHandlePos[1];
|
||||
itemAngle = (leftHand.Rotation + (holdAngle - MathHelper.PiOver2) * Dir);
|
||||
}
|
||||
@@ -1750,12 +1750,12 @@ namespace Barotrauma
|
||||
{
|
||||
if (character.SelectedItems[0] == item)
|
||||
{
|
||||
if (rightHand.IsSevered) return;
|
||||
if (rightHand == null || rightHand.IsSevered) { return; }
|
||||
rightHand.Disabled = true;
|
||||
}
|
||||
if (character.SelectedItems[1] == item)
|
||||
{
|
||||
if (leftHand.IsSevered) return;
|
||||
if (leftHand == null || leftHand.IsSevered) { return; }
|
||||
leftHand.Disabled = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -441,7 +441,7 @@ namespace Barotrauma
|
||||
{
|
||||
foreach (LimbJoint joint in LimbJoints)
|
||||
{
|
||||
if (GameMain.World.JointList.Contains(joint)) { GameMain.World.Remove(joint); }
|
||||
if (GameMain.World.JointList.Contains(joint.Joint)) { GameMain.World.Remove(joint.Joint); }
|
||||
}
|
||||
}
|
||||
DebugConsole.Log($"Creating joints from {RagdollParams.Name}.");
|
||||
@@ -526,7 +526,7 @@ namespace Barotrauma
|
||||
public void AddJoint(JointParams jointParams)
|
||||
{
|
||||
LimbJoint joint = new LimbJoint(Limbs[jointParams.Limb1], Limbs[jointParams.Limb2], jointParams, this);
|
||||
GameMain.World.Add(joint);
|
||||
GameMain.World.Add(joint.Joint);
|
||||
for (int i = 0; i < LimbJoints.Length; i++)
|
||||
{
|
||||
if (LimbJoints[i] != null) continue;
|
||||
@@ -609,7 +609,7 @@ namespace Barotrauma
|
||||
limb.Remove();
|
||||
foreach (LimbJoint limbJoint in attachedJoints)
|
||||
{
|
||||
GameMain.World.Remove(limbJoint);
|
||||
GameMain.World.Remove(limbJoint.Joint);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -726,7 +726,7 @@ namespace Barotrauma
|
||||
|
||||
private readonly List<Limb> connectedLimbs = new List<Limb>();
|
||||
private readonly List<LimbJoint> checkedJoints = new List<LimbJoint>();
|
||||
public bool SeverLimbJoint(LimbJoint limbJoint, bool playSound = true)
|
||||
public bool SeverLimbJoint(LimbJoint limbJoint)
|
||||
{
|
||||
if (!limbJoint.CanBeSevered || limbJoint.IsSevered)
|
||||
{
|
||||
@@ -750,6 +750,14 @@ namespace Barotrauma
|
||||
{
|
||||
if (connectedLimbs.Contains(limb)) { continue; }
|
||||
limb.IsSevered = true;
|
||||
if (limb.type == LimbType.RightHand)
|
||||
{
|
||||
character.SelectedItems[0]?.Drop(character);
|
||||
}
|
||||
else if (limb.type == LimbType.LeftHand)
|
||||
{
|
||||
character.SelectedItems[1]?.Drop(character);
|
||||
}
|
||||
}
|
||||
|
||||
SeverLimbJointProjSpecific(limbJoint, playSound: true);
|
||||
@@ -1776,11 +1784,12 @@ namespace Barotrauma
|
||||
|
||||
if (LimbJoints != null)
|
||||
{
|
||||
foreach (RevoluteJoint joint in LimbJoints)
|
||||
foreach (var joint in LimbJoints)
|
||||
{
|
||||
if (GameMain.World.JointList.Contains(joint))
|
||||
var j = joint.Joint;
|
||||
if (GameMain.World.JointList.Contains(j))
|
||||
{
|
||||
GameMain.World.Remove(joint);
|
||||
GameMain.World.Remove(j);
|
||||
}
|
||||
}
|
||||
LimbJoints = null;
|
||||
|
||||
@@ -1150,8 +1150,11 @@ namespace Barotrauma
|
||||
float reduction = 0;
|
||||
reduction = CalculateMovementPenalty(AnimController.GetLimb(LimbType.RightFoot, excludeSevered: false), reduction);
|
||||
reduction = CalculateMovementPenalty(AnimController.GetLimb(LimbType.LeftFoot, excludeSevered: false), reduction);
|
||||
reduction = CalculateMovementPenalty(AnimController.GetLimb(LimbType.RightHand, excludeSevered: false), reduction);
|
||||
reduction = CalculateMovementPenalty(AnimController.GetLimb(LimbType.LeftHand, excludeSevered: false), reduction);
|
||||
if (!(AnimController is HumanoidAnimController))
|
||||
{
|
||||
reduction = CalculateMovementPenalty(AnimController.GetLimb(LimbType.RightHand, excludeSevered: false), reduction);
|
||||
reduction = CalculateMovementPenalty(AnimController.GetLimb(LimbType.LeftHand, excludeSevered: false), reduction);
|
||||
}
|
||||
int totalTailLimbs = 0;
|
||||
int destroyedTailLimbs = 0;
|
||||
foreach (var limb in AnimController.Limbs)
|
||||
@@ -1176,7 +1179,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (limb != null)
|
||||
{
|
||||
sum += MathHelper.Lerp(0, max, CharacterHealth.GetLimbDamage(limb));
|
||||
sum += MathHelper.Lerp(0, max, CharacterHealth.GetLimbDamage(limb, afflictionType: "damage"));
|
||||
}
|
||||
return Math.Clamp(sum, 0, 1f);
|
||||
}
|
||||
@@ -2895,6 +2898,7 @@ namespace Barotrauma
|
||||
{
|
||||
SelectedConstruction = null;
|
||||
}
|
||||
HealthUpdateInterval = 0.0f;
|
||||
}
|
||||
|
||||
private readonly List<ISerializableEntity> targets = new List<ISerializableEntity>();
|
||||
@@ -2956,6 +2960,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
CharacterHealth.ApplyAffliction(null, new Affliction(AfflictionPrefab.Pressure, AfflictionPrefab.Pressure.MaxStrength));
|
||||
if (isNetworkMessage && GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient && Vitality <= CharacterHealth.MinVitality) { Kill(CauseOfDeathType.Pressure, null, isNetworkMessage: true); }
|
||||
if (IsDead)
|
||||
{
|
||||
BreakJoints();
|
||||
@@ -2988,7 +2993,10 @@ namespace Barotrauma
|
||||
|
||||
foreach (var joint in AnimController.LimbJoints)
|
||||
{
|
||||
joint.LimitEnabled = false;
|
||||
if (joint.revoluteJoint != null)
|
||||
{
|
||||
joint.revoluteJoint.LimitEnabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3055,9 +3063,12 @@ namespace Barotrauma
|
||||
|
||||
AnimController.ResetPullJoints();
|
||||
|
||||
foreach (RevoluteJoint joint in AnimController.LimbJoints)
|
||||
foreach (var joint in AnimController.LimbJoints)
|
||||
{
|
||||
joint.MotorEnabled = false;
|
||||
if (joint.revoluteJoint != null)
|
||||
{
|
||||
joint.revoluteJoint.MotorEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (GameMain.GameSession != null)
|
||||
@@ -3088,7 +3099,11 @@ namespace Barotrauma
|
||||
|
||||
foreach (LimbJoint joint in AnimController.LimbJoints)
|
||||
{
|
||||
joint.MotorEnabled = true;
|
||||
var revoluteJoint = joint.revoluteJoint;
|
||||
if (revoluteJoint != null)
|
||||
{
|
||||
revoluteJoint.MotorEnabled = true;
|
||||
}
|
||||
joint.Enabled = true;
|
||||
joint.IsSevered = false;
|
||||
}
|
||||
|
||||
@@ -252,8 +252,8 @@ namespace Barotrauma
|
||||
: afflictions.Where(limbHealthFilter).Union(limbHealths.SelectMany(lh => lh.Afflictions.Where(limbHealthFilter)));
|
||||
}
|
||||
|
||||
private LimbHealth GetMatchingLimbHealth(Limb limb) => limbHealths[limb.HealthIndex];
|
||||
private LimbHealth GetMatchingLimbHealth(Affliction affliction) => GetMatchingLimbHealth(Character.AnimController.GetLimb(affliction.Prefab.IndicatorLimb));
|
||||
private LimbHealth GetMatchingLimbHealth(Limb limb) => limb == null ? null : limbHealths[limb.HealthIndex];
|
||||
private LimbHealth GetMatchingLimbHealth(Affliction affliction) => GetMatchingLimbHealth(Character.AnimController.GetLimb(affliction.Prefab.IndicatorLimb, excludeSevered: false));
|
||||
|
||||
/// <summary>
|
||||
/// Returns the limb afflictions and non-limbspecific afflictions that are set to be displayed on this limb.
|
||||
@@ -515,7 +515,7 @@ namespace Barotrauma
|
||||
if (Vitality <= MinVitality) { Kill(); }
|
||||
}
|
||||
|
||||
public float GetLimbDamage(Limb limb)
|
||||
public float GetLimbDamage(Limb limb, string afflictionType = null)
|
||||
{
|
||||
float damageStrength;
|
||||
if (limb.IsSevered)
|
||||
@@ -528,10 +528,17 @@ namespace Barotrauma
|
||||
// Therefore with e.g. 80 health, the max damage per limb would be 20.
|
||||
// Having at least 20 damage on both legs would cause maximum limping.
|
||||
float max = MaxVitality / 4;
|
||||
float damage = GetAfflictionStrength("damage", limb, true);
|
||||
float bleeding = GetAfflictionStrength("bleeding", limb, true);
|
||||
float burn = GetAfflictionStrength("burn", limb, true);
|
||||
damageStrength = Math.Min(damage + bleeding + burn, max);
|
||||
if (string.IsNullOrEmpty(afflictionType))
|
||||
{
|
||||
float damage = GetAfflictionStrength("damage", limb, true);
|
||||
float bleeding = GetAfflictionStrength("bleeding", limb, true);
|
||||
float burn = GetAfflictionStrength("burn", limb, true);
|
||||
damageStrength = Math.Min(damage + bleeding + burn, max);
|
||||
}
|
||||
else
|
||||
{
|
||||
damageStrength = Math.Min(GetAfflictionStrength("damage", limb, true), max);
|
||||
}
|
||||
return damageStrength / max;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,6 +163,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
public Sprite Icon;
|
||||
public Sprite IconSmall;
|
||||
public string FilePath { get; private set; }
|
||||
|
||||
public XElement Element { get; private set; }
|
||||
@@ -207,6 +208,9 @@ namespace Barotrauma
|
||||
case "jobicon":
|
||||
Icon = new Sprite(subElement.FirstElement());
|
||||
break;
|
||||
case "jobiconsmall":
|
||||
IconSmall = new Sprite(subElement.FirstElement());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ namespace Barotrauma
|
||||
None, LeftHand, RightHand, LeftArm, RightArm, LeftForearm, RightForearm,
|
||||
LeftLeg, RightLeg, LeftFoot, RightFoot, Head, Torso, Tail, Legs, RightThigh, LeftThigh, Waist, Jaw
|
||||
};
|
||||
|
||||
partial class LimbJoint : RevoluteJoint
|
||||
|
||||
partial class LimbJoint
|
||||
{
|
||||
public bool IsSevered;
|
||||
public bool CanBeSevered => Params.CanBeSevered;
|
||||
@@ -30,27 +30,135 @@ namespace Barotrauma
|
||||
|
||||
public float Scale => Params.Scale * ragdoll.RagdollParams.JointScale;
|
||||
|
||||
public LimbJoint(Limb limbA, Limb limbB, JointParams jointParams, Ragdoll ragdoll) : this(limbA, limbB, Vector2.One, Vector2.One)
|
||||
public readonly RevoluteJoint revoluteJoint;
|
||||
public readonly WeldJoint weldJoint;
|
||||
public Joint Joint => revoluteJoint ?? weldJoint as Joint;
|
||||
|
||||
public bool Enabled
|
||||
{
|
||||
get => Joint.Enabled;
|
||||
set => Joint.Enabled = value;
|
||||
}
|
||||
|
||||
public Body BodyA => Joint.BodyA;
|
||||
|
||||
public Body BodyB => Joint.BodyB;
|
||||
|
||||
public Vector2 WorldAnchorA
|
||||
{
|
||||
get => Joint.WorldAnchorA;
|
||||
set => Joint.WorldAnchorA = value;
|
||||
}
|
||||
|
||||
public Vector2 WorldAnchorB
|
||||
{
|
||||
get => Joint.WorldAnchorB;
|
||||
set => Joint.WorldAnchorB = value;
|
||||
}
|
||||
|
||||
public Vector2 LocalAnchorA
|
||||
{
|
||||
get => revoluteJoint != null ? revoluteJoint.LocalAnchorA : weldJoint.LocalAnchorA;
|
||||
set
|
||||
{
|
||||
if (weldJoint != null)
|
||||
{
|
||||
weldJoint.LocalAnchorA = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
revoluteJoint.LocalAnchorA = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Vector2 LocalAnchorB
|
||||
{
|
||||
get => revoluteJoint != null ? revoluteJoint.LocalAnchorB : weldJoint.LocalAnchorB;
|
||||
set
|
||||
{
|
||||
if (weldJoint != null)
|
||||
{
|
||||
weldJoint.LocalAnchorB = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
revoluteJoint.LocalAnchorB = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool LimitEnabled
|
||||
{
|
||||
get => revoluteJoint != null ? revoluteJoint.LimitEnabled : false;
|
||||
set
|
||||
{
|
||||
if (revoluteJoint != null)
|
||||
{
|
||||
revoluteJoint.LimitEnabled = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float LowerLimit
|
||||
{
|
||||
get => revoluteJoint != null ? revoluteJoint.LowerLimit : 0;
|
||||
set
|
||||
{
|
||||
if (revoluteJoint != null)
|
||||
{
|
||||
revoluteJoint.LowerLimit = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float UpperLimit
|
||||
{
|
||||
get => revoluteJoint != null ? revoluteJoint.UpperLimit : 0;
|
||||
set
|
||||
{
|
||||
if (revoluteJoint != null)
|
||||
{
|
||||
revoluteJoint.UpperLimit = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float JointAngle => revoluteJoint != null ? revoluteJoint.JointAngle : weldJoint.ReferenceAngle;
|
||||
|
||||
public LimbJoint(Limb limbA, Limb limbB, JointParams jointParams, Ragdoll ragdoll) : this(limbA, limbB, Vector2.One, Vector2.One, jointParams.WeldJoint)
|
||||
{
|
||||
Params = jointParams;
|
||||
this.ragdoll = ragdoll;
|
||||
LoadParams();
|
||||
}
|
||||
|
||||
public LimbJoint(Limb limbA, Limb limbB, Vector2 anchor1, Vector2 anchor2)
|
||||
: base(limbA.body.FarseerBody, limbB.body.FarseerBody, anchor1, anchor2)
|
||||
public LimbJoint(Limb limbA, Limb limbB, Vector2 anchor1, Vector2 anchor2, bool weld = false)
|
||||
{
|
||||
CollideConnected = false;
|
||||
MotorEnabled = true;
|
||||
MaxMotorTorque = 0.25f;
|
||||
if (weld)
|
||||
{
|
||||
weldJoint = new WeldJoint(limbA.body.FarseerBody, limbB.body.FarseerBody, anchor1, anchor2);
|
||||
}
|
||||
else
|
||||
{
|
||||
revoluteJoint = new RevoluteJoint(limbA.body.FarseerBody, limbB.body.FarseerBody, anchor1, anchor2)
|
||||
{
|
||||
MotorEnabled = true,
|
||||
MaxMotorTorque = 0.25f
|
||||
};
|
||||
}
|
||||
Joint.CollideConnected = false;
|
||||
LimbA = limbA;
|
||||
LimbB = limbB;
|
||||
}
|
||||
|
||||
public void LoadParams()
|
||||
{
|
||||
MaxMotorTorque = Params.Stiffness;
|
||||
LimitEnabled = Params.LimitEnabled;
|
||||
if (revoluteJoint != null)
|
||||
{
|
||||
revoluteJoint.MaxMotorTorque = Params.Stiffness;
|
||||
revoluteJoint.LimitEnabled = Params.LimitEnabled;
|
||||
}
|
||||
if (float.IsNaN(Params.LowerLimit))
|
||||
{
|
||||
Params.LowerLimit = 0;
|
||||
@@ -61,17 +169,33 @@ namespace Barotrauma
|
||||
}
|
||||
if (ragdoll.IsFlipped)
|
||||
{
|
||||
LocalAnchorA = ConvertUnits.ToSimUnits(new Vector2(-Params.Limb1Anchor.X, Params.Limb1Anchor.Y) * Scale);
|
||||
LocalAnchorB = ConvertUnits.ToSimUnits(new Vector2(-Params.Limb2Anchor.X, Params.Limb2Anchor.Y) * Scale);
|
||||
UpperLimit = MathHelper.ToRadians(-Params.LowerLimit);
|
||||
LowerLimit = MathHelper.ToRadians(-Params.UpperLimit);
|
||||
if (weldJoint != null)
|
||||
{
|
||||
weldJoint.LocalAnchorA = ConvertUnits.ToSimUnits(new Vector2(-Params.Limb1Anchor.X, Params.Limb1Anchor.Y) * Scale);
|
||||
weldJoint.LocalAnchorB = ConvertUnits.ToSimUnits(new Vector2(-Params.Limb2Anchor.X, Params.Limb2Anchor.Y) * Scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
revoluteJoint.LocalAnchorA = ConvertUnits.ToSimUnits(new Vector2(-Params.Limb1Anchor.X, Params.Limb1Anchor.Y) * Scale);
|
||||
revoluteJoint.LocalAnchorB = ConvertUnits.ToSimUnits(new Vector2(-Params.Limb2Anchor.X, Params.Limb2Anchor.Y) * Scale);
|
||||
revoluteJoint.UpperLimit = MathHelper.ToRadians(-Params.LowerLimit);
|
||||
revoluteJoint.LowerLimit = MathHelper.ToRadians(-Params.UpperLimit);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LocalAnchorA = ConvertUnits.ToSimUnits(Params.Limb1Anchor * Scale);
|
||||
LocalAnchorB = ConvertUnits.ToSimUnits(Params.Limb2Anchor * Scale);
|
||||
UpperLimit = MathHelper.ToRadians(Params.UpperLimit);
|
||||
LowerLimit = MathHelper.ToRadians(Params.LowerLimit);
|
||||
if (weldJoint != null)
|
||||
{
|
||||
weldJoint.LocalAnchorA = ConvertUnits.ToSimUnits(Params.Limb1Anchor * Scale);
|
||||
weldJoint.LocalAnchorB = ConvertUnits.ToSimUnits(Params.Limb2Anchor * Scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
revoluteJoint.LocalAnchorA = ConvertUnits.ToSimUnits(Params.Limb1Anchor * Scale);
|
||||
revoluteJoint.LocalAnchorB = ConvertUnits.ToSimUnits(Params.Limb2Anchor * Scale);
|
||||
revoluteJoint.UpperLimit = MathHelper.ToRadians(Params.UpperLimit);
|
||||
revoluteJoint.LowerLimit = MathHelper.ToRadians(Params.LowerLimit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -470,7 +470,7 @@ namespace Barotrauma
|
||||
[Serialize(true, true), Editable]
|
||||
public bool CanBeSevered { get; set; }
|
||||
|
||||
[Serialize(1f, true, description:"Modifies the severance probability (defined per item/attack) when the character is alive. Currently only affects limbs of type None, Shield, or Tail on non-humanoid ragdolls. Also note that if CanBeSevered is false, this property doesn't have any effect."), Editable(MinValueFloat = 0, MaxValueFloat = 10, ValueStep = 0.1f, DecimalCount = 2)]
|
||||
[Serialize(0f, true, description:"Default 0 (Can't be severed when the creature is alive). Modifies the severance probability (defined per item/attack) when the character is alive. Currently only affects non-humanoid ragdolls. Also note that if CanBeSevered is false, this property doesn't have any effect."), Editable(MinValueFloat = 0, MaxValueFloat = 10, ValueStep = 0.1f, DecimalCount = 2)]
|
||||
public float SeveranceProbabilityModifier { get; set; }
|
||||
|
||||
[Serialize("gore", true), Editable]
|
||||
@@ -497,6 +497,9 @@ namespace Barotrauma
|
||||
[Serialize(1f, true, description: "CAUTION: Not fully implemented. Only use for limb joints that connect non-animated limbs!"), Editable]
|
||||
public float Scale { get; set; }
|
||||
|
||||
[Serialize(false, false), Editable(ReadOnly = true)]
|
||||
public bool WeldJoint { get; set; }
|
||||
|
||||
public JointParams(XElement element, RagdollParams ragdoll) : base(element, ragdoll) { }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user