entitywrap
This commit is contained in:
parent
7d0af8c413
commit
77ca6d3145
22
src/entitywrap.cpp
Normal file
22
src/entitywrap.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* entitywrap.cpp
|
||||
*
|
||||
* Created on: Mar 18, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#include "entitywrap.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
EntityWrapper::EntityWrapper(int idx) : idx(idx) {}
|
||||
|
||||
bool EntityWrapper::good() const {
|
||||
return idx < g_IEntityList->GetHighestEntityIndex() && g_IEntityList->GetClientEntity(idx);
|
||||
}
|
||||
|
||||
IClientEntity* EntityWrapper::operator ->() const {
|
||||
IClientEntity* ret = g_IEntityList->GetClientEntity(idx);
|
||||
if (!ret) throw std::runtime_error("referencing null entity");
|
||||
return ret;
|
||||
}
|
23
src/entitywrap.h
Normal file
23
src/entitywrap.h
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* entitywrap.h
|
||||
*
|
||||
* Created on: Mar 18, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#ifndef ENTITYWRAP_H_
|
||||
#define ENTITYWRAP_H_
|
||||
|
||||
class IClientEntity;
|
||||
|
||||
class EntityWrapper {
|
||||
public:
|
||||
EntityWrapper(int idx);
|
||||
|
||||
bool good() const;
|
||||
IClientEntity* operator->() const;
|
||||
|
||||
const int idx;
|
||||
};
|
||||
|
||||
#endif /* ENTITYWRAP_H_ */
|
Reference in New Issue
Block a user