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
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue