From 4ee17f01b65a7a85d72a191988b854a5e9010a6a Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 16 Jun 2019 18:45:18 +0200 Subject: [PATCH] refactor(levels): remove all functions already provided by Actor2D --- .../scenes/levels/entities/parent.lua | 38 ++----------------- 1 file changed, 4 insertions(+), 34 deletions(-) diff --git a/imperium-porcorum.love/scenes/levels/entities/parent.lua b/imperium-porcorum.love/scenes/levels/entities/parent.lua index b28e9cc..2d74e06 100644 --- a/imperium-porcorum.love/scenes/levels/entities/parent.lua +++ b/imperium-porcorum.love/scenes/levels/entities/parent.lua @@ -1,4 +1,5 @@ -local Entity = Object:extend() -- On créer la classe des entitées, c'est la classe de base +local Base = require "core.modules.world.actors.actor2D" +local Entity = Base:extend() -- On créer la classe des entitées, c'est la classe de base function Entity:new(world, type, x, y, w, h) -- On enregistre une nouvelle entité, avec par défaut sa hitbox. self:initPhysics(world, type, x, y, w, h) @@ -8,10 +9,8 @@ function Entity:new(world, type, x, y, w, h) -- On enregistre une nouvelle entit end function Entity:initPhysics(world, type, x, y, w, h) - self.scene = world.scene - self.world = world + self:setManagers(world) self.camera = self.scene.camera - self.obj = self.world.obj self.type = type self.gacc = 550 @@ -22,10 +21,7 @@ function Entity:initPhysics(world, type, x, y, w, h) self.grav = 0 self.frc = 0 - self.x = x or 0 - self.y = y or 0 - self.w = w or 16 - self.h = h or 16 + self:initHitbox(x, y, w, h) self.onGround = false self.playerID = -1 @@ -33,25 +29,10 @@ function Entity:initPhysics(world, type, x, y, w, h) self:register() end -function Entity:setDebugColor(r,g,b) - self.debug = {} - self.debug.r = r - self.debug.g = r - self.debug.b = r -end - function Entity:update(dt) end -function Entity:register() - self.world:registerActor(self) -end - -function Entity:destroy() - self.world:removeActor(self) -end - function Entity:canBounce(bounce) self.bounce = bounce end @@ -99,21 +80,10 @@ function Entity:changeSpeedToCollisionNormal(nx, ny) self.xsp, self.ysp = xsp, ysp end -function Entity:getCenter() - return self.x + self.w / 2, - self.y + self.h / 2 -end - function Entity:purge() self:remove() end -function Entity:setFilter() - self.filter = function(item, other) - return nil - end -end - function Entity:checkGround(ny) if not (self.grav == 0) then if ny < 0 then self.onGround = true end