Add hurt, die animation when taking damage
This commit is contained in:
@@ -73,6 +73,19 @@ ECS_MOVE(Building, dst, src, {
|
||||
*dst = *src;
|
||||
})
|
||||
|
||||
void delayDeleteUpdate(ecs_iter_t *it) {
|
||||
DelayDelete *delay = ecs_field(it, DelayDelete, 1);
|
||||
|
||||
f32 dt = GetFrameTime();
|
||||
|
||||
for (i32 i = 0; i < it->count; i++) {
|
||||
delay[i].elapsed += dt;
|
||||
|
||||
if (delay[i].elapsed >= delay[i].time)
|
||||
ecs_delete(ECS, it->entities[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void setupSystems() {
|
||||
ecs_set_hooks(ECS, SpatialGridID, {
|
||||
.dtor = ecs_dtor(SpatialGridID),
|
||||
@@ -99,7 +112,7 @@ void setupSystems() {
|
||||
|
||||
ECS_SYSTEM(ECS, entityUpdateSpatialID, EcsOnUpdate, Position, HitBox, Velocity, SpatialGridID);
|
||||
ECS_SYSTEM(ECS, entityUpdateKinematic, EcsOnUpdate, Position, Velocity, Steering, Unit);
|
||||
ECS_SYSTEM(ECS, entityUpdatePhysics, EcsOnUpdate, Position, HitBox, Velocity, SpatialGridID);
|
||||
ECS_SYSTEM(ECS, entityUpdate, EcsOnUpdate, Position, HitBox, Velocity, Unit, Owner, SpatialGridID);
|
||||
|
||||
ECS_SYSTEM(ECS, entityMoveToTarget, EcsOnUpdate, Position, Velocity, TargetPosition, Steering);
|
||||
ECS_SYSTEM(ECS, entityFollowPath, EcsOnUpdate, Path);
|
||||
@@ -113,12 +126,14 @@ void setupSystems() {
|
||||
ECS_SYSTEM(ECS, updateAnimation, EcsOnUpdate, Animation, TextureRegion);
|
||||
ECS_SYSTEM(ECS, updateEasingSystem, EcsOnUpdate, Easing, Position, HitBox, Rotation);
|
||||
|
||||
ECS_SYSTEM(ECS, renderHealth, EcsOnUpdate, Position, HitBox, Health);
|
||||
ECS_SYSTEM(ECS, renderHealthBar, EcsOnUpdate, Position, HitBox, Health);
|
||||
ECS_SYSTEM(ECS, renderDebugPath, EcsOnUpdate, Path);
|
||||
|
||||
ECS_SYSTEM(ECS, renderColliders, EcsOnUpdate, Position, HitBox);
|
||||
ECS_SYSTEM(ECS, renderOrientationDirection, EcsOnUpdate, Position, Orientation);
|
||||
|
||||
ECS_SYSTEM(ECS, delayDeleteUpdate, EcsOnUpdate, DelayDelete);
|
||||
|
||||
renderDebugPathSystem = renderDebugPath;
|
||||
renderOrientDirSystem = renderOrientationDirection;
|
||||
renderCollidersSystem = renderColliders;
|
||||
|
||||
Reference in New Issue
Block a user