Skip to content

Instantly share code, notes, and snippets.

@Vavius
Created March 12, 2018 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vavius/7914d1424a12abbda2a5152e7440ea9a to your computer and use it in GitHub Desktop.
Save Vavius/7914d1424a12abbda2a5152e7440ea9a to your computer and use it in GitHub Desktop.
//----------------------------------------------------------------//
// Copyright (c) 2016 CloudTeam, Inc
// All Rights Reserved.
//----------------------------------------------------------------//
#ifndef DOBA_MOVEMENT_COMPONENT_H
#define DOBA_MOVEMENT_COMPONENT_H
#include <components/DOBAComponentBase-impl.h>
//================================================================//
// MovementComponent
//================================================================//
/* "seek" steering behavior
TODO: maybe it's worth implementing a full set of configurable steering behaviors as components?
*/
struct MovementComponent :
public entityx::Component < MovementComponent > {
ZLFixVec2D targetPosition;
// controls how fast entity will turn to it's target direction
Fix16 steeringForce;
Fix16 maximumSpeed;
bool active;
//----------------------------------------------------------------//
MovementComponent () :
steeringForce ( 0.1f ),
maximumSpeed ( 1.f ),
active ( false ) {
}
};
//================================================================//
// DOBAMovementComponent
//================================================================//
class DOBAMovementComponent :
public DOBAComponentBase < MovementComponent > {
private:
void RegisterProperties ( MOAILuaState& state ) {
DOBA_DECL_FIELD ( MovementComponent, targetPosition )
DOBA_DECL_FIELD ( MovementComponent, steeringForce )
DOBA_DECL_FIELD ( MovementComponent, maximumSpeed )
DOBA_DECL_FIELD ( MovementComponent, active )
};
public:
DECL_LUA_FACTORY ( DOBAMovementComponent )
};
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment