#include "component_action_angle.h" /* DEPENDENCIES: Physics, AnimationIdle */ /* Ticks action angle component. */ void component_action_angle_tick(ComponentActionAngle* self, ECS* ecs) { ComponentPhysics* physics; ComponentSprite* sprite; ComponentAnimationIdle* animationIdle; physics = ecs_component_get(ecs, ECS_COMPONENT_PHYSICS, self->component.id); sprite = ecs_component_get(ecs, ECS_COMPONENT_SPRITE, self->component.id); animationIdle = ecs_component_get(ecs, ECS_COMPONENT_ANIMATION_IDLE, self->component.id); animationIdle->component.isDisabled = true; if ( physics->angle >= 0.0f && physics->angle < PI_FOURTH ) { animationIdle->baseIndex = 0; sprite->atlas.index = 0; } else if ( physics->angle >= PI_FOURTH && physics->angle < PI_HALF ) { animationIdle->baseIndex = 2; sprite->atlas.index = 2; } else if ( physics->angle >= PI_HALF && physics->angle < (PI_HALF + PI_FOURTH) ) { animationIdle->baseIndex = 4; sprite->atlas.index = 4; } else if ( physics->angle >= (PI_HALF + PI_FOURTH) && physics->angle < PI ) { animationIdle->baseIndex = 6; sprite->atlas.index = 6; } else if ( physics->angle >= -PI && physics->angle < -(PI_HALF + PI_FOURTH) ) { animationIdle->baseIndex = 8; sprite->atlas.index = 8; } else if ( physics->angle >= -(PI_HALF + PI_FOURTH) && physics->angle < -PI_HALF ) { animationIdle->baseIndex = 10; sprite->atlas.index = 10; } else if ( physics->angle >= -PI_HALF && physics->angle < -PI_FOURTH ) { animationIdle->baseIndex = 12; sprite->atlas.index = 12; } else if ( physics->angle >= -PI_FOURTH && physics->angle < 0.0f ) { animationIdle->baseIndex = 14; sprite->atlas.index = 14; } }