summaryrefslogtreecommitdiff
path: root/world.lua
diff options
context:
space:
mode:
Diffstat (limited to 'world.lua')
-rw-r--r--world.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/world.lua b/world.lua
index 861a7da..c7cde9f 100644
--- a/world.lua
+++ b/world.lua
@@ -24,6 +24,7 @@ function World:new()
self.liquidSurfaces = {}
self.liquidSurfaceFixtures = {}
self.spikes = {}
+ self.textTriggers = {}
self.refractionCanvas = nil
self.liquidShader = nil
self.activeSplashes = {}
@@ -153,6 +154,12 @@ function World:load(mapPath, tilesets)
table.insert(self.entities, spike)
end
+ for _, textTrigger in ipairs(self.tilemap:getEntitiesTextTriggers()) do
+ textTrigger:setWorldPhysics(self.physicsWorld)
+ table.insert(self.textTriggers, textTrigger)
+ table.insert(self.entities, textTrigger)
+ end
+
local ok, shader = pcall(love.graphics.newShader, "shaders/liquid.glsl")
self.liquidShader = ok and shader or nil
if not self.liquidShader then
@@ -198,7 +205,19 @@ function World:_isHazard(ud)
return type(ud) == "table" and (ud.isSpike or ud.isEnemy)
end
+function World:handleTextTrigger(trigger, player)
+ if trigger and player and trigger.isTextTrigger and self:_isPlayerLike(player) then
+ trigger:trigger(self, player)
+ end
+end
+
function World:_onBeginContact(udA, udB, nx, ny, contact)
+ if type(udA) == "table" and udA.isTextTrigger then
+ self:handleTextTrigger(udA, udB)
+ elseif type(udB) == "table" and udB.isTextTrigger then
+ self:handleTextTrigger(udB, udA)
+ end
+
if udA == "ground" and self:_isTrackedEntity(udB) then
local kind = self:_normalToContactType(nx, ny)
if kind then
@@ -217,6 +236,7 @@ function World:_onBeginContact(udA, udB, nx, ny, contact)
end
self.groundContacts[udA] = (self.groundContacts[udA] or 0) + 1
if self:_isPlayerLike(udA) then udA.grounded = true end
+
end
local function doWaterSplash(waterData, entity)