diff options
| author | cursed22bc <admin@pixeldawn.org> | 2026-03-10 20:52:33 +0200 |
|---|---|---|
| committer | cursed22bc <admin@pixeldawn.org> | 2026-03-10 20:52:33 +0200 |
| commit | a64d77bc12cadb3989a7faf094adc1d5c581d565 (patch) | |
| tree | 86bc2a3876c3cd42b86772eaff755549590e57c8 /world.lua | |
| parent | 9d95968c3e732be915f10841d1d659e37b3b5d03 (diff) | |
text triggers
Diffstat (limited to 'world.lua')
| -rw-r--r-- | world.lua | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -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) |
