From a64d77bc12cadb3989a7faf094adc1d5c581d565 Mon Sep 17 00:00:00 2001 From: cursed22bc Date: Tue, 10 Mar 2026 20:52:33 +0200 Subject: text triggers --- world.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'world.lua') 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) -- cgit v1.2.3