Stardew Engine
Loading...
Searching...
No Matches
Entities.h File Reference
#include "Game2DLayer.h"
#include "DynArray.h"
#include "DrawContext.h"
#include "InputContext.h"
#include "Physics2D.h"
#include <box2d/box2d.h>
#include <stdbool.h>
Include dependency graph for Entities.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  EntitySerializerPair
 
struct  Sprite
 
struct  StaticCollider
 
struct  DynamicCollider
 
struct  TextSprite
 
struct  AnimatedSprite
 
struct  Component2D
 An entity component tagged union - there are a fixed number built into the engine. More...
 
struct  Entity2D
 

Macros

#define MAX_COMPONENTS   16
 

Typedefs

typedef void(* Entity2DOnInitFn) (struct Entity2D *pEnt, struct GameFrameworkLayer *pLayer, DrawContext *pDrawCtx, InputContext *pInputCtx)
 
typedef void(* Entity2DUpdateFn) (struct Entity2D *pEnt, struct GameFrameworkLayer *pLayer, float deltaT)
 
typedef void(* Entity2DUpdatePostPhysicsFn) (struct Entity2D *pEnt, struct GameFrameworkLayer *pLayer, float deltaT)
 
typedef void(* Entity2DDrawFn) (struct Entity2D *pEnt, struct GameFrameworkLayer *pLayer, struct Transform2D *pCam, VECTOR(Worldspace2DVert) *outVerts, VECTOR(VertIndexT) *outIndices, VertIndexT *pNextIndex)
 
typedef void(* Entity2DInputFn) (struct Entity2D *pEnt, struct GameFrameworkLayer *pLayer, InputContext *context)
 
typedef void(* Entity2DOnDestroyFn) (struct Entity2D *pEnt, struct GameFrameworkLayer *pLayer)
 
typedef void(* Entity2DGetBoundingBoxFn) (struct Entity2D *pEnt, struct GameFrameworkLayer *pLayer, vec2 outTL, vec2 outBR)
 
typedef float(* Entity2DGetPreDrawSortValueFn) (struct Entity2D *pEnt)
 lower values drawn first
 
typedef void(* EntityDeserializeFn) (struct BinarySerializer *bs, struct Entity2D *pOutEnt, struct GameLayer2DData *pData)
 
typedef void(* EntitySerializeFn) (struct BinarySerializer *bs, struct Entity2D *pInEnt, struct GameLayer2DData *pData)
 
typedef void(* RegisterGameEntitiesFn) (void)
 
typedef void(* OnSensorShapeOverlapBeginFn) (struct GameFrameworkLayer *pLayer, HEntity2D hOverlappingEntity, HEntity2D thisSensorEntity)
 
typedef void(* OnSensorShapeOverlapEndFn) (struct GameFrameworkLayer *pLayer, HEntity2D hOverlappingEntity, HEntity2D thisSensorEntity)
 
typedef void(* PrintEntityInfoExtenderFn) (struct Entity2D *pInEnt)
 
typedef i32 EntityType
 
typedef bool(* Entity2DIterator) (struct Entity2D *pEnt, int i, void *pUser)
 both serialize and deserialize
 

Enumerations

enum  ComponentType {
  ETE_Sprite , ETE_StaticCollider , ETE_DynamicCollider , ETE_TextSprite ,
  ETE_SpriteAnimator , ETE_Last
}
 types built into the engine More...
 
enum  EngineBuiltinEntityType {
  EBET_StaticColliderRect , EBET_StaticColliderCircle , EBET_StaticColliderPoly , EBET_StaticColliderEllipse ,
  EBET_Last
}
 

Functions

void Et2D_RegisterEntityType (u32 typeID, struct EntitySerializerPair *pair)
 Games using the engine should call this to add types of entity to be serialized.
 
void Et2D_Init (RegisterGameEntitiesFn registerGameEntities)
 
HEntity2D Et2D_AddEntity (struct Entity2DCollection *pCollection, struct Entity2D *pEnt)
 
void Et2D_DestroyEntity (struct GameFrameworkLayer *pLayer, struct Entity2DCollection *pCollection, HEntity2D hEnt)
 
struct Entity2DEt2D_GetEntity (struct Entity2DCollection *pCollection, HEntity2D hEnt)
 
void Et2D_IterateEntities (struct Entity2DCollection *pCollection, Entity2DIterator itr, void *pUser)
 
void Et2D_SerializeEntities (struct Entity2DCollection *pCollection, struct BinarySerializer *bs, struct GameLayer2DData *pData, int objectLayer)
 
void Et2D_DeserializeCommon (struct BinarySerializer *bs, struct Entity2D *pOutEnt)
 
void Et2D_SerializeCommon (struct BinarySerializer *bs, struct Entity2D *pInEnt)
 
