Method InteractWith
- Namespace
- GrindFest
- Assembly
- GrindFest.dll
InteractWith(InteractiveBehaviour)
Makes the hero move to and interact with an interactive object like a chest, shrine, or NPC.
public static bool InteractWith(InteractiveBehaviour interactive)
Parameters
interactive
InteractiveBehaviourThe interactive object to interact with
Returns
- bool
True if the interaction was successful, false if still moving towards the object
Remarks
This method handles both movement and interaction with game objects that implement InteractiveBehaviour. Common interactable objects include:
- Chests - Contains loot and equipment
- Shrines - Provides temporary buffs
- NPCs - Trading and dialogue
The method will:
- Move the hero within interaction range if needed
- Trigger the same interaction that occurs when a player double-clicks the object
- Handle any resulting inventory changes or effects
var chest = Hero.FindNearestInteractive("Chest");
if (chest != null)
{
if (Hero.InteractWith(chest))
{
Hero.Say("Found and opened a chest!");
}
}
// Find and use shrines while exploring
if (!Hero.RunAroundInAreaAnd(() => {
var shrine = Hero.FindNearestInteractive("Shrine");
if (shrine != null)
{
return Hero.InteractWith(shrine);
}
return false;
}))
{
Hero.Say("No shrines found, keep looking...");
}