(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)
|
if (vanillaContent == null)
|
||||||
{
|
{
|
||||||
// TODO: Dynamic method for defining and finding the vanilla content package.
|
// 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;
|
return vanillaContent;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -539,7 +539,11 @@ namespace Barotrauma
|
|||||||
if (item.ParentInventory != this)
|
if (item.ParentInventory != this)
|
||||||
{
|
{
|
||||||
//in another inventory -> attempt to place in the character's inventory
|
//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 ?
|
return item.ParentInventory is CharacterInventory ?
|
||||||
QuickUseAction.TakeFromCharacter : QuickUseAction.TakeFromContainer;
|
QuickUseAction.TakeFromCharacter : QuickUseAction.TakeFromContainer;
|
||||||
@@ -548,18 +552,24 @@ namespace Barotrauma
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var selectedContainer = character.SelectedConstruction?.GetComponent<ItemContainer>();
|
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
|
//player has selected the inventory of another item -> attempt to move the item there
|
||||||
return QuickUseAction.PutToContainer;
|
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
|
//player has selected the inventory of another character -> attempt to move the item there
|
||||||
return QuickUseAction.PutToCharacter;
|
return QuickUseAction.PutToCharacter;
|
||||||
}
|
}
|
||||||
else if (character.SelectedBy != null && Character.Controlled == character.SelectedBy &&
|
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;
|
return QuickUseAction.TakeFromCharacter;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,24 +62,9 @@ namespace Barotrauma
|
|||||||
newTargetTimer = 0;
|
newTargetTimer = 0;
|
||||||
standStillTimer = 0;
|
standStillTimer = 0;
|
||||||
}
|
}
|
||||||
else if (character.IsClimbing)
|
if (character.AnimController.InWater || character.IsClimbing)
|
||||||
{
|
{
|
||||||
if (currentTarget == null)
|
standStillTimer = 0;
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (newTargetTimer <= 0.0f)
|
if (newTargetTimer <= 0.0f)
|
||||||
{
|
{
|
||||||
@@ -137,28 +122,23 @@ namespace Barotrauma
|
|||||||
// - if reached the end of the path
|
// - if reached the end of the path
|
||||||
// - if the target is unreachable
|
// - if the target is unreachable
|
||||||
// - if the path requires going outside
|
// - 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 &&
|
standStillTimer -= deltaTime;
|
||||||
(PathSteering.CurrentPath.NextNode == null || PathSteering.CurrentPath.Unreachable || PathSteering.CurrentPath.HasOutdoorsNodes)))
|
if (standStillTimer > 0.0f)
|
||||||
{
|
{
|
||||||
if (!character.AnimController.InWater)
|
walkDuration = Rand.Range(walkDurationMin, walkDurationMax);
|
||||||
{
|
PathSteering.Reset();
|
||||||
standStillTimer -= deltaTime;
|
|
||||||
if (standStillTimer > 0.0f)
|
|
||||||
{
|
|
||||||
walkDuration = Rand.Range(walkDurationMin, walkDurationMax);
|
|
||||||
PathSteering.Reset();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (standStillTimer < -walkDuration)
|
|
||||||
{
|
|
||||||
standStillTimer = Rand.Range(standStillMin, standStillMax);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Wander(deltaTime);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (standStillTimer < -walkDuration)
|
||||||
|
{
|
||||||
|
standStillTimer = Rand.Range(standStillMin, standStillMax);
|
||||||
|
}
|
||||||
|
|
||||||
|
Wander(deltaTime);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentTarget != null)
|
if (currentTarget != null)
|
||||||
@@ -169,54 +149,44 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public void Wander(float deltaTime)
|
public void Wander(float deltaTime)
|
||||||
{
|
{
|
||||||
if (character.IsClimbing) { return; }
|
|
||||||
//steer away from edges of the hull
|
//steer away from edges of the hull
|
||||||
var currentHull = character.CurrentHull;
|
if (character.AnimController.CurrentHull != null && !character.IsClimbing)
|
||||||
if (currentHull != null)
|
|
||||||
{
|
{
|
||||||
float roomWidth = currentHull.Rect.Width;
|
float leftDist = character.Position.X - character.AnimController.CurrentHull.Rect.X;
|
||||||
if (roomWidth < WallAvoidDistance * 4)
|
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
|
else
|
||||||
{
|
{
|
||||||
float leftDist = character.Position.X - currentHull.Rect.X;
|
SteeringManager.SteeringWander();
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SteeringManager.SteeringWander();
|
SteeringManager.SteeringWander();
|
||||||
}
|
}
|
||||||
if (!character.AnimController.InWater)
|
if (!character.IsClimbing && !character.AnimController.InWater)
|
||||||
{
|
{
|
||||||
//reset vertical steering to prevent dropping down from platforms etc
|
//reset vertical steering to prevent dropping down from platforms etc
|
||||||
character.AIController.SteeringManager.ResetY();
|
character.AIController.SteeringManager.ResetY();
|
||||||
@@ -251,12 +221,7 @@ namespace Barotrauma
|
|||||||
if (!targetHulls.Contains(hull))
|
if (!targetHulls.Contains(hull))
|
||||||
{
|
{
|
||||||
targetHulls.Add(hull);
|
targetHulls.Add(hull);
|
||||||
float weight = hull.Volume;
|
hullWeights.Add(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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user