Difference between revisions of "Script/Entity"
From SF3
(Created page with "==class Entity== === Class Methods === {| border='0' style ='border:solid 1px #eeeedd; color: black; width: 1200px;background-color: #ffffcc;' cellspacing='0' cellpadding='7'...") |
(→Class Methods) |
||
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
==class Entity== | ==class Entity== | ||
+ | Represents a reference to an entity in the game world (e.g. a building, creature, etc.). | ||
+ | An instance of this class acts like a weak pointer to an existing entity in the game world and provides an interface to interact with it. | ||
+ | Before interacting with the entity, you should call Exists() in order to check if the entity actually (still) exists. | ||
+ | IMPORTANT: This class must NOT be stored as a class member. If you want to store the entity for later reference, store the id | ||
+ | obtained by GetId instead. You can then later retrieve the entity from the LevelReference class by calling GetEntityById. | ||
=== Class Methods === | === Class Methods === | ||
{| border='0' style ='border:solid 1px #eeeedd; color: black; width: 1200px;background-color: #ffffcc;' cellspacing='0' cellpadding='7' | {| border='0' style ='border:solid 1px #eeeedd; color: black; width: 1200px;background-color: #ffffcc;' cellspacing='0' cellpadding='7' | ||
Line 31: | Line 36: | ||
| style='color: black; width: 90%; line-height: 0.8;' | '''Exists''' () const | | style='color: black; width: 90%; line-height: 0.8;' | '''Exists''' () const | ||
|- | |- | ||
+ | | | ||
+ | | style = 'color: #505050; line-height: 0.5;' |''does the entity actually exist? (always check this before doing anything with the entity!)'' | ||
|- | |- | ||
| style='color: blue; width: 10%; text-align:right;line-height: 0.8;' | [[../BasicDataTypes|uint]] | | style='color: blue; width: 10%; text-align:right;line-height: 0.8;' | [[../BasicDataTypes|uint]] | ||
| style='color: black; width: 90%; line-height: 0.8;' | '''GetId''' () const | | style='color: black; width: 90%; line-height: 0.8;' | '''GetId''' () const | ||
|- | |- | ||
+ | | | ||
+ | | style = 'color: #505050; line-height: 0.5;' |''get persistent entity id, use this to save the entity for later reference.'' | ||
|- | |- | ||
| style='color: blue; width: 10%; text-align:right;line-height: 0.8;' | [[../BasicDataTypes|uint8]] | | style='color: blue; width: 10%; text-align:right;line-height: 0.8;' | [[../BasicDataTypes|uint8]] | ||
| style='color: black; width: 90%; line-height: 0.8;' | '''GetFaction''' () const | | style='color: black; width: 90%; line-height: 0.8;' | '''GetFaction''' () const | ||
|- | |- | ||
+ | | | ||
+ | | style = 'color: #505050; line-height: 0.5;' |''get owner faction'' | ||
|- | |- | ||
| style='color: blue; width: 10%; text-align:right;line-height: 0.8;' | [[../BasicDataTypes|void]] | | style='color: blue; width: 10%; text-align:right;line-height: 0.8;' | [[../BasicDataTypes|void]] | ||
| style='color: black; width: 90%; line-height: 0.8;' | '''SetFaction''' (const [[../BasicDataTypes|uint8]] ''_Faction'') | | style='color: black; width: 90%; line-height: 0.8;' | '''SetFaction''' (const [[../BasicDataTypes|uint8]] ''_Faction'') | ||
|- | |- | ||
+ | | | ||
+ | | style = 'color: #505050; line-height: 0.5;' |''set owner faction'' | ||
|- | |- | ||
− | | style='color: blue; width: 10%; text-align:right;line-height: 0.8;' | [[../ | + | | style='color: blue; width: 10%; text-align:right;line-height: 0.8;' | [[../LogicEnums#EEntityType|EEntityType]] |
| style='color: black; width: 90%; line-height: 0.8;' | '''GetEntityType''' () const | | style='color: black; width: 90%; line-height: 0.8;' | '''GetEntityType''' () const | ||
|- | |- | ||
+ | | | ||
+ | | style = 'color: #505050; line-height: 0.5;' |''get entity type'' | ||
|- | |- | ||
| style='color: blue; width: 10%; text-align:right;line-height: 0.8;' | [[../BasicDataTypes|bool]] | | style='color: blue; width: 10%; text-align:right;line-height: 0.8;' | [[../BasicDataTypes|bool]] | ||
| style='color: black; width: 90%; line-height: 0.8;' | '''IsEnabled''' () const | | style='color: black; width: 90%; line-height: 0.8;' | '''IsEnabled''' () const | ||
|- | |- | ||
+ | | | ||
+ | | style = 'color: #505050; line-height: 0.5;' |''whether the entity is currently enabled (i.e. is visible in the game world)'' | ||
|- | |- | ||
| style='color: blue; width: 10%; text-align:right;line-height: 0.8;' | [[../BasicDataTypes|void]] | | style='color: blue; width: 10%; text-align:right;line-height: 0.8;' | [[../BasicDataTypes|void]] | ||
| style='color: black; width: 90%; line-height: 0.8;' | '''Enable''' (const [[../BasicDataTypes|bool]] ''_bEnabled'') | | style='color: black; width: 90%; line-height: 0.8;' | '''Enable''' (const [[../BasicDataTypes|bool]] ''_bEnabled'') | ||
|- | |- | ||
+ | | | ||
+ | | style = 'color: #505050; line-height: 0.5;' |''enabled or disable the entity'' | ||
|- | |- | ||
| style='color: blue; width: 10%; text-align:right;line-height: 0.8;' | [[../BasicDataTypes|bool]] | | style='color: blue; width: 10%; text-align:right;line-height: 0.8;' | [[../BasicDataTypes|bool]] | ||
| style='color: black; width: 90%; line-height: 0.8;' | '''IsInteractive''' () const | | style='color: black; width: 90%; line-height: 0.8;' | '''IsInteractive''' () const | ||
|- | |- | ||
+ | | | ||
+ | | style = 'color: #505050; line-height: 0.5;' |''can the entity be interacted with?'' | ||
|- | |- | ||
| style='color: blue; width: 10%; text-align:right;line-height: 0.8;' | [[../BasicDataTypes|void]] | | style='color: blue; width: 10%; text-align:right;line-height: 0.8;' | [[../BasicDataTypes|void]] | ||
| style='color: black; width: 90%; line-height: 0.8;' | '''SetInteractive''' (const [[../BasicDataTypes|bool]] ''_bInteractive'') | | style='color: black; width: 90%; line-height: 0.8;' | '''SetInteractive''' (const [[../BasicDataTypes|bool]] ''_bInteractive'') | ||
|- | |- | ||
+ | | | ||
+ | | style = 'color: #505050; line-height: 0.5;' |''set whether the entity can be interacted with'' | ||
+ | |- | ||
+ | | style='color: blue; width: 10%; text-align:right;line-height: 0.8;' | [[../BasicDataTypes|bool]] | ||
+ | | style='color: black; width: 90%; line-height: 1.0;' | '''IsSelectable''' () const | ||
+ | |- | ||
+ | | | ||
+ | | style = 'color: #505050; line-height: 0.5;' |''can the entity (theoretically) be selected by the player?'' | ||
+ | |- | ||
+ | | style='color: blue; width: 10%; text-align:right;line-height: 0.8;' | [[../BasicDataTypes|void]] | ||
+ | | style='color: black; width: 90%; line-height: 1.0;' | '''SetSelectable''' (const [[../BasicDataTypes|bool]] ''_bSelectable'') | ||
+ | |- | ||
+ | | | ||
+ | | style = 'color: #505050; line-height: 0.5;' |''set whether the entity can be selected by the player | ||
+ | (note that depending on the type of entity, there may be additional checks preventing the entity from being selected)'' | ||
+ | |- | ||
+ | | style='color: blue; width: 10%; text-align:right;line-height: 0.8;' | [[../BasicDataTypes|bool]] | ||
+ | | style='color: black; width: 90%; line-height: 1.0;' | '''IsBusy''' () const | ||
+ | |- | ||
+ | | | ||
+ | | style = 'color: #505050; line-height: 0.5;' |''is the entity currently marked as busy?'' | ||
+ | |- | ||
+ | | style='color: blue; width: 10%; text-align:right;line-height: 0.8;' | [[../BasicDataTypes|void]] | ||
+ | | style='color: black; width: 90%; line-height: 1.0;' | '''SetBusy''' (const [[../BasicDataTypes|bool]] ''_bBusy'') | ||
+ | |- | ||
+ | | | ||
+ | | style = 'color: #505050; line-height: 0.5;' |''mark the entity as busy'' | ||
+ | |- | ||
+ | | style='color: blue; width: 10%; text-align:right;line-height: 0.8;' | [[../BasicDataTypes|bool]] | ||
+ | | style='color: black; width: 90%; line-height: 1.0;' | '''HasInspectionText''' () const | ||
+ | |- | ||
+ | | | ||
+ | | style = 'color: #505050; line-height: 0.5;' |''check whether the entity currently has an inspection text'' | ||
+ | |- | ||
+ | | style='color: blue; width: 10%; text-align:right;line-height: 0.8;' | [[../BasicDataTypes|void]] | ||
+ | | style='color: black; width: 90%; line-height: 1.0;' | '''SetInspectionText''' (const [[../BasicDataTypes|uint]] ''_uTextId'') | ||
+ | |- | ||
+ | | | ||
+ | | style = 'color: #505050; line-height: 0.5;' |''make the entity inspectable and set the text to be displayed upon inspection'' | ||
|- | |- | ||
| style='color: blue; width: 10%; text-align:right;line-height: 0.8;' | [[../BasicDataTypes|bool]] | | style='color: blue; width: 10%; text-align:right;line-height: 0.8;' | [[../BasicDataTypes|bool]] | ||
| style='color: black; width: 90%; line-height: 0.8;' | '''CanBeAttacked''' () const | | style='color: black; width: 90%; line-height: 0.8;' | '''CanBeAttacked''' () const | ||
|- | |- | ||
+ | | | ||
+ | | style = 'color: #505050; line-height: 0.5;' |''can the entity be attacked?'' | ||
|- | |- | ||
| style='color: blue; width: 10%; text-align:right;line-height: 0.8;' | [[../BasicDataTypes|void]] | | style='color: blue; width: 10%; text-align:right;line-height: 0.8;' | [[../BasicDataTypes|void]] | ||
| style='color: black; width: 90%; line-height: 0.8;' | '''SetAttackable''' (const [[../BasicDataTypes|bool]] ''_bAttackable'') | | style='color: black; width: 90%; line-height: 0.8;' | '''SetAttackable''' (const [[../BasicDataTypes|bool]] ''_bAttackable'') | ||
|- | |- | ||
+ | | | ||
+ | | style = 'color: #505050; line-height: 0.5;' |''set whether the entity can be attacked'' | ||
|} | |} |
Latest revision as of 10:02, 11 May 2017
class Entity
Represents a reference to an entity in the game world (e.g. a building, creature, etc.).
An instance of this class acts like a weak pointer to an existing entity in the game world and provides an interface to interact with it. Before interacting with the entity, you should call Exists() in order to check if the entity actually (still) exists. IMPORTANT: This class must NOT be stored as a class member. If you want to store the entity for later reference, store the id obtained by GetId instead. You can then later retrieve the entity from the LevelReference class by calling GetEntityById.
Class Methods
Entity& | operator= (const Entity&in) |
bool | operator== (const Entity&in) |
Building | opConv () const |
Creature | opConv () const |
LogicObject | opConv () const |
ResourceDeposit | opConv () const |
bool | Exists () const |
does the entity actually exist? (always check this before doing anything with the entity!) | |
uint | GetId () const |
get persistent entity id, use this to save the entity for later reference. | |
uint8 | GetFaction () const |
get owner faction | |
void | SetFaction (const uint8 _Faction) |
set owner faction | |
EEntityType | GetEntityType () const |
get entity type | |
bool | IsEnabled () const |
whether the entity is currently enabled (i.e. is visible in the game world) | |
void | Enable (const bool _bEnabled) |
enabled or disable the entity | |
bool | IsInteractive () const |
can the entity be interacted with? | |
void | SetInteractive (const bool _bInteractive) |
set whether the entity can be interacted with | |
bool | IsSelectable () const |
can the entity (theoretically) be selected by the player? | |
void | SetSelectable (const bool _bSelectable) |
set whether the entity can be selected by the player
(note that depending on the type of entity, there may be additional checks preventing the entity from being selected) | |
bool | IsBusy () const |
is the entity currently marked as busy? | |
void | SetBusy (const bool _bBusy) |
mark the entity as busy | |
bool | HasInspectionText () const |
check whether the entity currently has an inspection text | |
void | SetInspectionText (const uint _uTextId) |
make the entity inspectable and set the text to be displayed upon inspection | |
bool | CanBeAttacked () const |
can the entity be attacked? | |
void | SetAttackable (const bool _bAttackable) |
set whether the entity can be attacked |