Some tweaking to the item interaction logic:
- FindItemAtPosition uses the distance calculated in CanInteractWith to determine how close an item is to the character. Otherwise very large items (such as ladders) wouldn't be possible to select with aim assist unless the player happens to be holding the cursor close to the center of the item. - The hull-parameter is taken into account in FindItemAtPosition. - Characters are considered to be inside a trigger if either their lower or upper body is inside it. - Added triggers to engines because they are often placed partially inside a wall, making it impossible to rewire them if the center is not inside the sub.
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
|
||||
<Sprite texture ="engine.png" depth="0.8" sourcerect="0,0,373,113" canflipx="true"/>
|
||||
|
||||
<trigger x="20" y ="0" width="333" height="113"/>
|
||||
|
||||
<fixrequirement name="Mechanical repairs">
|
||||
<skill name="Construction" level="40"/>
|
||||
<item name="Welding Tool"/>
|
||||
@@ -38,6 +40,8 @@
|
||||
|
||||
<Sprite texture ="engine.png" depth="0.8" sourcerect="0,115,224,73" canflipx="true"/>
|
||||
|
||||
<trigger x="15" y ="0" width="194" height="73"/>
|
||||
|
||||
<fixrequirement name="Mechanical repairs">
|
||||
<skill name="Construction" level="30"/>
|
||||
<item name="Welding Tool"/>
|
||||
|
||||
@@ -1028,7 +1028,7 @@ namespace Barotrauma
|
||||
// Get the point along the line between lowerBodyPosition and upperBodyPosition which is closest to the center of itemDisplayRect
|
||||
playerDistanceCheckPosition = Vector2.Clamp(transformedTrigger.Center.ToVector2(), lowerBodyPosition, upperBodyPosition);
|
||||
|
||||
if (!transformedTrigger.Contains(upperBodyPosition)) return false;
|
||||
if (!transformedTrigger.Contains(upperBodyPosition) && !transformedTrigger.Contains(lowerBodyPosition)) return false;
|
||||
|
||||
insideTrigger = true;
|
||||
}
|
||||
@@ -1099,9 +1099,11 @@ namespace Barotrauma
|
||||
foreach (Item item in Item.ItemList)
|
||||
{
|
||||
if (ignoredItems != null && ignoredItems.Contains(item)) continue;
|
||||
if (hull != null && item.CurrentHull != hull) continue;
|
||||
if (item.body != null && !item.body.Enabled) continue;
|
||||
|
||||
if (CanInteractWith(item))
|
||||
|
||||
float distanceToItem = float.PositiveInfinity;
|
||||
if (CanInteractWith(item, out distanceToItem))
|
||||
{
|
||||
if (item.IsMouseOn(displayPosition))
|
||||
{
|
||||
@@ -1115,7 +1117,6 @@ namespace Barotrauma
|
||||
}
|
||||
else if (aimAssistModifier > 0.0f)
|
||||
{
|
||||
float distanceToItem = Vector2.Distance(item.WorldPosition, displayPosition);
|
||||
if (distanceToItem < (100.0f * aimAssistModifier) && (closestItem == null || distanceToItem < closestItemDistance))
|
||||
{
|
||||
closestItem = item;
|
||||
|
||||
Reference in New Issue
Block a user