(714944a46) - Item triggers can be used to define areas that cause the item to be highlighted, not just areas that the player has to be inside to interact with the item. - Triggers take item scale into account. - Added triggers around the integrated buttons in the new hatch/window variants (-> fixes hatches not being highlighted by putting the cursor on the button when there's a ladder next to the player).
This commit is contained in:
@@ -1546,12 +1546,11 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (item.InteractDistance == 0.0f && !item.Prefab.Triggers.Any()) return false;
|
||||
|
||||
if (item.InteractDistance == 0.0f && !item.Prefab.Triggers.Any()) { return false; }
|
||||
|
||||
Pickable pickableComponent = item.GetComponent<Pickable>();
|
||||
if (pickableComponent != null && (pickableComponent.Picker != null && !pickableComponent.Picker.IsDead)) return false;
|
||||
if (pickableComponent != null && (pickableComponent.Picker != null && !pickableComponent.Picker.IsDead)) { return false; }
|
||||
|
||||
Vector2 characterDirection = Vector2.Transform(Vector2.UnitY, Matrix.CreateRotationZ(AnimController.Collider.Rotation));
|
||||
|
||||
@@ -1565,7 +1564,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
bool insideTrigger = item.IsInsideTrigger(upperBodyPosition) || item.IsInsideTrigger(lowerBodyPosition);
|
||||
if (item.Prefab.Triggers.Count > 0 && !insideTrigger) return false;
|
||||
if (item.Prefab.Triggers.Count > 0 && !insideTrigger && item.Prefab.RequireBodyInsideTrigger) { return false; }
|
||||
|
||||
Rectangle itemDisplayRect = new Rectangle(item.InteractionRect.X, item.InteractionRect.Y - item.InteractionRect.Height, item.InteractionRect.Width, item.InteractionRect.Height);
|
||||
|
||||
|
||||
@@ -833,16 +833,16 @@ namespace Barotrauma
|
||||
{
|
||||
return world ?
|
||||
new Rectangle(
|
||||
WorldRect.X + trigger.X,
|
||||
WorldRect.Y + trigger.Y,
|
||||
(trigger.Width == 0) ? Rect.Width : trigger.Width,
|
||||
(trigger.Height == 0) ? Rect.Height : trigger.Height)
|
||||
(int)(WorldRect.X + trigger.X * Scale),
|
||||
(int)(WorldRect.Y + trigger.Y * Scale),
|
||||
(trigger.Width == 0) ? Rect.Width : (int)(trigger.Width * Scale),
|
||||
(trigger.Height == 0) ? Rect.Height : (int)(trigger.Height * Scale))
|
||||
:
|
||||
new Rectangle(
|
||||
Rect.X + trigger.X,
|
||||
Rect.Y + trigger.Y,
|
||||
(trigger.Width == 0) ? Rect.Width : trigger.Width,
|
||||
(trigger.Height == 0) ? Rect.Height : trigger.Height);
|
||||
(int)(Rect.X + trigger.X * Scale),
|
||||
(int)(Rect.Y + trigger.Y * Scale),
|
||||
(trigger.Width == 0) ? Rect.Width : (int)(trigger.Width * Scale),
|
||||
(trigger.Height == 0) ? Rect.Height : (int)(trigger.Height * Scale));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -132,14 +132,16 @@ namespace Barotrauma
|
||||
//default size
|
||||
protected Vector2 size;
|
||||
|
||||
private float impactTolerance;
|
||||
private List<XElement> fabricationRecipeElements = new List<XElement>();
|
||||
|
||||
private bool canSpriteFlipX, canSpriteFlipY;
|
||||
|
||||
private Dictionary<string, PriceInfo> prices;
|
||||
|
||||
//an area next to the construction
|
||||
//the construction can be Activated() by a Character inside the area
|
||||
/// <summary>
|
||||
/// Defines areas where the item can be interacted with. If RequireBodyInsideTrigger is set to true, the character
|
||||
/// has to be within the trigger to interact. If it's set to false, having the cursor within the trigger is enough.
|
||||
/// </summary>
|
||||
public List<Rectangle> Triggers;
|
||||
|
||||
private List<XElement> fabricationRecipeElements = new List<XElement>();
|
||||
@@ -196,6 +198,15 @@ namespace Barotrauma
|
||||
private set;
|
||||
}
|
||||
|
||||
//if true and the item has trigger areas defined, characters need to be within the trigger to interact with the item
|
||||
//if false, trigger areas define areas that can be used to highlight the item
|
||||
[Serialize(true, false)]
|
||||
public bool RequireBodyInsideTrigger
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
|
||||
//should the camera focus on the item when selected
|
||||
[Serialize(false, false)]
|
||||
|
||||
Reference in New Issue
Block a user