]> git.lizzy.rs Git - minetest.git/blobdiff - src/environment.h
Fix addon and configuration file paths
[minetest.git] / src / environment.h
index a3418dbd4fe97426bda26c007072a21c87b282b0..fcd16e2967bebd271303940541af8894a08f991f 100644 (file)
@@ -39,6 +39,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "activeobject.h"
 
 class Server;
+class ServerEnvironment;
 class ActiveBlockModifier;
 class ServerActiveObject;
 typedef struct lua_State lua_State;
@@ -108,9 +109,15 @@ class ActiveBlockModifier
        ActiveBlockModifier(){};
        virtual ~ActiveBlockModifier(){};
        
+       // Set of contents to trigger on
        virtual std::set<std::string> getTriggerContents()=0;
+       // Set of required neighbors (trigger doesn't happen if none are found)
+       // Empty = do not check neighbors
+       virtual std::set<std::string> getRequiredNeighbors()
+       { return std::set<std::string>(); }
+       // Trigger interval in seconds
        virtual float getTriggerInterval() = 0;
-       // chance of (1 / return value), 0 is disallowed
+       // Random chance of (1 / return value), 0 is disallowed
        virtual u32 getTriggerChance() = 0;
        // This is called usually at interval for 1/chance of the nodes
        virtual void trigger(ServerEnvironment *env, v3s16 p, MapNode n){};
@@ -118,6 +125,14 @@ class ActiveBlockModifier
                        u32 active_object_count, u32 active_object_count_wider){};
 };
 
+struct ABMWithState
+{
+       ActiveBlockModifier *abm;
+       float timer;
+
+       ABMWithState(ActiveBlockModifier *abm_);
+};
+
 /*
        List of active blocks, used by ServerEnvironment
 */
@@ -245,18 +260,24 @@ class ServerEnvironment : public Environment
        void activateBlock(MapBlock *block, u32 additional_dtime=0);
 
        /*
-               ActiveBlockModifiers (TODO)
+               ActiveBlockModifiers
                -------------------------------------------
-               NOTE: Not used currently (TODO: Use or remove)
        */
 
        void addActiveBlockModifier(ActiveBlockModifier *abm);
 
-       /* Other stuff */
+       /*
+               Other stuff
+               -------------------------------------------
+       */
+       
+       // Find all active objects inside a radius around a point
+       std::set<u16> getObjectsInsideRadius(v3f pos, float radius);
        
        // Clear all objects, loading and going through every MapBlock
        void clearAllObjects();
        
+       // This makes stuff happen
        void step(f32 dtime);
        
 private:
@@ -329,12 +350,13 @@ class ServerEnvironment : public Environment
        u32 m_game_time;
        // A helper variable for incrementing the latter
        float m_game_time_fraction_counter;
-       core::list<ActiveBlockModifier*> m_abms;
+       core::list<ABMWithState> m_abms;
 };
 
 #ifndef SERVER
 
 #include "clientobject.h"
+class ClientSimpleObject;
 
 /*
        The client-side environment.
@@ -358,6 +380,7 @@ struct ClientEnvEvent
                } none;
                struct{
                        u8 amount;
+                       bool send_to_server;
                } player_damage;
        };
 };
@@ -366,7 +389,8 @@ class ClientEnvironment : public Environment
 {
 public:
        ClientEnvironment(ClientMap *map, scene::ISceneManager *smgr,
-                       ITextureSource *texturesource, IGameDef *gamedef);
+                       ITextureSource *texturesource, IGameDef *gamedef,
+                       IrrlichtDevice *device);
        ~ClientEnvironment();
 
        Map & getMap()
@@ -401,6 +425,12 @@ class ClientEnvironment : public Environment
                }
        }
 
+       /*
+               ClientSimpleObjects
+       */
+
+       void addSimpleObject(ClientSimpleObject *simple);
+
        /*
                ActiveObjects
        */
@@ -426,7 +456,7 @@ class ClientEnvironment : public Environment
                Callbacks for activeobjects
        */
 
-       void damageLocalPlayer(u8 damage);
+       void damageLocalPlayer(u8 damage, bool handle_hp=true);
 
        /*
                Client likes to call these
@@ -444,7 +474,9 @@ class ClientEnvironment : public Environment
        scene::ISceneManager *m_smgr;
        ITextureSource *m_texturesource;
        IGameDef *m_gamedef;
+       IrrlichtDevice *m_irr;
        core::map<u16, ClientActiveObject*> m_active_objects;
+       core::list<ClientSimpleObject*> m_simple_objects;
        Queue<ClientEnvEvent> m_client_event_queue;
        IntervalLimiter m_active_object_light_update_interval;
        IntervalLimiter m_lava_hurt_interval;