Stardew Engine
Loading...
Searching...
No Matches
WfPlayer.h
Go to the documentation of this file.
1#ifndef WFPLAYER_H
2#define WFPLAYER_H
3
4#include <cglm/cglm.h>
5#include "WfEnums.h"
6#include "InputContext.h"
7
8
10struct Entity2D;
11struct Component2D;
12struct GameLayer2DData;
14
15#define NUM_ANIMATIONS NumDirections
16
17#define PLAYER_SPRITE_COMP_INDEX 3
18#define PLAYER_BG_SPRITE_COMP_START 1
19#define PLAYER_NUM_BG_SPRITES 2
20
21#define PLAYER_COLLIDER_COMP_INDEX 0
22
23
31
32/* layers on top of the base */
41
42/* layers behind the base */
49
65
72
74{
76 WfPD_Down = (1 << 1),
77 WfPD_Left = (1 << 2),
78 WfPD_Right = (1 << 3),
79};
80
82{
88
91
93
96 /* value I set this to is NOT meters per second, TODO: fix */
98
100
102
104
106
108
109 /*
110 its shit having to have this, the position to spawn the network player when it is initialized.
111 The network player is created in two steps, first they're deserialized into a player entity then the player entity is initialized.
112 We have to call WfMakeIntoPlayerEntityBase when it is initialized, and so must serialize args for it in the deserialize stage
113 */
114 struct
115 {
119
120
122
123 /* flags section */
126
128
129};
130
132
133struct WfAnimationSet* WfGetPlayerAnimationSet(struct Entity2D* pInPlayerEnt);
134
135void WfSetPlayerAnimationSet(struct Entity2D* pInPlayerEnt, const struct WfAnimationSet* pInSet);
136
137void WfDeSerializePlayerEntity(struct BinarySerializer* bs, struct Entity2D* pOutEnt, struct GameLayer2DData* pData);
138
139void WfSerializePlayerEntity(struct BinarySerializer* bs, struct Entity2D* pInEnt, struct GameLayer2DData* pData);
140
141void WfMakeIntoPlayerEntity(struct Entity2D* pInEnt, struct GameFrameworkLayer* pLayer, vec2 spawnAtGroundPos);
142
143struct WfPlayerEntData* WfGetPlayerEntData(struct Entity2D* pInEnt);
144
146
147void WfSetPlayerOverlayAnimations(enum WfDirection dir, struct GameFrameworkLayer* pLayer, struct WfPlayerEntData* pPlayerEntData, struct Entity2D* pEnt);
148
149void WfPlayerGetGroundContactPoint(struct Entity2D* pEnt, vec2 outPos);
150
151#endif
vec2 vec2 struct Entity2DCollection struct GameFrameworkLayer * pLayer
Definition EntityQuadTree.h:38
uint8_t u8
Definition IntTypes.h:6
uint32_t u32
Definition IntTypes.h:12
WfActionAnimation
an animation that plays and then finishes, returning back to the normal movement animations
Definition WfEnums.h:25
WfDirection
Definition WfEnums.h:14
struct Component2D * WfGetPlayerAnimationLayerComponent(struct Entity2D *pPlayer, enum WfAnimationLayerNames layer)
Definition WfPlayer.c:823
WfPlayerDirection
Definition WfPlayer.h:74
@ WfPD_Up
Definition WfPlayer.h:75
@ WfPD_Down
Definition WfPlayer.h:76
@ WfPD_Right
Definition WfPlayer.h:78
@ WfPD_Left
Definition WfPlayer.h:77
WfAnimationLayerNames
Definition WfPlayer.h:34
@ WfToolAnimationLayer
Definition WfPlayer.h:38
@ WfLegAnimationLayer
Definition WfPlayer.h:37
@ WfNumAnimationLayers
Definition WfPlayer.h:39
@ WfHairAnimationLayer
Definition WfPlayer.h:35
@ WfTorsoAnimationLayer
Definition WfPlayer.h:36
struct WfAnimationSet * WfGetPlayerAnimationSet(struct Entity2D *pInPlayerEnt)
Definition WfPlayer.c:806
void WfDeSerializePlayerEntity(struct BinarySerializer *bs, struct Entity2D *pOutEnt, struct GameLayer2DData *pData)
Definition WfPlayer.c:734
WfPlayerState
Definition WfPlayer.h:67
@ WfNumPlayerStates
Definition WfPlayer.h:70
@ WfWalking
Definition WfPlayer.h:68
@ WfAttacking
Definition WfPlayer.h:69
void WfSetPlayerOverlayAnimations(enum WfDirection dir, struct GameFrameworkLayer *pLayer, struct WfPlayerEntData *pPlayerEntData, struct Entity2D *pEnt)
Definition WfPlayer.c:231
void WfInitPlayer()
void WfMakeIntoPlayerEntity(struct Entity2D *pInEnt, struct GameFrameworkLayer *pLayer, vec2 spawnAtGroundPos)
Definition WfPlayer.c:801
void WfSerializePlayerEntity(struct BinarySerializer *bs, struct Entity2D *pInEnt, struct GameLayer2DData *pData)
Definition WfPlayer.c:697
void WfPlayerGetGroundContactPoint(struct Entity2D *pEnt, vec2 outPos)
Definition WfPlayer.c:538
WfBGAnimationLayerNames
Definition WfPlayer.h:44
@ WfBG1
Definition WfPlayer.h:45
@ WfBG2
Definition WfPlayer.h:46
@ WfNumBackgroundAnimationLayers
Definition WfPlayer.h:47
void WfSetPlayerAnimationSet(struct Entity2D *pInPlayerEnt, const struct WfAnimationSet *pInSet)
Definition WfPlayer.c:812
#define NUM_ANIMATIONS
Definition WfPlayer.h:15
struct WfPlayerEntData * WfGetPlayerEntData(struct Entity2D *pInEnt)
Definition WfPlayer.c:818
Definition InputContext.h:201
Definition BinarySerializer.h:17
Definition InputContext.h:187
An entity component tagged union - there are a fixed number built into the engine.
Definition Entities.h:116
Definition Entities.h:199
Definition GameFramework.h:42
Definition Game2DLayer.h:93
A set of animations for everything the player can do.
Definition WfPlayer.h:26
const char * slashAnimations[NUM_ANIMATIONS]
Definition WfPlayer.h:28
const char * thrustAnimations[NUM_ANIMATIONS]
Definition WfPlayer.h:29
const char * walkAnimations[NUM_ANIMATIONS]
Definition WfPlayer.h:27
A set of anumations drawn behind and in front of the base sprite.
Definition WfPlayer.h:52
unsigned int bgLayersMask
which layers behind are drawn
Definition WfPlayer.h:63
struct WfAnimationSetLayer layers[WfNumAnimationLayers]
Layers in front of the sprite.
Definition WfPlayer.h:57
struct WfAnimationSetLayer bgLayers[WfNumBackgroundAnimationLayers]
Layers behind the sprite.
Definition WfPlayer.h:54
unsigned int layersMask
which layers in front are drawn
Definition WfPlayer.h:60
Definition WfPlayer.h:82
struct ButtonBinding mainActionBinding
Definition WfPlayer.h:92
u32 bNetworkControlled
Definition WfPlayer.h:125
enum WfDirection directionFacing
Definition WfPlayer.h:105
vec2 groundColliderCenter2EntTransform
Definition WfPlayer.h:83
struct WfAnimationSet animationSet
Definition WfPlayer.h:103
int netPlayerSlot
Definition WfPlayer.h:117
struct ButtonBinding settingsMenuBinding
Definition WfPlayer.h:94
struct ButtonBinding moveUpBinding
Definition WfPlayer.h:84
vec2 netPlayerSpawnAtPos
Definition WfPlayer.h:116
struct ButtonBinding moveRightBinding
Definition WfPlayer.h:87
u32 bMovingLastFrame
Definition WfPlayer.h:124
int networkPlayerNum
Definition WfPlayer.h:121
enum WfActionAnimation actionAnimation
Definition WfPlayer.h:127
struct ButtonBinding prevItemBinding
Definition WfPlayer.h:90
struct ButtonBinding moveLeftBinding
Definition WfPlayer.h:86
u8 movementBits
Definition WfPlayer.h:101
float metersPerSecondWalkSpeedBase
Definition WfPlayer.h:97
struct ButtonBinding nextItemBinding
Definition WfPlayer.h:89
enum WfPlayerState state
Definition WfPlayer.h:107
float speedMultiplier
Definition WfPlayer.h:99
struct ActiveInputBindingsMask playerControlsMask
Definition WfPlayer.h:95
struct ButtonBinding moveDownBinding
Definition WfPlayer.h:85
struct WfPlayerEntData::@0 createNetPlayerOnInitArgs