void Et2D_InitCollection (struct Entity2DCollection *pCollection)
 
void Et2D_DestroyCollection (struct Entity2DCollection *pCollection, struct GameFrameworkLayer *pLayer)
 
void Et2D_PrintEntitiesInfo (struct Entity2DCollection *pCollection)
 
void Entity2DOnInit (struct Entity2D *pEnt, struct GameFrameworkLayer *pLayer, DrawContext *pDrawCtx, InputContext *pInputCtx)
 Default base implementations, override with own behavior and then call these at the end.
 
void Entity2DUpdate (struct Entity2D *pEnt, struct GameFrameworkLayer *pLayer, float deltaT)
 
void Entity2DUpdatePostPhysics (struct Entity2D *pEnt, struct GameFrameworkLayer *pLayer, float deltaT)
 
void Entity2DDraw (struct Entity2D *pEnt, struct GameFrameworkLayer *pLayer, struct Transform2D *pCam, VECTOR(Worldspace2DVert) *outVerts, VECTOR(VertIndexT) *outIndices, VertIndexT *pNextIndex)
 
void Entity2DInput (struct Entity2D *pEnt, struct GameFrameworkLayer *pLayer, InputContext *context)
 
void Entity2DOnDestroy (struct Entity2D *pEnt, struct GameFrameworkLayer *pLayer)
 
void Entity2DGetBoundingBox (struct Entity2D *pEnt, struct GameFrameworkLayer *pLayer, vec2 outTL, vec2 outBR)
 
float Entity2DGetSortVal (struct Entity2D *pEnt)
 
void Et2D_PopulateCommonHandlers (struct Entity2D *pEnt)
 

Macro Definition Documentation

◆ MAX_COMPONENTS

#define MAX_COMPONENTS   16

Typedef Documentation

◆ Entity2DDrawFn

typedef void(* Entity2DDrawFn) (struct Entity2D *pEnt, struct GameFrameworkLayer *pLayer, struct Transform2D *pCam, VECTOR(Worldspace2DVert) *outVerts, VECTOR(VertIndexT) *outIndices, VertIndexT *pNextIndex)

◆ Entity2DGetBoundingBoxFn

typedef void(* Entity2DGetBoundingBoxFn) (struct Entity2D *pEnt, struct GameFrameworkLayer *pLayer, vec2 outTL, vec2 outBR)

◆ Entity2DGetPreDrawSortValueFn

typedef float(* Entity2DGetPreDrawSortValueFn) (struct Entity2D *pEnt)

lower values drawn first

◆ Entity2DInputFn

typedef void(* Entity2DInputFn) (struct Entity2D *pEnt, struct GameFrameworkLayer *pLayer, InputContext *context)

◆ Entity2DIterator

typedef bool(* Entity2DIterator) (struct Entity2D *pEnt, int i, void *pUser)

both serialize and deserialize

return value == should continue iterating

◆ Entity2DOnDestroyFn

typedef void(* Entity2DOnDestroyFn) (struct Entity2D *pEnt, struct GameFrameworkLayer *pLayer)

◆ Entity2DOnInitFn

typedef void(* Entity2DOnInitFn) (struct Entity2D *pEnt, struct GameFrameworkLayer *pLayer, DrawContext *pDrawCtx, InputContext *pInputCtx)

◆ Entity2DUpdateFn

typedef void(* Entity2DUpdateFn) (struct Entity2D *pEnt, struct GameFrameworkLayer *pLayer, float deltaT)

◆ Entity2DUpdatePostPhysicsFn

typedef void(* Entity2DUpdatePostPhysicsFn) (struct Entity2D *pEnt, struct GameFrameworkLayer *pLayer, float deltaT)

◆ EntityDeserializeFn

typedef void(* EntityDeserializeFn) (struct BinarySerializer *bs, struct Entity2D *pOutEnt, struct GameLayer2DData *pData)

◆ EntitySerializeFn

typedef void(* EntitySerializeFn) (struct BinarySerializer *bs, struct Entity2D *pInEnt, struct GameLayer2DData *pData)

◆ EntityType

typedef i32 EntityType

◆ OnSensorShapeOverlapBeginFn

typedef void(* OnSensorShapeOverlapBeginFn) (struct GameFrameworkLayer *pLayer, HEntity2D hOverlappingEntity, HEntity2D thisSensorEntity)

◆ OnSensorShapeOverlapEndFn

typedef void(* OnSensorShapeOverlapEndFn) (struct GameFrameworkLayer *pLayer, HEntity2D hOverlappingEntity, HEntity2D thisSensorEntity)

◆ PrintEntityInfoExtenderFn

