(17490598f) Don't allow putting items into locked inventories by double-clicking (causes them to be dropped in multiplayer)
This commit is contained in:
@@ -61,7 +61,7 @@ namespace Barotrauma
|
||||
if (vanillaContent == null)
|
||||
{
|
||||
// TODO: Dynamic method for defining and finding the vanilla content package.
|
||||
vanillaContent = SelectedPackages.SingleOrDefault(cp => Path.GetFileName(cp.Path).ToLowerInvariant() == "vanilla 0.9.xml");
|
||||
vanillaContent = ContentPackage.List.SingleOrDefault(cp => Path.GetFileName(cp.Path).ToLowerInvariant() == "vanilla 0.9.xml");
|
||||
}
|
||||
return vanillaContent;
|
||||
}
|
||||
|
||||
@@ -539,7 +539,11 @@ namespace Barotrauma
|
||||
if (item.ParentInventory != this)
|
||||
{
|
||||
//in another inventory -> attempt to place in the character's inventory
|
||||
if (allowInventorySwap)
|
||||
if (item.ParentInventory.Locked)
|
||||
{
|
||||
return QuickUseAction.None;
|
||||
}
|
||||
else if (allowInventorySwap)
|
||||
{
|
||||
return item.ParentInventory is CharacterInventory ?
|
||||
QuickUseAction.TakeFromCharacter : QuickUseAction.TakeFromContainer;
|
||||
@@ -548,18 +552,24 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
var selectedContainer = character.SelectedConstruction?.GetComponent<ItemContainer>();
|
||||
if (selectedContainer != null && selectedContainer.Inventory != null && allowInventorySwap)
|
||||
if (selectedContainer != null &&
|
||||
selectedContainer.Inventory != null &&
|
||||
!selectedContainer.Inventory.Locked &&
|
||||
allowInventorySwap)
|
||||
{
|
||||
//player has selected the inventory of another item -> attempt to move the item there
|
||||
return QuickUseAction.PutToContainer;
|
||||
}
|
||||
else if (character.SelectedCharacter != null && character.SelectedCharacter.Inventory != null && allowInventorySwap)
|
||||
else if (character.SelectedCharacter != null &&
|
||||
character.SelectedCharacter.Inventory != null &&
|
||||
!character.SelectedCharacter.Inventory.Locked &&
|
||||
allowInventorySwap)
|
||||
{
|
||||
//player has selected the inventory of another character -> attempt to move the item there
|
||||
return QuickUseAction.PutToCharacter;
|
||||
}
|
||||
else if (character.SelectedBy != null && Character.Controlled == character.SelectedBy &&
|
||||
character.SelectedBy.Inventory != null && allowInventorySwap)
|
||||
character.SelectedBy.Inventory != null && !character.SelectedBy.Inventory.Locked && allowInventorySwap)
|
||||
{
|
||||
return QuickUseAction.TakeFromCharacter;
|
||||
}
|
||||
|
||||
@@ -62,24 +62,9 @@ namespace Barotrauma
|
||||
newTargetTimer = 0;
|
||||
standStillTimer = 0;
|
||||
}
|
||||
else if (character.IsClimbing)
|
||||
if (character.AnimController.InWater || character.IsClimbing)
|
||||
{
|
||||
if (currentTarget == null)
|
||||
{
|
||||
newTargetTimer = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Don't allow new targets when climbing.
|
||||
newTargetTimer = Math.Max(newTargetIntervalMin, newTargetTimer);
|
||||
}
|
||||
}
|
||||
else if (character.AnimController.InWater)
|
||||
{
|
||||
if (currentTarget == null)
|
||||
{
|
||||
newTargetTimer = 0;
|
||||
}
|
||||
standStillTimer = 0;
|
||||
}
|
||||
if (newTargetTimer <= 0.0f)
|
||||
{
|
||||
@@ -137,28 +122,23 @@ namespace Barotrauma
|
||||
// - if reached the end of the path
|
||||
// - if the target is unreachable
|
||||
// - if the path requires going outside
|
||||
if (!character.IsClimbing)
|
||||
if (SteeringManager != PathSteering || (PathSteering.CurrentPath != null &&
|
||||
(PathSteering.CurrentPath.NextNode == null || PathSteering.CurrentPath.Unreachable || PathSteering.CurrentPath.HasOutdoorsNodes)))
|
||||
{
|
||||
if (SteeringManager != PathSteering || (PathSteering.CurrentPath != null &&
|
||||
(PathSteering.CurrentPath.NextNode == null || PathSteering.CurrentPath.Unreachable || PathSteering.CurrentPath.HasOutdoorsNodes)))
|
||||
standStillTimer -= deltaTime;
|
||||
if (standStillTimer > 0.0f)
|
||||
{
|
||||
if (!character.AnimController.InWater)
|
||||
{
|
||||
standStillTimer -= deltaTime;
|
||||
if (standStillTimer > 0.0f)
|
||||
{
|
||||
walkDuration = Rand.Range(walkDurationMin, walkDurationMax);
|
||||
PathSteering.Reset();
|
||||
return;
|
||||
}
|
||||
if (standStillTimer < -walkDuration)
|
||||
{
|
||||
standStillTimer = Rand.Range(standStillMin, standStillMax);
|
||||
}
|
||||
}
|
||||
Wander(deltaTime);
|
||||
walkDuration = Rand.Range(walkDurationMin, walkDurationMax);
|
||||
PathSteering.Reset();
|
||||
return;
|
||||
}
|
||||
if (standStillTimer < -walkDuration)
|
||||
{
|
||||
standStillTimer = Rand.Range(standStillMin, standStillMax);
|
||||
}
|
||||
|
||||
Wander(deltaTime);
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentTarget != null)
|
||||
@@ -169,54 +149,44 @@ namespace Barotrauma
|
||||
|
||||
public void Wander(float deltaTime)
|
||||
{
|
||||
if (character.IsClimbing) { return; }
|
||||
//steer away from edges of the hull
|
||||
var currentHull = character.CurrentHull;
|
||||
if (currentHull != null)
|
||||
if (character.AnimController.CurrentHull != null && !character.IsClimbing)
|
||||
{
|
||||
float roomWidth = currentHull.Rect.Width;
|
||||
if (roomWidth < WallAvoidDistance * 4)
|
||||
float leftDist = character.Position.X - character.AnimController.CurrentHull.Rect.X;
|
||||
float rightDist = character.AnimController.CurrentHull.Rect.Right - character.Position.X;
|
||||
if (leftDist < WallAvoidDistance && rightDist < WallAvoidDistance)
|
||||
{
|
||||
PathSteering.Reset();
|
||||
if (Math.Abs(rightDist - leftDist) > WallAvoidDistance / 2)
|
||||
{
|
||||
PathSteering.SteeringManual(deltaTime, Vector2.UnitX * Math.Sign(rightDist - leftDist));
|
||||
}
|
||||
else
|
||||
{
|
||||
PathSteering.Reset();
|
||||
}
|
||||
}
|
||||
else if (leftDist < WallAvoidDistance)
|
||||
{
|
||||
//PathSteering.SteeringManual(deltaTime, Vector2.UnitX * (WallAvoidDistance - leftDist) / WallAvoidDistance);
|
||||
PathSteering.SteeringManual(deltaTime, Vector2.UnitX);
|
||||
PathSteering.WanderAngle = 0.0f;
|
||||
}
|
||||
else if (rightDist < WallAvoidDistance)
|
||||
{
|
||||
//PathSteering.SteeringManual(deltaTime, -Vector2.UnitX * (WallAvoidDistance - rightDist) / WallAvoidDistance);
|
||||
PathSteering.SteeringManual(deltaTime, -Vector2.UnitX);
|
||||
PathSteering.WanderAngle = MathHelper.Pi;
|
||||
}
|
||||
else
|
||||
{
|
||||
float leftDist = character.Position.X - currentHull.Rect.X;
|
||||
float rightDist = currentHull.Rect.Right - character.Position.X;
|
||||
if (leftDist < WallAvoidDistance && rightDist < WallAvoidDistance)
|
||||
{
|
||||
if (Math.Abs(rightDist - leftDist) > WallAvoidDistance / 2)
|
||||
{
|
||||
PathSteering.SteeringManual(deltaTime, Vector2.UnitX * Math.Sign(rightDist - leftDist));
|
||||
}
|
||||
else
|
||||
{
|
||||
PathSteering.Reset();
|
||||
}
|
||||
}
|
||||
else if (leftDist < WallAvoidDistance)
|
||||
{
|
||||
float speed = (WallAvoidDistance - leftDist) / WallAvoidDistance;
|
||||
PathSteering.SteeringManual(deltaTime, Vector2.UnitX * MathHelper.Clamp(speed, 0.25f, 1));
|
||||
PathSteering.WanderAngle = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
float speed = (WallAvoidDistance - rightDist) / WallAvoidDistance;
|
||||
PathSteering.SteeringManual(deltaTime, -Vector2.UnitX * MathHelper.Clamp(speed, 0.25f, 1));
|
||||
PathSteering.WanderAngle = MathHelper.Pi;
|
||||
}
|
||||
else
|
||||
{
|
||||
SteeringManager.SteeringWander();
|
||||
}
|
||||
SteeringManager.SteeringWander();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SteeringManager.SteeringWander();
|
||||
}
|
||||
if (!character.AnimController.InWater)
|
||||
if (!character.IsClimbing && !character.AnimController.InWater)
|
||||
{
|
||||
//reset vertical steering to prevent dropping down from platforms etc
|
||||
character.AIController.SteeringManager.ResetY();
|
||||
@@ -251,12 +221,7 @@ namespace Barotrauma
|
||||
if (!targetHulls.Contains(hull))
|
||||
{
|
||||
targetHulls.Add(hull);
|
||||
float weight = hull.Volume;
|
||||
// Prefer rooms that are closer. Avoid rooms that are not in the same level.
|
||||
float dist = Math.Abs(character.WorldPosition.X - hull.WorldPosition.X) + Math.Abs(character.WorldPosition.Y - hull.WorldPosition.Y) * 5.0f;
|
||||
float distanceFactor = MathHelper.Lerp(1, 0.1f, MathUtils.InverseLerp(0, 2500, dist));
|
||||
weight *= distanceFactor;
|
||||
hullWeights.Add(weight);
|
||||
hullWeights.Add(hull.Volume);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user