chore: simplify gizmo collision check
This commit is contained in:
parent
bceda94970
commit
91c7a03dc2
1 changed files with 14 additions and 12 deletions
|
@ -68,27 +68,29 @@ function Player:updateCurrentCharset()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Player:collisionResponse(col)
|
function Player:collisionResponse(col)
|
||||||
if (not col.other.owner.isDestroyed) then
|
local hitbox = col.other
|
||||||
if (col.other.type == "gizmo") then
|
local other = col.other.owner
|
||||||
if (col.other.owner.needButton) then
|
if (not other.isDestroyed) then
|
||||||
|
if (hitbox.type == "gizmo") then
|
||||||
|
if (other.needButton) then
|
||||||
if (self.keys["A"].isPressed) then
|
if (self.keys["A"].isPressed) then
|
||||||
col.other.owner:doAction()
|
other:doAction()
|
||||||
self.haveCollided = true
|
self.haveCollided = true
|
||||||
self.lastCollision = col.other.owner.creationID
|
self.lastCollision = other.creationID
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if (self.lastCollision ~= col.other.owner.creationID) then
|
if (self.lastCollision ~= other.creationID) then
|
||||||
col.other.owner:doAction()
|
other:doAction()
|
||||||
end
|
end
|
||||||
self.haveCollided = true
|
self.haveCollided = true
|
||||||
self.lastCollision = col.other.owner.creationID
|
self.lastCollision = other.creationID
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (col.other.type == "btnInput" and col.other.owner.needButton) then
|
if (hitbox.type == "btnInput" and other.needButton) then
|
||||||
if (self.keys["A"].isPressed and (self:faceRightDirection(col.other.owner))) then
|
if (self.keys["A"].isPressed and (self:faceRightDirection(other))) then
|
||||||
col.other.owner:doAction()
|
other:doAction()
|
||||||
self.haveCollided = true
|
self.haveCollided = true
|
||||||
self.lastCollision = col.other.owner.creationID
|
self.lastCollision = other.creationID
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue