mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
dont have a players light component enabled when offscreen, dont give global perks to notplayers, wait till end
This commit is contained in:
parent
e15655dac6
commit
fc9ba4ee06
5 changed files with 44 additions and 16 deletions
|
@ -184,7 +184,7 @@ unsafe fn grab_addrs(lua: *mut lua_State) {
|
|||
});
|
||||
}
|
||||
|
||||
unsafe extern "C" fn make_ephemereal(lua: *mut lua_State) -> c_int {
|
||||
unsafe extern "C" fn make_ephemerial(lua: *mut lua_State) -> c_int {
|
||||
unsafe {
|
||||
let entity_id = LUA.lua_tointeger(lua, 1) as u32;
|
||||
STATE.with(|state| {
|
||||
|
@ -226,7 +226,7 @@ pub unsafe extern "C" fn luaopen_ewext0(lua: *mut lua_State) -> c_int {
|
|||
LUA.lua_setfield(lua, -2, c"load_world_state".as_ptr());
|
||||
LUA.lua_pushcclosure(lua, Some(save_world_state_lua), 0);
|
||||
LUA.lua_setfield(lua, -2, c"save_world_state".as_ptr());
|
||||
LUA.lua_pushcclosure(lua, Some(make_ephemereal), 0);
|
||||
LUA.lua_pushcclosure(lua, Some(make_ephemerial), 0);
|
||||
LUA.lua_setfield(lua, -2, c"make_ephemerial".as_ptr());
|
||||
}
|
||||
println!("Initializing ewext - Ok");
|
||||
|
|
|
@ -54,6 +54,7 @@ local function spawn_perk(perk_info, auto_pickup_entity)
|
|||
EntityAddChild(ctx.my_player.entity, icon)
|
||||
end
|
||||
|
||||
local to_spawn = {}
|
||||
|
||||
local function give_one_perk(entity_who_picked, perk_info, count)
|
||||
lazyload()
|
||||
|
@ -66,6 +67,7 @@ local function give_one_perk(entity_who_picked, perk_info, count)
|
|||
end
|
||||
|
||||
if not perks_to_ignore[perk_info.id] then
|
||||
GamePrint(perk_info.id)
|
||||
-- add game effect
|
||||
if perk_info.game_effect ~= nil then
|
||||
local game_effect_comp, ent = GetGameEffectLoadTo( entity_who_picked, perk_info.game_effect, true )
|
||||
|
@ -103,7 +105,11 @@ local function give_one_perk(entity_who_picked, perk_info, count)
|
|||
|
||||
if global_perks[perk_info.id]
|
||||
and perk_fns.get_my_perks()[perk_info.id] == nil then
|
||||
spawn_perk(perk_info, true)
|
||||
if not EntityHasTag(ctx.my_player.entity, "ew_notplayer") then
|
||||
spawn_perk(perk_info, true)
|
||||
else
|
||||
table.insert(to_spawn, perk_info)
|
||||
end
|
||||
global_perks[perk_info.id] = false
|
||||
end
|
||||
end
|
||||
|
@ -135,7 +141,6 @@ function perk_fns.update_perks(perk_data, player_data)
|
|||
util.set_ent_variable(entity, "ew_current_perks", perk_data)
|
||||
end
|
||||
|
||||
|
||||
function perk_fns.update_perks_for_entity(perk_data, entity, allow_perk)
|
||||
lazyload()
|
||||
local current_counts = util.get_ent_variable(entity, "ew_current_perks") or {}
|
||||
|
@ -164,4 +169,14 @@ function perk_fns.update_perks_for_entity(perk_data, entity, allow_perk)
|
|||
-- util.set_ent_variable(entity, "ew_current_perks", perk_data)
|
||||
end
|
||||
|
||||
function perk_fns.on_world_update()
|
||||
if to_spawn ~= {} and GameGetFrameNum() % 60 == 40
|
||||
and not EntityHasTag(ctx.my_player.entity, "ew_notplayer") then
|
||||
for _, perk_info in ipairs(to_spawn) do
|
||||
spawn_perk(perk_info, true)
|
||||
end
|
||||
to_spawn = {}
|
||||
end
|
||||
end
|
||||
|
||||
return perk_fns
|
|
@ -540,7 +540,9 @@ function player_fns.spawn_player_for(peer_id, x, y, existing_playerdata)
|
|||
end
|
||||
|
||||
function player_fns.replace_player_entity(new_entity, player_data)
|
||||
util.make_ephemerial(new_entity)
|
||||
if player_data.entity ~= ctx.my_player.entity then
|
||||
util.make_ephemerial(new_entity)
|
||||
end
|
||||
if new_entity ~= nil then
|
||||
local old_entity = player_data.entity
|
||||
player_data.entity = new_entity
|
||||
|
|
|
@ -108,7 +108,7 @@ function module.on_world_update()
|
|||
local cpe = EntityGetFirstComponentIncludingDisabled(child, "VerletPhysicsComponent")
|
||||
local cx, cy = ComponentGetValue2(cpe, "m_position_previous")
|
||||
local dcx, dcy = mx - cx, my - cy
|
||||
if dcx * dcx + dcy * dcy > 300 * 300 then
|
||||
if dcx * dcx + dcy * dcy > 350 * 350 then
|
||||
EntityKill(child)
|
||||
else
|
||||
cape = child
|
||||
|
@ -116,19 +116,29 @@ function module.on_world_update()
|
|||
break
|
||||
end
|
||||
end
|
||||
if dx * dx + dy * dy > 300 * 300 then
|
||||
local light = EntityGetFirstComponentIncludingDisabled(ent, "LightComponent")
|
||||
if dx * dx + dy * dy > 350 * 350 then
|
||||
if cape ~= nil then
|
||||
EntityKill(cape)
|
||||
end
|
||||
elseif cape == nil then
|
||||
local player_cape_sprite_file
|
||||
if notplayer then
|
||||
player_cape_sprite_file = "mods/quant.ew/files/system/local_health/notplayer/notplayer_cape.xml"
|
||||
else
|
||||
player_cape_sprite_file = "mods/quant.ew/files/system/player/tmp/" .. peer_id .. "_cape.xml"
|
||||
if light ~= nil then
|
||||
EntitySetComponentIsEnabled(ent, light, false)
|
||||
end
|
||||
else
|
||||
if light ~= nil then
|
||||
EntitySetComponentIsEnabled(ent, light, true)
|
||||
end
|
||||
if cape == nil then
|
||||
local player_cape_sprite_file
|
||||
if notplayer then
|
||||
player_cape_sprite_file = "mods/quant.ew/files/system/local_health/notplayer/notplayer_cape.xml"
|
||||
else
|
||||
player_cape_sprite_file = "mods/quant.ew/files/system/player/tmp/" .. peer_id .. "_cape.xml"
|
||||
end
|
||||
local cape2 = EntityLoad(player_cape_sprite_file, x, y)
|
||||
EntityAddChild(ent, cape2)
|
||||
|
||||
end
|
||||
local cape2 = EntityLoad(player_cape_sprite_file, x, y)
|
||||
EntityAddChild(ent, cape2)
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
|
|
|
@ -347,6 +347,7 @@ local function on_world_pre_update_inner()
|
|||
end
|
||||
end
|
||||
|
||||
perk_fns.on_world_update()
|
||||
wake_up_waiting_threads(1)
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue