mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 15:13:16 +00:00
dont leave floating capes when other player mvoes out of range
This commit is contained in:
parent
2f7230377c
commit
77c4faeced
2 changed files with 27 additions and 1 deletions
|
@ -29,7 +29,8 @@ function player_color(player_entity)
|
||||||
|
|
||||||
EntityKill(cape)
|
EntityKill(cape)
|
||||||
local player_cape_sprite_file = "mods/quant.ew/files/system/player/tmp/" .. ctx.my_id .. "_cape.xml"
|
local player_cape_sprite_file = "mods/quant.ew/files/system/player/tmp/" .. ctx.my_id .. "_cape.xml"
|
||||||
local cape2 = EntityLoad(player_cape_sprite_file, 0, 0)
|
local x, y = EntityGetTransform(ctx.my_player.entity)
|
||||||
|
local cape2 = EntityLoad(player_cape_sprite_file, x, y)
|
||||||
EntityAddChild( player_entity, cape2 )
|
EntityAddChild( player_entity, cape2 )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,31 @@ function module.on_world_update()
|
||||||
rpc.check_gamemode(np.GetGameModeName(n))
|
rpc.check_gamemode(np.GetGameModeName(n))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if GameGetFrameNum() % 16 == 7 then
|
||||||
|
local mx, my = GameGetCameraPos()
|
||||||
|
for peer_id, player in pairs(ctx.players) do
|
||||||
|
local ent = player.entity
|
||||||
|
local x, y = EntityGetTransform(ent)
|
||||||
|
local dx, dy = x - mx, y - my
|
||||||
|
local cape
|
||||||
|
for _, child in ipairs(EntityGetAllChildren(ent) or {}) do
|
||||||
|
if EntityGetName(child) == "cape" then
|
||||||
|
cape = child
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if dx * dx + dy * dy > 300 * 300 then
|
||||||
|
if cape ~= nil then
|
||||||
|
EntityKill(cape)
|
||||||
|
end
|
||||||
|
elseif cape == nil then
|
||||||
|
local player_cape_sprite_file = "mods/quant.ew/files/system/player/tmp/" .. peer_id .. "_cape.xml"
|
||||||
|
local cape2 = EntityLoad(player_cape_sprite_file, x, y)
|
||||||
|
EntityAddChild(ent, cape2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return module
|
return module
|
Loading…
Add table
Add a link
Reference in a new issue