When any segment of the marker wall is punched, unmark the entire wall

Fixes #102
This commit is contained in:
Starbeamrainbowlabs 2023-07-31 18:20:06 +01:00
parent a465a50244
commit 564785ddf6
No known key found for this signature in database
GPG Key ID: 1BE5172E637709C2
5 changed files with 26 additions and 6 deletions

@ -4,6 +4,10 @@ It's about time I started a changelog! This will serve from now on as the main c
Note to self: See the bottom of this file for the release template text.
## v1.14.4: The multipoint update, hotfix 4 (unreleased)
- When any segment of the marker wall is punched, unmark the entire wall
## v1.14.3: The multipoint update, hotfix 3 (18th July 2023)
- Fix regions not remembering their state and being unresettable

@ -54,6 +54,9 @@ local WEAPositionMarkerWall = {
end,
on_punch = function(self, _)
anchor.delete(self)
-- Only unmark the rest of the walls
-- Unmark for the player that created this wall.... NOT the player who punched it!
wea_c.pos.unmark(self.player_name, false, true)
end,
on_blast = function(self, damage)
return false, false, {} -- Do not damage or knockback the player

@ -33,7 +33,7 @@ local anchor = nil
--- It is requested that all position/region marker UI elements be hidden for the given player.
-- @event unmark
-- @format { player_name: string }
-- @format { player_name: string, markers: bool, walls: bool }
--- It is requested that all position/region marker UI elements be shown once more for the given player.
-- @event mark
@ -268,15 +268,24 @@ end
--- Hides the visual markers for the given player's positions and defined region, but does not clear the points.
-- @param player_name string The name of the player to operate on.
local function unmark(player_name)
-- @param markers=true bool Whether to hide positional markers.
-- @param walls=true bool Whether to hide the marker walls.
-- @returns void
local function unmark(player_name, markers, walls)
if markers == nil then markers = true end
if walls == nil then walls = true end
anchor:emit("unmark", {
player_name = player_name
player_name = player_name,
markers = markers,
walls = walls
})
end
--- Shows the visual markers for the given player's positions and defined region once more.
-- Often used some time after calling worldeditadditions_core.pos.unmark().
-- @param player_name string The name of the player to operate on.
-- @returns void
local function mark(player_name)
anchor:emit("mark", {
player_name = player_name

@ -92,8 +92,9 @@ end)
wea_c.pos:addEventListener("unmark", function(event)
ensure_player(event.player_name)
do_delete_all(event.player_name)
if event.markers then
do_delete_all(event.player_name)
end
-- Note that this function is NOT WorldEdit compatible, because it is only called through our override of WorldEdit's `//unmark`, and WorldEdit doesn't have an API function to call to unmark and everything is complicated.
end)

@ -85,13 +85,16 @@ local function handle_event(event)
if needs_update(event) then do_update(event) end
end
local function handle_unmark(event)
if event.walls then do_delete(event) end
end
weac.pos:addEventListener("set", handle_event)
weac.pos:addEventListener("pop", handle_event)
weac.pos:addEventListener("push", handle_event)
weac.pos:addEventListener("clear", do_delete)
weac.pos:addEventListener("unmark", do_delete)
weac.pos:addEventListener("unmark", handle_unmark)
weac.pos:addEventListener("mark", do_update)
weac.entities.pos_marker_wall:addEventListener("update_entity", update_entity)