diff --git a/sonic-radiance.love/birb/modules/gamesystem/libs/binser.lua b/sonic-radiance.love/birb/libs/binser.lua similarity index 100% rename from sonic-radiance.love/birb/modules/gamesystem/libs/binser.lua rename to sonic-radiance.love/birb/libs/binser.lua diff --git a/sonic-radiance.love/game/modules/tweenmanager/libs/tween.lua b/sonic-radiance.love/birb/libs/tween.lua similarity index 100% rename from sonic-radiance.love/game/modules/tweenmanager/libs/tween.lua rename to sonic-radiance.love/birb/libs/tween.lua diff --git a/sonic-radiance.love/birb/modules/gamesystem/init.lua b/sonic-radiance.love/birb/modules/gamesystem/init.lua deleted file mode 100644 index 2fca259..0000000 --- a/sonic-radiance.love/birb/modules/gamesystem/init.lua +++ /dev/null @@ -1,145 +0,0 @@ --- game :: The main game subsystem. Basically a big object that handle all the --- game-related data like characters, monsters, etc. While the core aim to be --- reusable at will, the game is specifically made for the current game. - --- It's also what handle the savedata for games - ---[[ - Copyright © 2019 Kazhnuz - - Permission is hereby granted, free of charge, to any person obtaining a copy of - this software and associated documentation files (the "Software"), to deal in - the Software without restriction, including without limitation the rights to - use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - the Software, and to permit persons to whom the Software is furnished to do so, - subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -]] - -local cwd = (...):gsub('%.init$', '') .. "." -local cwd2 = (...):gsub('%.gamesystem.init$', '') .. "." - -local GameSystem = Object:extend() -local binser = require(cwd2 .. "libs.binser") - -local DEFAULT_SAVENUMBER = 3 - -function GameSystem:new() - self.currentSlot = -1 - - self.submodules = {} - self.playtime = 0 - self:register() -end - -function GameSystem:register() - core:registerGameSystem(self) -end - -function GameSystem:registerSubmodules(submodule) - local name = submodule.name - self.submodules[name] = submodule -end - --- UPDATE FUNCTIONS --- Update every submodules - -function GameSystem:update(dt) - self.playtime = self.playtime + dt - for k, submodule in pairs(self.submodules) do - submodule:update(dt) - end -end - --- DATA MANAGEMENT FUNCTIONS --- Get and set data in the gamesystem object - -function GameSystem:setData(data) - local data = data - self.playtime = data.playtime - for k, submodule in pairs(self.submodules) do - submodule:setData(data[k]) - end -end - -function GameSystem:getData() - local data = {} - data.playtime = self.playtime - for k, submodule in pairs(self.submodules) do - data[k] = submodule:getData() - end - return data -end - --- SAVE MANAGEMENT FUNCTIONS --- Get and set data in the gamesystem object - -function GameSystem:getSaveNumber() - return DEFAULT_SAVENUMBER -end - -function GameSystem:resetSave(saveid) - if utils.filesystem.exists("save" .. saveid .. ".save") then - love.filesystem.remove( "save" .. saveid .. ".save" ) - end -end - -function GameSystem:resetAllSaves() - for i=1, self:getSaveNumber() do - self:resetSave(i) - end -end - -function GameSystem:getSavePath(saveid, absolute) - local saveDir = "" - if (absolute) then - saveDir = love.filesystem.getSaveDirectory() .. "/" - if not utils.filesystem.exists(saveDir) then - love.filesystem.createDirectory( "" ) - end - end - - local filepath = saveDir .. self:getSaveName(saveid) - - return filepath -end - -function GameSystem:getSaveName(saveid) - return "save" .. saveid .. ".save" -end - -function GameSystem:saveFileExist(saveid) - return utils.filesystem.exists(self:getSaveName(saveid)) -end - -function GameSystem:read(saveid) - self.currentSlot = saveid or self.currentSlot - if (self.currentSlot > 0) then - local savepath = self:getSavePath(self.currentSlot, true) - if self:saveFileExist(self.currentSlot) then - local datas = binser.readFile(savepath) - - self:setData(datas[1]) - end - end -end - -function GameSystem:write() - if (self.currentSlot > 0) then - local data = self:getData() - - local savepath = self:getSavePath(self.currentSlot, true) - binser.writeFile(savepath, data) - end -end - -return GameSystem diff --git a/sonic-radiance.love/birb/modules/gamesystem/submodule.lua b/sonic-radiance.love/birb/modules/gamesystem/submodule.lua deleted file mode 100644 index 5ea5486..0000000 --- a/sonic-radiance.love/birb/modules/gamesystem/submodule.lua +++ /dev/null @@ -1,23 +0,0 @@ -local SubModule = Object:extend() - -function SubModule:new(game, name) - self.name = name or error("SUBMODULE must have a name") - self.game = game - self.data = {} - - self:register() -end - -function SubModule:register() - self.game:registerSubmodules(self) -end - -function SubModule:getData() - return self.data -end - -function SubModule:setData(data) - self.data = data -end - -return SubModule diff --git a/sonic-radiance.love/birb/options.lua b/sonic-radiance.love/birb/options.lua index fc523e7..c958e1c 100644 --- a/sonic-radiance.love/birb/options.lua +++ b/sonic-radiance.love/birb/options.lua @@ -25,7 +25,7 @@ local OptionsManager = Object:extend() local cwd = (...):gsub('%.options$', '') .. "." -local binser = require(cwd .. "modules.gamesystem.libs.binser") +local binser = require(cwd .. "libs.binser") local TRANSLATION_PATH = "datas/languages/" diff --git a/sonic-radiance.love/game/init.lua b/sonic-radiance.love/game/init.lua index b965614..b2742bf 100644 --- a/sonic-radiance.love/game/init.lua +++ b/sonic-radiance.love/game/init.lua @@ -31,7 +31,7 @@ local Loot = require "game.loot" local CBSCore = require "game.battle" local Difficulty = require "game.difficulty" -local binser = require "birb.modules.gamesystem.libs.binser" +local binser = require "birb.libs.binser" local startdata = require "datas.gamedata.startdata" diff --git a/sonic-radiance.love/game/modules/tweenmanager/init.lua b/sonic-radiance.love/game/modules/tweenmanager/init.lua index d4a8afa..a6acf7a 100644 --- a/sonic-radiance.love/game/modules/tweenmanager/init.lua +++ b/sonic-radiance.love/game/modules/tweenmanager/init.lua @@ -1,6 +1,6 @@ local TweenManager = Object:extend() -local tween = require "game.modules.tweenmanager.libs.tween" +local tween = require "birb.libs.tween" local Timer = require "birb.modules.world.actors.utils.timer" function TweenManager:new(subject)