Jump to content

Entity Lifecycle


Recommended Posts

Posted

Lets say I query for some Entity and store it to a variable. 

List<RS2Object> visibleTrees1 = objects.filter(
  new ContainsNameFilter<>("tree"),
  rs2Object -> !rs2Object.getName().contains("Tree stump") &&
  rs2Object.isVisible() &&
  myPlayer().getPosition().distance(rs2Object.getPosition()) <= 5
);

Rs2Object myReference = visibleTrees.get(0);

For how long is that instance (myReference) valid for interaction events?

If I leave the area and come back, can I still use the instance I queried before? Or has it gone stale and need to be re-queried? 

Posted (edited)

I think the answer is until I walk far enough to hit a loading screen. The RS would get the set of objects in the newly loaded game area which would then be intercepted by osbot and made available through the api. The instances from the previous area would be available to the JVM for garbage collection. 

Going to test that hypothesis

Edited by PayPalMeRSGP
Posted
45 minutes ago, PayPalMeRSGP said:

I think the answer is until I walk far enough to hit a loading screen. The RS would get the set of objects in the newly loaded game area which would then be intercepted by osbot and made available through the api. The instances from the previous area would be available to the JVM for garbage collection. 

Going to test that hypothesis

Seems the be the case. I walk away, trigger a load then the hashcode of the instance changes when I come back. 

[INFO][Bot #1][11/15 09:09:19 PM]: Querying Entity
[INFO][Bot #1][11/15 09:09:19 PM]: org.osbot.rs07.api.model.InteractableObject@60beb29d
[INFO][Bot #1][11/15 09:09:19 PM]: Optional[org.osbot.rs07.api.model.Model@52697857]
Walk and return...
[INFO][Bot #1][11/15 09:10:05 PM]: Querying Entity
[INFO][Bot #1][11/15 09:10:05 PM]: org.osbot.rs07.api.model.InteractableObject@856ac72
[INFO][Bot #1][11/15 09:10:05 PM]: Optional[org.osbot.rs07.api.model.Model@f00a947]

Same situation for if the entity is consumed (Tree chopped)

 

Posted (edited)
2 hours ago, PayPalMeRSGP said:

Lets say I query for some Entity and store it to a variable. 

List<RS2Object> visibleTrees1 = objects.filter(
  new ContainsNameFilter<>("tree"),
  rs2Object -> !rs2Object.getName().contains("Tree stump") &&
  rs2Object.isVisible() &&
  myPlayer().getPosition().distance(rs2Object.getPosition()) <= 5
);

Rs2Object myReference = visibleTrees.get(0);

For how long is that instance (myReference) valid for interaction events?

If I leave the area and come back, can I still use the instance I queried before? Or has it gone stale and need to be re-queried? 

Until it unloads or if it's not there anymore I believe

Edited by Khaleesi

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...