Class cse491::Entity
Inherits the following classes: cse491::CoreObject
Inherited by the following classes: cse491::AgentBase, cse491::ItemBase
Public Functions
Type | Name |
---|---|
Entity & | AddItem (size_t id) |
Entity & | AddItem (Entity & item) |
virtual void | Deserialize_impl (std::istream & is) override Serialize entity-specific values. |
Entity (size_t id, const std::string & name) |
|
Entity (const Entity &) = delete |
|
Entity (Entity &&) = default |
|
size_t | GetGridID () const |
size_t | GetID () const |
std::vector< size_t > | GetInventory () const |
const std::string & | GetName () const |
size_t | GetNumProperties () const How many properties does this entity have? |
GridPosition | GetPosition () const |
const T & | GetProperty (const std::string & name) const Return the current value of the specified property. |
property_map_t & | GetPropertyMap () return the property map for the entity |
PropertyType | GetPropertyType (const std::string & name) const |
WorldBase & | GetWorld () const |
bool | HasItem (size_t id) const Inventory Management. |
bool | HasProperty (const std::string & name) const Does this agent have a property with the specified name? |
bool | HasWorld () const |
virtual bool | IsAgent () const Is Entity an autonomous agent? |
virtual bool | IsInterface () const Is Entity an interface for a human? |
virtual bool | IsItem () const Is Entity an item? |
bool | IsOnGrid (size_t in_grid_id) const |
Entity & | RemoveItem (size_t id) |
Entity & | RemoveItem (Entity & item) |
Entity & | RemoveProperty (const std::string & name) Completely remove a property from an Entity . |
virtual void | Serialize_impl (std::ostream & os) override const Serialize entity-specific values. |
Entity & | SetName (const std::string in_name) |
Entity & | SetPosition (GridPosition in_pos, size_t grid_id=0) |
Entity & | SetPosition (double x, double y) |
Entity & | SetProperties () Allow for setting multiple properties at once. |
Entity & | SetProperties (const std::string & name, VALUE_T && value, EXTRA_Ts &&... extras) |
Entity & | SetProperty (const std::string & name, const T & value) Change the value of the specified property (will create if needed) |
virtual Entity & | SetWorld (WorldBase & in_world) |
Entity & | operator= (const Entity &) = delete |
Entity & | operator= (Entity &&) = delete |
virtual | ~Entity () = default |
Public Functions inherited from cse491::CoreObject
Type | Name |
---|---|
void | Deserialize (std::istream & is) Restore the state of this object, extracting it from the provided stream. |
bool | Deserialize (std::string filename) A version of Deserialize that accepts a filename to read this object from. |
std::string | GetTypeName () const Access the derived name for this type. |
void | Serialize (std::ostream & os) const Store the current state of this object for later extraction. |
bool | Serialize (std::string filename) const A version of Serialize that accepts a filename for saving just this object. |
auto | operator<=> (const CoreObject &) const |
virtual | ~CoreObject () |
Protected Types
Type | Name |
---|---|
typedef std::unordered_map< std::string, std::unique_ptr< PropertyBase > > | property_map_t Every entity can have a simple set of properties (with values) associated with it. |
Protected Attributes
Type | Name |
---|---|
size_t | grid_id = = 0 Which grid is this entity on? |
size_t | id = = 0 Unique ID for this entity (0 is used for "no ID") |
std::vector< size_t > | inventory What entity ids are held by this entity? |
std::string | name = = "" Name for this entity (E.g., "Player 1" or "+2 Sword") |
GridPosition | position Where on the grid is this entity? |
property_map_t | property_map |
Protected Functions
Type | Name |
---|---|
Property< T > & | AsProperty (const std::string & name) const |
Protected Functions inherited from cse491::CoreObject
Type | Name |
---|---|
virtual void | Deserialize_impl (std::istream &) = 0 Override to restore the state of this object from the provided stream. |
bool | EndDeserialize (std::istream & is) Set up end of the deserialization for this class (does type checking) |
void | EndSerialize (std::ostream & os) const Set up end of the serialization for this class (allows checking later) |
virtual std::string | GetTypeName_impl () const = 0 Override to allow access the derived name for this type. |
virtual void | Serialize_impl (std::ostream &) const = 0 Override to store the current state of this object for later extraction. |
bool | StartDeserialize (std::istream & is) Set up beginning of the deserialization for this class (does type checking) |
void | StartSerialize (std::ostream & os) const Set up beginning of the serialization for this class (allows checking later) |
Public Functions Documentation
function AddItem [1/2]
Entity & cse491::Entity::AddItem (
size_t id
)
function AddItem [2/2]
inline Entity & cse491::Entity::AddItem (
Entity & item
)
function Deserialize_impl
Serialize entity-specific values.
inline virtual void cse491::Entity::Deserialize_impl (
std::istream & is
) override
Parameters:
os
ostream to write contents to.
Implements cse491::CoreObject::Deserialize_impl
function Entity [1/3]
inline cse491::Entity::Entity (
size_t id,
const std::string & name
)
function Entity [2/3]
cse491::Entity::Entity (
const Entity &
) = delete
function Entity [3/3]
cse491::Entity::Entity (
Entity &&
) = default
function GetGridID
inline size_t cse491::Entity::GetGridID () const
function GetID
inline size_t cse491::Entity::GetID () const
function GetInventory
inline std::vector< size_t > cse491::Entity::GetInventory () const
function GetName
inline const std::string & cse491::Entity::GetName () const
function GetNumProperties
inline size_t cse491::Entity::GetNumProperties () const
function GetPosition
inline GridPosition cse491::Entity::GetPosition () const
function GetProperty
template<typename T typename T>
inline const T & cse491::Entity::GetProperty (
const std::string & name
) const
function GetPropertyMap
inline property_map_t & cse491::Entity::GetPropertyMap ()
function GetPropertyType
inline PropertyType cse491::Entity::GetPropertyType (
const std::string & name
) const
function GetWorld
inline WorldBase & cse491::Entity::GetWorld () const
function HasItem
inline bool cse491::Entity::HasItem (
size_t id
) const
function HasProperty
inline bool cse491::Entity::HasProperty (
const std::string & name
) const
function HasWorld
inline bool cse491::Entity::HasWorld () const
function IsAgent
inline virtual bool cse491::Entity::IsAgent () const
function IsInterface
inline virtual bool cse491::Entity::IsInterface () const
function IsItem
inline virtual bool cse491::Entity::IsItem () const
function IsOnGrid
inline bool cse491::Entity::IsOnGrid (
size_t in_grid_id
) const
function RemoveItem [1/2]
Entity & cse491::Entity::RemoveItem (
size_t id
)
function RemoveItem [2/2]
inline Entity & cse491::Entity::RemoveItem (
Entity & item
)
function RemoveProperty
inline Entity & cse491::Entity::RemoveProperty (
const std::string & name
)
function Serialize_impl
Serialize entity-specific values.
inline virtual void cse491::Entity::Serialize_impl (
std::ostream & os
) override const
Parameters:
os
ostream to write contents to.
Implements cse491::CoreObject::Serialize_impl
function SetName
inline Entity & cse491::Entity::SetName (
const std::string in_name
)
function SetPosition [1/2]
Entity & cse491::Entity::SetPosition (
GridPosition in_pos,
size_t grid_id=0
)
function SetPosition [2/2]
inline Entity & cse491::Entity::SetPosition (
double x,
double y
)
function SetProperties [1/2]
inline Entity & cse491::Entity::SetProperties ()
function SetProperties [2/2]
template<typename VALUE_T typename VALUE_T, typename... EXTRA_Ts>
inline Entity & cse491::Entity::SetProperties (
const std::string & name,
VALUE_T && value,
EXTRA_Ts &&... extras
)
function SetProperty
template<typename T typename T>
inline Entity & cse491::Entity::SetProperty (
const std::string & name,
const T & value
)
function SetWorld
inline virtual Entity & cse491::Entity::SetWorld (
WorldBase & in_world
)
function operator=
Entity & cse491::Entity::operator= (
const Entity &
) = delete
function operator=
Entity & cse491::Entity::operator= (
Entity &&
) = delete
function ~Entity
virtual cse491::Entity::~Entity () = default
Protected Types Documentation
typedef property_map_t
using property_map_t = std::unordered_map<std::string, std::unique_ptr<PropertyBase> >;
Protected Attributes Documentation
variable grid_id
size_t grid_id;
variable id
size_t id;
variable inventory
std::vector<size_t> inventory;
variable name
std::string name;
variable position
GridPosition position;
variable property_map
property_map_t property_map;
Protected Functions Documentation
function AsProperty
template<typename T typename T>
inline Property < T > & cse491::Entity::AsProperty (
const std::string & name
) const
The documentation for this class was generated from the following file source/core/Entity.hpp