53 lines
1.1 KiB
C
53 lines
1.1 KiB
C
#ifndef ENTITY_H
|
|
#define ENTITY_H
|
|
#include "vector.h"
|
|
#include "tile.h"
|
|
|
|
typedef int(*entity_func)(void*);
|
|
typedef int(*entity_update_func)(int, void*);
|
|
|
|
// Entity network transaction.
|
|
typedef struct {
|
|
int id;
|
|
int action;
|
|
int userdataSize;
|
|
void* userdata;
|
|
} entity_transaction;
|
|
|
|
// Entity Callbacks
|
|
typedef struct {
|
|
entity_func init;
|
|
entity_update_func update;
|
|
entity_func free;
|
|
} entity_callbacks;
|
|
|
|
// Entity Struct
|
|
typedef struct {
|
|
int id;
|
|
const char* name;
|
|
const char* description;
|
|
tile tile;
|
|
vec2 position;
|
|
void* userdata;
|
|
entity_callbacks callback;
|
|
entity_transaction ta;
|
|
} entity;
|
|
|
|
entity* CreateEntity(const char* name, const char* description);
|
|
int EntityAddCallbacks(entity* e, entity_callbacks cb);
|
|
int EntitySetUserdat(entity* e, void* userdata);
|
|
|
|
// Gets
|
|
const char* GetEntityDescription(entity* e);
|
|
const char* GetEntityName(entity* e);
|
|
|
|
// Entity minipulation
|
|
int EntityInit(entity* e);
|
|
int EntityUpdate(entity* e, int action, void* userdata);
|
|
int EntityFree(entity* e);
|
|
|
|
// Network
|
|
int EntityTransaction(entity* e);
|
|
|
|
#endif
|