Updated and refactored how items and characters are chosen for interactions in the world. The new system has more precision, with items under the cursor taking priority (this helps with small items which are in front of large items). A new method CanInteractWith(Item) has been added to the Character class which does all validation of interaction with items, including new distance calculations based on bounding boxes. This gives more consistency in selecting and interacting with all sizes and shapes of items. Because of this pickdistance (not interactdistance) has been removed from all item configurations (in their XML config files) and the default InteractDistance for all items is now 120.

This commit is contained in:
Faerdan
2017-06-18 22:30:54 +01:00
parent 5cd2a5a838
commit a09367c78f
45 changed files with 483 additions and 476 deletions
+17 -9
View File
@@ -35,9 +35,11 @@ namespace Barotrauma
protected Vector2 size;
//how close the Character has to be to the item to pick it up
private float pickDistance;
private float interactDistance;
// this can be used to allow items which are behind other items tp
private float interactPriority;
private bool pickThroughWalls;
private bool interactThroughWalls;
//an area next to the construction
//the construction can be Activated() by a Character inside the area
@@ -80,14 +82,19 @@ namespace Barotrauma
private set;
}
public float PickDistance
public float InteractDistance
{
get { return pickDistance; }
get { return interactDistance; }
}
public bool PickThroughWalls
public float InteractPriority
{
get { return pickThroughWalls; }
get { return interactPriority; }
}
public bool InteractThroughWalls
{
get { return interactThroughWalls; }
}
public override bool IsLinkable
@@ -268,9 +275,10 @@ namespace Barotrauma
Description = ToolBox.GetAttributeString(element, "description", "");
pickThroughWalls = ToolBox.GetAttributeBool(element, "pickthroughwalls", false);
pickDistance = ToolBox.GetAttributeFloat(element, "pickdistance", 0.0f);
interactThroughWalls = ToolBox.GetAttributeBool(element, "interactthroughwalls", false);
interactDistance = ToolBox.GetAttributeFloat(element, "interactdistance", 120.0f); // Default to 120 as the new item picking method is tuned to this number
interactPriority = ToolBox.GetAttributeFloat(element, "interactpriority", 0.0f);
isLinkable = ToolBox.GetAttributeBool(element, "linkable", false);
resizeHorizontal = ToolBox.GetAttributeBool(element, "resizehorizontal", false);