Skip to content
Snippets Groups Projects
shoot_controller.h 1.01 KiB
Newer Older
  • Learn to ignore specific revisions
  • Tomas Vybiral's avatar
    Tomas Vybiral committed
    #ifndef SHOOT_CONTROLLER_H
    #define SHOOT_CONTROLLER_H
    
    
    Tomas Vybiral's avatar
    Tomas Vybiral committed
    /// Controls shooting behavior
    
    Tomas Vybiral's avatar
    Tomas Vybiral committed
    public:
    
    Tomas Vybiral's avatar
    Tomas Vybiral committed
        /// Initializes controller with max delay 
    
        explicit shoot_controller_impl(double delay);
    
    Tomas Vybiral's avatar
    Tomas Vybiral committed
        /// Virtual destructor to prevent memory leaks
    
        virtual ~shoot_controller_impl() = default;
    
    Tomas Vybiral's avatar
    Tomas Vybiral committed
    
        /// Try to shoot - returns true if can
        virtual bool shoot(bool did_shoot);
        /// Updates shooting delay timer
        void update_timer(double delta_time);
        /// Checks if the game can change shoot controller
        virtual bool can_switch();
    protected:
        /// Checks if timer is expired
        bool can_shoot() const;
    
    
        /// Remaining time before you can shoot again
    
    Tomas Vybiral's avatar
    Tomas Vybiral committed
        double remaining_time;
    
    Tomas Vybiral's avatar
    Tomas Vybiral committed
        double shoot_delay;
    };
    
    
    typedef std::shared_ptr<shoot_controller_impl> shoot_controller;
    
    class shooter_factory {
    public:
        static shoot_controller get_single_shooter();
        static shoot_controller get_multi_shooter();
    };
    
    
    Tomas Vybiral's avatar
    Tomas Vybiral committed
    #endif//SHOOT_CONTROLLER_H