/*
 * KartInteractionComponent.h
 *
 *  Created on: Aug 19, 2020
 *      Author: fredrick
 */

#ifndef KARTINTERACTIONCOMPONENT_H_
#define KARTINTERACTIONCOMPONENT_H_

#include <chrono>
#include <memory>
#include <string>

#define GLM_FORCE_RADIANS
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>

#include <ecos/utility/Math.h>

#include <ecos/core/IDCache.h>
#include <ecos/core/Log.h>
#include <ecos/core/BroadcastObservable.h>
#include <ecos/core/Message.h>

#include <ecos/physics/TransformChangeMessage.h>

#include <ecos/interaction/InteractionSystem.h>
#include <ecos/interaction/InteractionComponent.h>

#include "../messages/DirectionChangeMessage.h"
#include "../messages/JumpMessage.h"

namespace JamSpook {

using std::chrono::milliseconds;
using std::shared_ptr;
using std::make_shared;
using std::weak_ptr;
using std::dynamic_pointer_cast;

using glm::vec3;
using glm::mat4;
using glm::translate;
using glm::rotate;
using glm::radians;

using ecos::utility::getTranslation;

using ecos::core::IDCache;
using ecos::core::logging::Log;
using ecos::core::logging::LogLevel;
using ecos::core::BroadcastObservable;
using ecos::core::Message;

using ecos::physics::TransformChangeMessage;

using ecos::interaction::InteractionSystem;
using ecos::interaction::InputDeviceState;
using ecos::interaction::ButtonState;
using ecos::interaction::InteractionComponent;

using messages::DirectionChangeMessage;
using messages::JumpMessage;

/// Kart interaction component
/// entity specific interaction system code
class KartInteractionComponent :
        public InteractionComponent
{
private:
    vec3 mOldDirection; ///< Used to construct the DirectionChangeMessaage
    bool mIsOnGround;

public:
    KartInteractionComponent(mat4 transform,
                             shared_ptr<BroadcastObservable<shared_ptr<Message> > > entity,
                             weak_ptr<InteractionSystem> wInteractionSystem);
    virtual ~KartInteractionComponent();

    virtual void onInputDeviceStateChange(const InputDeviceState inputDeviceState);
    virtual void onICCMessage(shared_ptr<Message> message);
};

} // namespace JamSpook

#endif // KARTINTERACTIONCOMPONENT_H_
