From 80ef8b1a65d5f93159d4794a6650585cfdf1f1bd Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Thu, 30 May 2019 13:37:55 +0200 Subject: [PATCH] gamecore/world: add an activity system for the world --- gamecore/modules/scenes.lua | 2 +- gamecore/modules/world/baseworld.lua | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/gamecore/modules/scenes.lua b/gamecore/modules/scenes.lua index 5fbdc06..7bca6c0 100644 --- a/gamecore/modules/scenes.lua +++ b/gamecore/modules/scenes.lua @@ -64,7 +64,7 @@ function Scene:update(dt) end function Scene:updateWorld(dt) - if (self.world ~= nil) then + if (self.world ~= nil) and (self.world.isActive) then self.world:update(dt) end end diff --git a/gamecore/modules/world/baseworld.lua b/gamecore/modules/world/baseworld.lua index 11b9ca0..ece92a7 100644 --- a/gamecore/modules/world/baseworld.lua +++ b/gamecore/modules/world/baseworld.lua @@ -44,6 +44,8 @@ function BaseWorld:new(scene, actorlist, mapfile) self:setGravity() self:register() + + self.isActive = true end function BaseWorld:setActorList(actorlist) @@ -275,6 +277,21 @@ function BaseWorld:getBackgroundColor() return self.backcolor[1]/256, self.backcolor[2]/256, self.backcolor[3]/256 end +-- Lock MANAGEMENT FUNCTIONS +-- Basic function to handle the lock + +function BaseWorld:setActivity(activity) + self.isActive = activity +end + +function BaseWorld:switchActivity() + self.isActive = (self.isActive == false) +end + +function BaseWorld:getActivity() + return self.isActive +end + -- UPDATE FUNCTIONS -- All update functions