From a227bbb033bd3a34bf22dd4879eea0fb7bc91e86 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 16 Jun 2019 16:33:29 +0200 Subject: [PATCH] feat(world): add a function to reset world --- gamecore/modules/world/baseworld.lua | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/gamecore/modules/world/baseworld.lua b/gamecore/modules/world/baseworld.lua index 9ba876c..4bf83eb 100644 --- a/gamecore/modules/world/baseworld.lua +++ b/gamecore/modules/world/baseworld.lua @@ -35,14 +35,16 @@ local PADDING_VALUE = 10/100 -- All functions to init the world and the map function BaseWorld:new(scene, actorlist, mapfile) - self.scene = scene + self.scene = scene + self.actorlist = actorlist + self.mapfile = mapfile self.cameras = CameraSystem(self) self:initActors() self:initPlayers() - self:setActorList(actorlist) - self:initMap(mapfile) + self:setActorList(self.actorlist) + self:initMap(self.mapfile) self:setGravity() self:register() @@ -79,6 +81,16 @@ function BaseWorld:register() self.scene:registerWorld(self) end +function BaseWorld:reset() + self:initActors() + self:initPlayers() + self:initMap(self.mapfile) + self.cameras:initViews() + collectgarbage() + + self:loadMap() +end + -- ACTOR MANAGEMENT FUNCTIONS -- Basic function to handle actors