src/Player.hh
author terom
Sat, 06 Dec 2008 22:47:08 +0000
changeset 233 ff4ecea83cf5
parent 228 dbc1bb7a98b5
child 235 0a0c729365ee
permissions -rw-r--r--
start using CL_ResourceManager, change most draw methods to take a Graphics*, implment even better input handling, and draw weapon names
#ifndef PLAYER_HH
#define PLAYER_HH

class Player;
class LocalPlayer;
class RemotePlayer;

#include "Weapon.hh"
#include "GameState.hh"
#include "PhysicsObject.hh"
#include "Input.hh"
#include "Rope.hh"
#include "GraphicsPointer.hh"
#include <vector>

class Player : public PhysicsObject {
    friend class Rope;

    public:
        GameState &state;

    protected:
        bool visible;
        std::vector<Weapon> arsenal;
        unsigned int selectedWeapon; //unsigned for x%sW not to fail
        bool changing;

        Rope rope;
        int animation_step;

        // default constructor for use with virtual inheritance... it's not defined
        Player (void);
        Player (GameState &state, Vector position, bool visible); 
        
        // used by the network code to execute actions for players
        virtual void handleDig (Vector position, float radius);
        virtual void handleCreateProjectile (Weapon &weapon, Vector position, Vector velocity);
        
        /*
         * The currently selected weapon
         */
        Weapon& getWeapon();

    public:
        /*
         * Prints random things via Engine::log
         */
        void printDebugInfo ();

        /*
         * Overrides PhysicsObject::tick to also advance game state
         */
        virtual void tick (TimeMS dt);

        /*
         * Drawing requires the skin texture, which is loaded on-demand when draw is called
         */
        static bool skin_loaded;
        static CL_Surface skin_surface;
        virtual void draw (Graphics *g);
};

class LocalPlayer : public virtual Player {
    private:
        void fireWeapon (Weapon &weapon);

    public:
        /*
         * Called to invoke some action on this player that we control, either by Graphics or NetworkServer.
         *
         * NetworkClientLocalPlayer overrides this to send the input to the server, which then handles it
         */
        virtual void handleInput (PlayerInput input);
        
        /*
         * As Player, but also draws the current weapon name if displayWeapon
         */
        virtual void draw (Graphics *g, bool displayWeapon);
};

class RemotePlayer : public virtual Player {
    protected:
};
 

#endif