diff --git a/Barotrauma/BarotraumaClient/Source/Characters/Animation/Ragdoll.cs b/Barotrauma/BarotraumaClient/Source/Characters/Animation/Ragdoll.cs index fa30d8a82..8f9276859 100644 --- a/Barotrauma/BarotraumaClient/Source/Characters/Animation/Ragdoll.cs +++ b/Barotrauma/BarotraumaClient/Source/Characters/Animation/Ragdoll.cs @@ -121,90 +121,7 @@ namespace Barotrauma MainLimb.PullJointWorldAnchorB = Collider.SimPosition; MainLimb.PullJointEnabled = true; } - character.SelectedConstruction = character.MemState[0].SelectedItem; } - - if (character.MemState[0].Animation == AnimController.Animation.CPR) - { - character.AnimController.Anim = AnimController.Animation.CPR; - } - else if (character.AnimController.Anim == AnimController.Animation.CPR) - { - character.AnimController.Anim = AnimController.Animation.None; - } - - Vector2 newVelocity = Collider.LinearVelocity; - Vector2 newPosition = Collider.SimPosition; - float newRotation = Collider.Rotation; - float newAngularVelocity = Collider.AngularVelocity; - Collider.CorrectPosition(character.MemState, out newPosition, out newVelocity, out newRotation, out newAngularVelocity); - - newVelocity = newVelocity.ClampLength(100.0f); - if (!MathUtils.IsValid(newVelocity)) { newVelocity = Vector2.Zero; } - overrideTargetMovement = newVelocity.LengthSquared() > 0.01f ? newVelocity : Vector2.Zero; - - Collider.LinearVelocity = newVelocity; - Collider.AngularVelocity = newAngularVelocity; - - float distSqrd = Vector2.DistanceSquared(newPosition, Collider.SimPosition); - float errorTolerance = character.AllowInput ? 0.01f : 0.2f; - if (distSqrd > errorTolerance) - { - if (distSqrd > 10.0f || !character.AllowInput) - { - Collider.TargetRotation = newRotation; - SetPosition(newPosition, lerp: distSqrd < 5.0f, ignorePlatforms: false); - } - else - { - Collider.TargetRotation = newRotation; - Collider.TargetPosition = newPosition; - Collider.MoveToTargetPosition(true); - } - } - - //unconscious/dead characters can't correct their position using AnimController movement - // -> we need to correct it manually - if (!character.AllowInput) - { - float mainLimbDistSqrd = Vector2.DistanceSquared(MainLimb.PullJointWorldAnchorA, Collider.SimPosition); - 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(); - } - else - { - //remove states with a timestamp (there may still timestamp-based states - //in the list if the controlled character switches from timestamp-based interpolation to ID-based) - character.MemState.RemoveAll(m => m.Timestamp > 0.0f); - - for (int i = 0; i < character.MemLocalState.Count; i++) - { - if (character.Submarine == null) - { - //transform in-sub coordinates to outside coordinates - if (character.MemLocalState[i].Position.Y > lowestSubPos) - { - character.MemLocalState[i].TransformInToOutside(); - } - } - else if (currentHull?.Submarine != null) - { - //transform outside coordinates to in-sub coordinates - if (character.MemLocalState[i].Position.Y < lowestSubPos) - { - character.MemLocalState[i].TransformOutToInside(currentHull.Submarine); - } - } - } character.MemLocalState.Clear(); } diff --git a/Barotrauma/BarotraumaClient/Source/Screens/CampaignSetupUI.cs b/Barotrauma/BarotraumaClient/Source/Screens/CampaignSetupUI.cs index ae68df8b2..e032b3a6a 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/CampaignSetupUI.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/CampaignSetupUI.cs @@ -742,6 +742,8 @@ namespace Barotrauma private GUILayoutGroup subPreviewContainer; + private GUILayoutGroup subPreviewContainer; + private GUIButton loadGameButton; public Action StartNewGame; diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs index 9480314fe..9213ee490 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs @@ -142,7 +142,7 @@ namespace Barotrauma bool run = objectiveManager.CurrentObjective.ForceRun || objectiveManager.GetCurrentPriority() > AIObjectiveManager.RunPriority; if (ObjectiveManager.CurrentObjective is AIObjectiveGoTo goTo && goTo.Target != null) { - run = Vector2.DistanceSquared(Character.SimPosition, goTo.Target.SimPosition) > 3 * 3; + run = Vector2.DistanceSquared(Character.WorldPosition, goTo.Target.WorldPosition) > 300 * 300; } if (run) { diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveCombat.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveCombat.cs index 49755942c..1c8d8a22a 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveCombat.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveCombat.cs @@ -349,8 +349,8 @@ namespace Barotrauma { followTargetObjective.CloseEnough = WeaponComponent is RangedWeapon ? 3 : - WeaponComponent is MeleeWeapon mw ? ConvertUnits.ToSimUnits(mw.Range) : - WeaponComponent is RepairTool rt ? ConvertUnits.ToSimUnits(rt.Range) : 0.5f; + WeaponComponent is MeleeWeapon mw ? mw.Range : + WeaponComponent is RepairTool rt ? rt.Range : 50; } } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveExtinguishFire.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveExtinguishFire.cs index 62d4653f3..d60f7926b 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveExtinguishFire.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveExtinguishFire.cs @@ -118,7 +118,7 @@ namespace Barotrauma if (move) { //go to the first firesource - TryAddSubObjective(ref gotoObjective, () => new AIObjectiveGoTo(ConvertUnits.ToSimUnits(fs.Position), character, objectiveManager)); + TryAddSubObjective(ref gotoObjective, () => new AIObjectiveGoTo(fs, character, objectiveManager)); } break; } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFixLeak.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFixLeak.cs index dfc6fdf8b..39f56cfa0 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFixLeak.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFixLeak.cs @@ -719,22 +719,36 @@ namespace Barotrauma { TryAddSubObjective(ref gotoObjective, () => new AIObjectiveGoTo(ConvertUnits.ToSimUnits(GetStandPosition()), character, objectiveManager) { CloseEnough = reach * 0.75f }); } - } - - private Vector2 GetStandPosition() - { - Vector2 standPos = Leak.Position; - var hull = Leak.FlowTargetHull; - if (hull == null) { return standPos; } - if (Leak.IsHorizontal) + if (subObjectives.Any()) { return; } + var repairTool = weldingTool.GetComponent(); + if (repairTool == null) { - standPos += Vector2.UnitX * Math.Sign(hull.Position.X - Leak.Position.X) * Leak.Rect.Width; +#if DEBUG + DebugConsole.ThrowError("AIObjectiveFixLeak failed - the item \"" + weldingTool + "\" has no RepairTool component but is tagged as a welding tool"); +#endif + abandon = true; + return; + } + Vector2 gapDiff = Leak.WorldPosition - character.WorldPosition; + // TODO: use the collider size/reach? + if (!character.AnimController.InWater && Math.Abs(gapDiff.X) < 100 && gapDiff.Y < 0.0f && gapDiff.Y > -150) + { + HumanAIController.AnimController.Crouching = true; + } + // Use a greater reach, because the distance is calculated from the character to the leak, not from the item to the leak. + float reach = repairTool.Range + ((HumanoidAnimController)character.AnimController).ArmLength; + bool canOperate = gapDiff.LengthSquared() < reach * reach; + if (canOperate) + { + TryAddSubObjective(ref operateObjective, () => new AIObjectiveOperateItem(repairTool, character, objectiveManager, option: "", requireEquip: true, operateTarget: Leak)); } else { - standPos += Vector2.UnitY * Math.Sign(hull.Position.Y - Leak.Position.Y) * Leak.Rect.Height; + TryAddSubObjective(ref gotoObjective, () => new AIObjectiveGoTo(Leak, character, objectiveManager) + { + CloseEnough = reach + }); } - return standPos; } } } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFixLeaks.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFixLeaks.cs index 1ba96d4e4..255cc6c3b 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFixLeaks.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveFixLeaks.cs @@ -20,8 +20,16 @@ namespace Barotrauma if (leak == null) { return 0; } float sizeFactor = MathHelper.Lerp(1, 10, MathUtils.InverseLerp(0, 200, (leak.IsHorizontal ? leak.Rect.Width : leak.Rect.Height))); float severity = sizeFactor * leak.Open; - if (!leak.IsRoomToRoom) { severity *= 50; } - return MathHelper.Min(severity, 100); + if (!leak.IsRoomToRoom) + { + severity *= 100; + // If there is a leak in the outer walls, the severity cannot be lower than 10, no matter how small the leak + return MathHelper.Clamp(severity, 10, 100); + } + else + { + return MathHelper.Min(severity, 100); + } } public override bool IsDuplicate(AIObjective otherObjective) => otherObjective is AIObjectiveFixLeaks; diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveGoTo.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveGoTo.cs index d3af1b170..d63ba2cf3 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveGoTo.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveGoTo.cs @@ -10,7 +10,6 @@ namespace Barotrauma public override string DebugTag => "go to"; private AIObjectiveFindDivingGear findDivingGear; - private Vector2 targetPos; private bool repeat; //how long until the path to the target is declared unreachable private float waitUntilPathUnreachable; @@ -19,9 +18,9 @@ namespace Barotrauma public Func customCondition; /// - /// Sim units + /// Display units /// - public float CloseEnough { get; set; } = 0.5f; + public float CloseEnough { get; set; } = 50; public bool IgnoreIfTargetDead { get; set; } public bool AllowGoingOutside { get; set; } public bool CheckVisibility { get; set; } @@ -29,7 +28,7 @@ namespace Barotrauma public override float GetPriority() { if (FollowControlledCharacter && Character.Controlled == null) { return 0.0f; } - if (Target != null && Target.Removed) { return 0.0f; } + if (Target is Entity e && e.Removed) { return 0.0f; } if (IgnoreIfTargetDead && Target is Character character && character.IsDead) { return 0.0f; } if (objectiveManager.CurrentOrder == this) { @@ -38,35 +37,20 @@ namespace Barotrauma return 1.0f; } - public Entity Target { get; private set; } - - public Vector2 TargetPos => Target != null ? Target.SimPosition : targetPos; + public ISpatialEntity Target { get; private set; } public bool FollowControlledCharacter; - public AIObjectiveGoTo(Entity target, Character character, AIObjectiveManager objectiveManager, bool repeat = false, bool getDivingGearIfNeeded = true, float priorityModifier = 1) + public AIObjectiveGoTo(ISpatialEntity target, Character character, AIObjectiveManager objectiveManager, bool repeat = false, bool getDivingGearIfNeeded = true, float priorityModifier = 1) : base (character, objectiveManager, priorityModifier) { this.Target = target; this.repeat = repeat; - waitUntilPathUnreachable = 2.0f; this.getDivingGearIfNeeded = getDivingGearIfNeeded; CalculateCloseEnough(); } - - public AIObjectiveGoTo(Vector2 simPos, Character character, AIObjectiveManager objectiveManager, bool repeat = false, bool getDivingGearIfNeeded = true, float priorityModifier = 1) - : base(character, objectiveManager, priorityModifier) - { - this.targetPos = simPos; - this.repeat = repeat; - - waitUntilPathUnreachable = 5.0f; - this.getDivingGearIfNeeded = getDivingGearIfNeeded; - CalculateCloseEnough(); - } - protected override void Act(float deltaTime) { if (FollowControlledCharacter) @@ -89,90 +73,69 @@ namespace Barotrauma { character.SelectedConstruction = null; } - if (Target != null) + if (Target is Entity e) { - if (Target.Removed) + if (e.Removed) { abandon = true; } else { - character.AIController.SelectTarget(Target.AiTarget); + character.AIController.SelectTarget(e.AiTarget); } } - Vector2 currTargetPos = Vector2.Zero; - if (Target == null) + bool isInside = character.CurrentHull != null; + bool insideSteering = SteeringManager == PathSteering && PathSteering.CurrentPath != null && !PathSteering.IsPathDirty; + var targetHull = Target is Hull h ? h : Target is Item i ? i.CurrentHull : Target is Character c ? c.CurrentHull : character.CurrentHull; + bool targetIsOutside = (Target != null && targetHull == null) || (insideSteering && PathSteering.CurrentPath.HasOutdoorsNodes); + if (isInside && targetIsOutside && !AllowGoingOutside) { - currTargetPos = targetPos; + abandon = true; + } + else if (!repeat && waitUntilPathUnreachable < 0) + { + if (SteeringManager == PathSteering && PathSteering.CurrentPath != null) + { + abandon = PathSteering.CurrentPath.Unreachable; + } + } + if (abandon) + { +#if DEBUG + DebugConsole.NewMessage($"{character.Name}: Cannot reach the target: {Target.ToString()}", Color.Yellow); +#endif + if (objectiveManager.CurrentOrder != null) + { + character.Speak(TextManager.Get("DialogCannotReach"), identifier: "cannotreach", minDurationBetweenSimilar: 10.0f); + } + character.AIController.SteeringManager.Reset(); } else { - currTargetPos = Target.SimPosition; - + Vector2 currTargetSimPos = Vector2.Zero; + currTargetSimPos = Target.SimPosition; //if character is inside the sub and target isn't, transform the position if (character.Submarine != null && Target.Submarine == null) { - currTargetPos -= character.Submarine.SimPosition; + currTargetSimPos -= character.Submarine.SimPosition; } - } - bool sightCheck = true; - if (CheckVisibility && Target != null) - { - sightCheck = Target is Character ch ? character.CanSeeCharacter(ch) : character.CanSeeTarget(Target); - } - if (sightCheck && Vector2.DistanceSquared(currTargetPos, character.SimPosition) < CloseEnough * CloseEnough) - { - character.AIController.SteeringManager.Reset(); - character.AnimController.TargetDir = currTargetPos.X > character.SimPosition.X ? Direction.Right : Direction.Left; - } - else - { - bool isInside = character.CurrentHull != null; - bool insideSteering = SteeringManager == PathSteering && PathSteering.CurrentPath != null && !PathSteering.IsPathDirty; - var targetHull = Target is Hull h ? h : Target is Item i ? i.CurrentHull : Target is Character c ? c.CurrentHull : character.CurrentHull; - bool targetIsOutside = (Target != null && targetHull == null) || (insideSteering && PathSteering.CurrentPath.HasOutdoorsNodes); - if (isInside && targetIsOutside && !AllowGoingOutside) + character.AIController.SteeringManager.SteeringSeek(currTargetSimPos); + if (getDivingGearIfNeeded) { - abandon = true; - } - else if (!repeat && waitUntilPathUnreachable < 0) - { - if (SteeringManager == PathSteering && PathSteering.CurrentPath != null) + bool needsDivingGear = HumanAIController.NeedsDivingGear(targetHull); + bool needsDivingSuit = needsDivingGear && (targetHull == null || targetIsOutside || targetHull.WaterPercentage > 90); + bool needsEquipment = false; + if (needsDivingSuit) { - abandon = PathSteering.CurrentPath.Unreachable; + needsEquipment = !HumanAIController.HasDivingSuit(character); } - } - if (abandon) - { -#if DEBUG - DebugConsole.NewMessage($"{character.Name}: Cannot reach the target: {(Target != null ? Target.ToString() : TargetPos.ToString())}", Color.Yellow); -#endif - if (objectiveManager.CurrentOrder != null) + else if (needsDivingGear) { - character.Speak(TextManager.Get("DialogCannotReach"), identifier: "cannotreach", minDurationBetweenSimilar: 10.0f); + needsEquipment = !HumanAIController.HasDivingMask(character); } - character.AIController.SteeringManager.Reset(); - } - else - { - character.AIController.SteeringManager.SteeringSeek(currTargetPos); - if (getDivingGearIfNeeded) + if (needsEquipment) { - bool needsDivingGear = HumanAIController.NeedsDivingGear(targetHull); - bool needsDivingSuit = needsDivingGear && (targetHull == null || targetIsOutside || targetHull.WaterPercentage > 90); - bool needsEquipment = false; - if (needsDivingSuit) - { - needsEquipment = !HumanAIController.HasDivingSuit(character); - } - else if (needsDivingGear) - { - needsEquipment = !HumanAIController.HasDivingMask(character); - } - if (needsEquipment) - { - TryAddSubObjective(ref findDivingGear, () => new AIObjectiveFindDivingGear(character, needsDivingSuit, objectiveManager)); - } + TryAddSubObjective(ref findDivingGear, () => new AIObjectiveFindDivingGear(character, needsDivingSuit, objectiveManager)); } } } @@ -186,7 +149,12 @@ namespace Barotrauma // And finally check if can interact (heaviest) if (repeat) { return false; } if (isCompleted) { return true; } - bool closeEnough = Vector2.DistanceSquared(Target != null ? Target.SimPosition : targetPos, character.SimPosition) < CloseEnough * CloseEnough; + if (Target == null) + { + abandon = true; + return false; + } + bool closeEnough = Vector2.DistanceSquared(Target.WorldPosition, character.WorldPosition) < CloseEnough * CloseEnough; if (closeEnough) { if (customCondition == null || customCondition()) @@ -197,7 +165,7 @@ namespace Barotrauma } else if (Target is Character targetCharacter) { - if (character.CanInteractWith(targetCharacter, ConvertUnits.ToDisplayUnits(CloseEnough))) { isCompleted = true; } + if (character.CanInteractWith(targetCharacter, CloseEnough)) { isCompleted = true; } } else { @@ -208,6 +176,7 @@ namespace Barotrauma if (isCompleted) { character.AIController.SteeringManager.Reset(); + character.AnimController.TargetDir = Target.WorldPosition.X > character.WorldPosition.X ? Direction.Right : Direction.Left; } return isCompleted; } @@ -215,13 +184,12 @@ namespace Barotrauma public override bool IsDuplicate(AIObjective otherObjective) { if (!(otherObjective is AIObjectiveGoTo objective)) { return false; } - if (objective.Target == Target) { return true; } - return objective.targetPos == targetPos; + return objective.Target == Target; } private void CalculateCloseEnough() { - float interactionDistance = Target is Item i ? ConvertUnits.ToSimUnits(i.InteractDistance * 0.9f) : 0; + float interactionDistance = Target is Item i ? i.InteractDistance * 0.9f : 0; CloseEnough = Math.Max(interactionDistance, CloseEnough); } } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveIdle.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveIdle.cs index 56abec596..88881b170 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveIdle.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveIdle.cs @@ -89,6 +89,21 @@ namespace Barotrauma } } + public override void Update(float deltaTime) + { + if (objectiveManager.CurrentObjective == this) + { + if (randomTimer > 0) + { + randomTimer -= deltaTime; + } + else + { + SetRandom(); + } + } + } + public override bool IsCompleted() => false; public override bool CanBeCompleted => true; diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveManager.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveManager.cs index 6ef703e18..249eb8da0 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveManager.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveManager.cs @@ -260,7 +260,7 @@ namespace Barotrauma case "follow": newObjective = new AIObjectiveGoTo(orderGiver, character, this, repeat: true, priorityModifier: priorityModifier) { - CloseEnough = 1.5f, + CloseEnough = 150, AllowGoingOutside = true, IgnoreIfTargetDead = true, FollowControlledCharacter = orderGiver == character diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveOperateItem.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveOperateItem.cs index 4e75ede29..1a245455c 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveOperateItem.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveOperateItem.cs @@ -885,6 +885,10 @@ namespace Barotrauma { isCompleted = true; } + if (component.AIOperate(deltaTime, character, this)) + { + isCompleted = true; + } } else { diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRepairItem.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRepairItem.cs index ca4450361..a3574b29d 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRepairItem.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRepairItem.cs @@ -158,7 +158,7 @@ namespace Barotrauma var objective = new AIObjectiveGoTo(Item, character, objectiveManager); if (repairTool != null) { - objective.CloseEnough = ConvertUnits.ToSimUnits(repairTool.Range) * 0.75f; + objective.CloseEnough = repairTool.Range * 0.75f; } return objective; }, diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Character.cs b/Barotrauma/BarotraumaShared/Source/Characters/Character.cs index eecc373a6..cc2e7af08 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Character.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Character.cs @@ -1145,24 +1145,6 @@ namespace Barotrauma SmoothedCursorPosition = cursorPosition - smoothedCursorDiff; } - if (!(this is AICharacter) || Controlled == this || IsRemotePlayer) - { - //apply some smoothing to the cursor positions of remote players when playing as a client - //to make aiming look a little less choppy - Vector2 smoothedCursorDiff = cursorPosition - SmoothedCursorPosition; - smoothedCursorDiff = NetConfig.InterpolateCursorPositionError(smoothedCursorDiff); - SmoothedCursorPosition = cursorPosition - smoothedCursorDiff; - } - - if (!(this is AICharacter) || Controlled == this || IsRemotePlayer) - { - //apply some smoothing to the cursor positions of remote players when playing as a client - //to make aiming look a little less choppy - Vector2 smoothedCursorDiff = cursorPosition - SmoothedCursorPosition; - smoothedCursorDiff = NetConfig.InterpolateCursorPositionError(smoothedCursorDiff); - SmoothedCursorPosition = cursorPosition - smoothedCursorDiff; - } - if (!(this is AICharacter) || Controlled == this || IsRemotePlayer) { if (speedMultipliers.Count == 0) return 1f; diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Deconstructor.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Deconstructor.cs index d20a57d69..bf78419aa 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Deconstructor.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Deconstructor.cs @@ -582,6 +582,25 @@ namespace Barotrauma.Items.Components } } + if (targetItem.Prefab.DeconstructItems.Any()) + { + inputContainer.Inventory.RemoveItem(targetItem); + Entity.Spawner.AddToRemoveQueue(targetItem); + MoveInputQueue(); + PutItemsToLinkedContainer(); + } + else + { + if (outputContainer.Inventory.Items.All(i => i != null)) + { + targetItem.Drop(dropper: null); + } + else + { + outputContainer.Inventory.TryPutItem(targetItem, user: null, createNetworkEvent: true); + } + } + if (targetItem.Prefab.DeconstructItems.Any()) { inputContainer.Inventory.RemoveItem(targetItem); diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Steering.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Steering.cs index 7a471a65c..f6d19e87b 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Steering.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Steering.cs @@ -144,17 +144,6 @@ namespace Barotrauma.Items.Components } } - public Vector2 SteeringInput - { - get { return steeringInput; } - set - { - if (!MathUtils.IsValid(value)) return; - steeringInput.X = MathHelper.Clamp(value.X, -100.0f, 100.0f); - steeringInput.Y = MathHelper.Clamp(value.Y, -100.0f, 100.0f); - } - } - public SteeringPath SteeringPath { if (!CanBeSelected) return false; @@ -175,6 +164,12 @@ namespace Barotrauma.Items.Components set { posToMaintain = value; } } + public Vector2? PosToMaintain + { + get { return posToMaintain; } + set { posToMaintain = value; } + } + struct ObstacleDebugInfo { public Vector2 Point1; diff --git a/Barotrauma/BarotraumaShared/Source/Items/Item.cs b/Barotrauma/BarotraumaShared/Source/Items/Item.cs index e83b84678..badc65546 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Item.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Item.cs @@ -1139,70 +1139,6 @@ namespace Barotrauma } } - public void UpdateTransform() - { - Submarine prevSub = Submarine; - - FindHull(); - - if (Submarine == null && prevSub != null) - { - body.SetTransform(body.SimPosition + prevSub.SimPosition, body.Rotation); - } - else if (Submarine != null && prevSub == null) - { - body.SetTransform(body.SimPosition - Submarine.SimPosition, body.Rotation); - } - else if (Submarine != null && prevSub != null && Submarine != prevSub) - { - body.SetTransform(body.SimPosition + prevSub.SimPosition - Submarine.SimPosition, body.Rotation); - } - - Vector2 displayPos = ConvertUnits.ToDisplayUnits(body.SimPosition); - rect.X = (int)(displayPos.X - rect.Width / 2.0f); - rect.Y = (int)(displayPos.Y + rect.Height / 2.0f); - - if (Math.Abs(body.LinearVelocity.X) > NetConfig.MaxPhysicsBodyVelocity || - Math.Abs(body.LinearVelocity.Y) > NetConfig.MaxPhysicsBodyVelocity) - { - body.LinearVelocity = new Vector2( - MathHelper.Clamp(body.LinearVelocity.X, -NetConfig.MaxPhysicsBodyVelocity, NetConfig.MaxPhysicsBodyVelocity), - MathHelper.Clamp(body.LinearVelocity.Y, -NetConfig.MaxPhysicsBodyVelocity, NetConfig.MaxPhysicsBodyVelocity)); - } - } - - public void UpdateTransform() - { - Submarine prevSub = Submarine; - - FindHull(); - - if (Submarine == null && prevSub != null) - { - body.SetTransform(body.SimPosition + prevSub.SimPosition, body.Rotation); - } - else if (Submarine != null && prevSub == null) - { - body.SetTransform(body.SimPosition - Submarine.SimPosition, body.Rotation); - } - else if (Submarine != null && prevSub != null && Submarine != prevSub) - { - body.SetTransform(body.SimPosition + prevSub.SimPosition - Submarine.SimPosition, body.Rotation); - } - - Vector2 displayPos = ConvertUnits.ToDisplayUnits(body.SimPosition); - rect.X = (int)(displayPos.X - rect.Width / 2.0f); - rect.Y = (int)(displayPos.Y + rect.Height / 2.0f); - - if (Math.Abs(body.LinearVelocity.X) > NetConfig.MaxPhysicsBodyVelocity || - Math.Abs(body.LinearVelocity.Y) > NetConfig.MaxPhysicsBodyVelocity) - { - body.LinearVelocity = new Vector2( - MathHelper.Clamp(body.LinearVelocity.X, -NetConfig.MaxPhysicsBodyVelocity, NetConfig.MaxPhysicsBodyVelocity), - MathHelper.Clamp(body.LinearVelocity.Y, -NetConfig.MaxPhysicsBodyVelocity, NetConfig.MaxPhysicsBodyVelocity)); - } - } - public void UpdateTransform() { Submarine prevSub = Submarine; diff --git a/Barotrauma/BarotraumaShared/Source/Map/Hull.cs b/Barotrauma/BarotraumaShared/Source/Map/Hull.cs index 1ace5bf7b..3668eb362 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Hull.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Hull.cs @@ -630,6 +630,25 @@ namespace Barotrauma } } + public string DisplayName + { + get; + private set; + } + + private string roomName; + [Editable, Serialize("", true, translationTextTag: "RoomName.")] + public string RoomName + { + get { return roomName; } + set + { + if (roomName == value) { return; } + roomName = value; + DisplayName = TextManager.Get(roomName, returnNull: true) ?? roomName; + } + } + public override Rectangle Rect { get