chore: simplify gizmo collision check

This commit is contained in:
Kazhnuz 2021-03-21 16:32:29 +01:00
parent bceda94970
commit 91c7a03dc2

View file

@ -68,27 +68,29 @@ function Player:updateCurrentCharset()
end
function Player:collisionResponse(col)
if (not col.other.owner.isDestroyed) then
if (col.other.type == "gizmo") then
if (col.other.owner.needButton) then
local hitbox = col.other
local other = col.other.owner
if (not other.isDestroyed) then
if (hitbox.type == "gizmo") then
if (other.needButton) then
if (self.keys["A"].isPressed) then
col.other.owner:doAction()
other:doAction()
self.haveCollided = true
self.lastCollision = col.other.owner.creationID
self.lastCollision = other.creationID
end
else
if (self.lastCollision ~= col.other.owner.creationID) then
col.other.owner:doAction()
if (self.lastCollision ~= other.creationID) then
other:doAction()
end
self.haveCollided = true
self.lastCollision = col.other.owner.creationID
self.lastCollision = other.creationID
end
end
if (col.other.type == "btnInput" and col.other.owner.needButton) then
if (self.keys["A"].isPressed and (self:faceRightDirection(col.other.owner))) then
col.other.owner:doAction()
if (hitbox.type == "btnInput" and other.needButton) then
if (self.keys["A"].isPressed and (self:faceRightDirection(other))) then
other:doAction()
self.haveCollided = true
self.lastCollision = col.other.owner.creationID
self.lastCollision = other.creationID
end
end
end