Jump to content

Entity Lifecycle


yfoo

Recommended Posts

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? 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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)

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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