ICT290 / src / scene / AIController / EntityBrain / TargetingSystem.h
TargetingSystem.h
Raw
//
// Created by Micha on 27/09/2021.
//

#pragma once

#include <glm/glm.hpp>
#include <list>

#include "SensoryMemory.h"
//#include "../Vehicle.h"
class Vehicle;

class SensoryMemory;

class TargetingSystem {
   public:
    explicit TargetingSystem(Vehicle* owner);

    // each time this method is called the opponents in the owner's sensory
    // memory are examined and the closest  is assigned to m_pCurrentTarget.
    // if there are no opponents that have had their memory records updated
    // within the memory span of the owner then the current target is set
    // to null
    void update();

    // returns true if there is a currently assigned target
    bool isTargetPresent() const { return m_CurrentTarget != nullptr; }

    // returns true if the target is within the field of view of the owner
    bool isTargetWithinFOV() const;

    // returns true if there is unobstructed line of sight between the target
    // and the owner
    bool isTargetShootable() const;

    // returns the position the target was last seen. Throws an exception if
    // there is no target currently assigned
    glm::vec2 getLastRecordedPosition() const;

    // returns the amount of time the target has been in the field of view
    float getTimeTargetHasBeenVisible() const;

    // returns the amount of time the target has been out of view
    float getTimeTargetHasBeenOutOfView() const;

    // returns a pointer to the target. null if no target current.
    Vehicle* getTarget() const { return m_CurrentTarget; }

    // sets the target pointer to null
    void clearTarget() { m_CurrentTarget = nullptr; }

   private:
    // the owner of this system
    Vehicle* m_Owner;

    // the current target (this will be null if there is no target assigned)
    Vehicle* m_CurrentTarget;
};

// ICT290_TARGETINGSYSTEM_H