typedef void(* PrintEntityInfoExtenderFn) (struct Entity2D *pInEnt)

◆ RegisterGameEntitiesFn

typedef void(* RegisterGameEntitiesFn) (void)

Enumeration Type Documentation

◆ ComponentType

types built into the engine

Enumerator
ETE_Sprite 
ETE_StaticCollider 
ETE_DynamicCollider 
ETE_TextSprite 
ETE_SpriteAnimator 
ETE_Last 

◆ EngineBuiltinEntityType

Enumerator
EBET_StaticColliderRect 
EBET_StaticColliderCircle 
EBET_StaticColliderPoly 
EBET_StaticColliderEllipse 
EBET_Last 

Function Documentation

◆ Entity2DDraw()

void Entity2DDraw ( struct Entity2D pEnt,
struct GameFrameworkLayer pLayer,
struct Transform2D pCam,
VECTOR(Worldspace2DVert) *  outVerts,
VECTOR(VertIndexT) *  outIndices,
VertIndexT pNextIndex 
)

◆ Entity2DGetBoundingBox()

void Entity2DGetBoundingBox ( struct Entity2D pEnt,
struct GameFrameworkLayer pLayer,
vec2  outTL,
vec2  outBR 
)

◆ Entity2DGetSortVal()

float Entity2DGetSortVal ( struct Entity2D pEnt)

◆ Entity2DInput()

void Entity2DInput ( struct Entity2D pEnt,
struct GameFrameworkLayer pLayer,
InputContext context 
)

◆ Entity2DOnDestroy()

void Entity2DOnDestroy ( struct Entity2D pEnt,
struct GameFrameworkLayer pLayer 
)

◆ Entity2DOnInit()

void Entity2DOnInit ( struct Entity2D pEnt,
struct GameFrameworkLayer pLayer,
DrawContext pDrawCtx,
InputContext pInputCtx 
)

Default base implementations, override with own behavior and then call these at the end.

◆ Entity2DUpdate()

void Entity2DUpdate ( struct Entity2D pEnt,
struct GameFrameworkLayer pLayer,
float  deltaT 
)

◆ Entity2DUpdatePostPhysics()

void Entity2DUpdatePostPhysics ( struct Entity2D pEnt,
struct GameFrameworkLayer pLayer,
float  deltaT 
)

◆ Et2D_AddEntity()

HEntity2D Et2D_AddEntity ( struct Entity2DCollection pCollection,
struct Entity2D pEnt 
)
Parameters
pCollection- collection to add to
pEnt- Entity to add
bOwned- Does this host own the entity or is it owned by another player on the network, no effect if single player
Returns
Entity handle

◆ Et2D_DeserializeCommon()

void Et2D_DeserializeCommon ( struct BinarySerializer bs,
struct Entity2D pOutEnt 
)

◆ Et2D_DestroyCollection()

void Et2D_DestroyCollection ( struct Entity2DCollection pCollection,
struct GameFrameworkLayer pLayer 
)

◆ Et2D_DestroyEntity()

void Et2D_DestroyEntity ( struct GameFrameworkLayer pLayer,
struct Entity2DCollection pCollection,
HEntity2D  hEnt 
)
Parameters
pLayer
pCollection
hEnt

◆ Et2D_GetEntity()

struct Entity2D * Et2D_GetEntity ( struct Entity2DCollection pCollection,
HEntity2D  hEnt 
)
Parameters
pCollection
hEnt
Returns
- entity handle

◆ Et2D_Init()

void Et2D_Init ( RegisterGameEntitiesFn  registerGameEntities)

◆ Et2D_InitCollection()

void Et2D_InitCollection ( struct Entity2DCollection pCollection)

◆ Et2D_IterateEntities()

void Et2D_IterateEntities ( struct Entity2DCollection pCollection,
Entity2DIterator  itr,
void *  pUser 
)

◆ Et2D_PopulateCommonHandlers()

void Et2D_PopulateCommonHandlers ( struct Entity2D pEnt)

◆ Et2D_PrintEntitiesInfo()

void Et2D_PrintEntitiesInfo ( struct Entity2DCollection pCollection)

◆ Et2D_RegisterEntityType()

void Et2D_RegisterEntityType ( u32  typeID,
struct EntitySerializerPair pair 
)

Games using the engine should call this to add types of entity to be serialized.

Parameters
typeIDEntity type
pairpair of functions to serialize and deserialize

◆ Et2D_SerializeCommon()

void Et2D_SerializeCommon ( struct BinarySerializer bs,
struct Entity2D pInEnt 
)

◆ Et2D_SerializeEntities()

void Et2D_SerializeEntities ( struct Entity2DCollection pCollection,
struct BinarySerializer bs,
struct GameLayer2DData pData,
int  objectLayer 
)