# RSEntities This file is responsible for interacting with `RSEntities`. `RSEntities` is anything in the game that has a {ref}`EDot` assign to it on the {ref}`Minimap`. These are functionally very similar to {ref}`RSObjects` and you create and interact with them almost the same way. They only differ in the fact that `TEntity` can use a {ref}`EDot` to help find them and/or {ref}`TDotFilters`. Also, due to the unpredictability of entities that move, unlike {ref}`RSObjects` these do not have a rotation field. - - - ## TEntity Main type to handle {ref}`RSEntity`. - - - ## TEntityArray Array of {ref}`TEntity`. - - - ## TEntity.Create ```pascal function TEntity.Create(var walker: TWalker; size: TVector3; coordinates: TPointArray; uptext: TStringArray = []; dots: EDots = []): TEntity; static; function TEntity.Create(var walker: TWalker; data: TMapNPCData): TEntity; static; overload; ``` Create function to create your {ref}`TEntity`. Assuming you create the `RSEntity` manually, the create function will provide you with a fully built `TEntity` without a finder. You may optionally assign one later if you want: ```pascal {$I WaspLib/main.simba} var npc: TEntity; begin Map.Setup([EChunk.VARROCK]); //varrock west southern most banker npc := TEntity.Create(Map.Walker, [1,1,7], [[8652,36686]], ['Banker'], [EDot.NPC]); //npc.Finder.Colors += [$543B3B, 10.121, EColorSpace.HSV, [0.528, 1.275, 1.199]]; end; ``` The `data` version builds the entity from one of the {ref}`Map NPCs`, finder included: ```pascal {$I WaspLib/main.simba} var npc: TEntity; begin Map.Setup([EChunk.VARROCK]); npc := TEntity.Create(Map.Walker, MapNPCs.GetByName('Banker', 1)[0]); end; ``` - - - ## TEntityArray.Create ```pascal function TEntityArray.Create(var walker: TWalker; data: TMapNPCDataArray): TEntityArray; static; ``` Create function to build your {ref}`TEntityArray`. Builds one {ref}`TEntity` for each of the {ref}`Map NPCs` in `data`. Example: ```pascal {$I WaspLib/main.simba} var entities: TEntityArray; begin Map.Setup([EChunk.VARROCK]); entities := TEntityArray.Create(Map.Walker, MapNPCs.GetByName('Banker')); end; ``` - - - ## Entity._GetBounds ```pascal function TEntity._GetBounds(me: TPoint; vector: TVector2; size: TVector3; height, radians: Single): TCuboid; ``` Internal helper function for {ref}`TEntity.GetBoundsArray`. - - - ## Entity.GetBoundsArray ```pascal function TEntity.GetBoundsArray(me: TPoint; angle: Single = $FFFF): TCuboidArray; ``` Internal function that returns an array of cuboids of the entity if it's visible on the {ref}`MainScreen`. - - - ## TEntity.Find ```pascal function TEntity.Find(cuboidArray: TCuboidArray): T2DPointArray; ``` Internal TEntity method responsible for filtering a TCuboidArray by what's visible in the mainscren. This is meant to filter TEntity.GetBoundsArray() so targets that are outside of the mainscreen are filtered out. You will probably never need to use this directly. - - - ## TEntity.FindEx ```pascal function TEntity.FindEx(me: TPoint; out boundsArray: TPolygonArray; out coordinates: TPointArray; out atpa: T2DPointArray): Boolean; ``` Internal {ref}`TEntity` method used to find a {ref}`RSEntity`. You also have {ref}`RSEntity.Find` to find entities, this version of the method is internal because it returns extra information about the found entities for internal use, like it's `cuboids` for example. This also returns an `atpa` containing the colors of the entity that were found assuming the entity has a {ref}`TColorFinder` setup. If not, the cuboids area are returned as the match. - - - ## RSEntity.Find ```pascal function TEntity.Find(out coordinates: TPointArray; out atpa: T2DPointArray): Boolean; function TEntity.Find(out atpa: T2DPointArray): Boolean; overload; ``` {ref}`TEntity` method used to find a {ref}`RSEntity`. This returns True/False if the entity was found and it's `atpa` which cointains the colors of it that were found. For more information on this refer to {ref}`TEntity.FindEx`, it's an internal function but is used within this one and will go into more detail. - - - ## Entity.IsVisible ```pascal function TEntity.IsVisible(): Boolean; ``` Returns a boolean whether the entity is currently visible or not. - - - ## TEntity._UpTextCheck ```pascal function TEntity._UpTextCheck(out shouldExit: Boolean; action: TStringArray): Boolean; ``` Internal TEntity helper method that is used by all hovering methods. You probably don't need to use this directly. - - - ## TEntity._ClickHelper ```pascal function TEntity._ClickHelper(leftClick: Boolean): Boolean; ``` Internal TEntity helper method that is used by other clicking methods. You probably don't need to use this directly. This is what's responsible for deciding if we click a target we are hovering or not. - - - ## TEntity._SelectHelper ```pascal function TEntity._SelectHelper(action: TStringArray): Boolean; ``` Internal TEntity helper method that is used by other select methods. You probably don't need to use this directly. This is what is responsible for deciding if we just left click a target we are hovering or right click it and choose an option. - - - ## TEntity.Hover ```pascal function TEntity.Hover(action: TStringArray = []; attempts: Integer = 2): Boolean; ``` Method used to hover a TEntity target if it's found on the {ref}`MainScreen`. Example: ```pascal {$I WaspLib/main.simba} var npc: TEntity; begin Map.Setup([Chunk(Box(40,49,41,48), 0)]); npc := TEntity.Create(Map.Walker, [1,1,7], 8, [[10432, 37966]], ['Dominic Onion'], [EDot.NPC]); WriteLn npc.Hover(); end. ``` - - - ## TEntity.WalkHover ```pascal function TEntity.WalkHover(action: TStringArray = []; attempts: Integer = 2): Boolean; ``` Method used to walk and hover a TEntity target if it's found on the {ref}`MainScreen` after walking. Example: ```pascal {$I WaspLib/main.simba} var npc: TEntity; begin Map.Setup([Chunk(Box(40,49,41,48), 0)]); npc := TEntity.Create(Map.Walker, [1,1,7], 8, [[10432, 37966]], ['Dominic Onion'], [EDot.NPC]); WriteLn npc.WalkHover(); end. ``` - - - ## TEntity.Click ```pascal function TEntity.Click(leftClick: Boolean = True; attempts: Integer = 2): Boolean; ``` Method used to click a TEntity target if it's found on the {ref}`MainScreen`. Example: ```pascal {$I WaspLib/main.simba} var npc: TEntity; begin Map.Setup([Chunk(Box(40,49,41,48), 0)]); npc := TEntity.Create(Map.Walker, [1,1,7], 8, [[10432, 37966]], ['Dominic Onion'], [EDot.NPC]); WriteLn npc.Click(); end. ``` - - - ## TEntity.Interact ```pascal function TEntity.Interact(action: TStringArray; attempts: Integer = 2): Boolean; ``` Method used to select an option on a TEntity target if it's found on the {ref}`MainScreen`. Example: ```pascal {$I WaspLib/main.simba} var npc: TEntity; begin Map.Setup([Chunk(Box(40,49,41,48), 0)]); npc := TEntity.Create(Map.Walker, [1,1,7], 8, [[10432, 37966]], ['Dominic Onion'], [EDot.NPC]); WriteLn npc.Interact(['Dream']); end. ``` - - - ## TEntity.WalkClick ```pascal function TEntity.WalkClick(leftClick: Boolean = True; attempts: Integer = 2): Boolean; ``` Method used to walk and click a TEntity target if it's found on the {ref}`MainScreen`. Example: ```pascal {$I WaspLib/main.simba} var npc: TEntity; begin Map.Setup([Chunk(Box(40,49,41,48), 0)]); npc := TEntity.Create(Map.Walker, [1,1,7], 8, [[10432, 37966]], ['Dominic Onion'], [EDot.NPC]); WriteLn npc.WalkClick(); end. ``` - - - ## TEntity.WalkInteract ```pascal function TEntity.WalkInteract(action: TStringArray; attempts: Integer = 2): Boolean; ``` Method used to walk and select an option on a TEntity target if it's found on the mainscreen. Example: ```pascal {$I WaspLib/main.simba} var npc: TEntity; begin Map.Setup([Chunk(Box(40,49,41,48), 0)]); npc := TEntity.Create(Map.Walker, [1,1,7], 8, [[10432, 37966]], ['Dominic Onion'], [EDot.NPC]); WriteLn npc.WalkInteract(['Dream']); end. ``` - - - ## DrawEntity ```pascal procedure TImage.DrawEntity(const entity: TEntity; alpha: Byte = $C8); procedure TExternalCanvas.DrawEntity(const entity: TEntity; alpha: Byte = $C8); ``` Helper methods to debug TEntitys. - - - ## ShowOnTarget TEntity ```pascal procedure ShowOnTarget(entity: TEntity); overload; ``` Shows an image of the target with the `TEntity` drawn on it. - - - ## ShowOnTarget TEntityArray ```pascal procedure ShowOnTarget(entities: TEntityArray); overload; ``` Shows an image of the target with the `TEntityArray` drawn on it.