mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
sync worms nicely
This commit is contained in:
parent
13e1173092
commit
9ee8b15c90
1 changed files with 5 additions and 27 deletions
|
@ -21,9 +21,8 @@ local EnemyDataNoMotion = util.make_type({
|
||||||
})
|
})
|
||||||
|
|
||||||
local EnemyDataWorm = util.make_type({
|
local EnemyDataWorm = util.make_type({
|
||||||
u32 = {"enemy_id", "target"},
|
u32 = {"enemy_id"},
|
||||||
f32 = {"x", "y", "vx", "vy", "tx", "ty"},
|
f32 = {"x", "y", "vx", "vy", "tx", "ty"},
|
||||||
peer_id = {"peer_id"}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
local EnemyDataKolmi = util.make_type({
|
local EnemyDataKolmi = util.make_type({
|
||||||
|
@ -275,6 +274,7 @@ function enemy_sync.host_upload_entities()
|
||||||
end
|
end
|
||||||
local en_data
|
local en_data
|
||||||
local worm = EntityGetFirstComponentIncludingDisabled(enemy_id, "WormAIComponent")
|
local worm = EntityGetFirstComponentIncludingDisabled(enemy_id, "WormAIComponent")
|
||||||
|
or EntityGetFirstComponentIncludingDisabled(enemy_id, "BossDragonComponent")
|
||||||
if EntityHasTag(enemy_id, "boss_centipede") then
|
if EntityHasTag(enemy_id, "boss_centipede") then
|
||||||
en_data = EnemyDataKolmi {
|
en_data = EnemyDataKolmi {
|
||||||
enemy_id = enemy_id,
|
enemy_id = enemy_id,
|
||||||
|
@ -285,14 +285,7 @@ function enemy_sync.host_upload_entities()
|
||||||
enabled = EntityGetFirstComponent(enemy_id, "BossHealthBarComponent", "disabled_at_start") ~= nil,
|
enabled = EntityGetFirstComponent(enemy_id, "BossHealthBarComponent", "disabled_at_start") ~= nil,
|
||||||
}
|
}
|
||||||
elseif worm ~= nil then
|
elseif worm ~= nil then
|
||||||
local tx, ty = ComponentGetValue2(worm, "mRandomTarget")
|
local tx, ty = ComponentGetValue2(worm, "mTargetVec")
|
||||||
local target = ComponentGetValue2(worm, "mTargetEntityId")
|
|
||||||
local peer_id
|
|
||||||
local data = player_fns.get_player_data_by_local_entity_id(target)
|
|
||||||
if data ~= nil then
|
|
||||||
peer_id = data.peer_id
|
|
||||||
target = nil
|
|
||||||
end
|
|
||||||
en_data = EnemyDataWorm {
|
en_data = EnemyDataWorm {
|
||||||
enemy_id = enemy_id,
|
enemy_id = enemy_id,
|
||||||
x = x,
|
x = x,
|
||||||
|
@ -301,8 +294,6 @@ function enemy_sync.host_upload_entities()
|
||||||
vy = vy,
|
vy = vy,
|
||||||
tx = tx,
|
tx = tx,
|
||||||
ty = ty,
|
ty = ty,
|
||||||
target = target,
|
|
||||||
peer_id = peer_id,
|
|
||||||
}
|
}
|
||||||
elseif math.abs(vx) < 0.01 and math.abs(vy) < 0.01 then
|
elseif math.abs(vx) < 0.01 and math.abs(vy) < 0.01 then
|
||||||
en_data = EnemyDataNoMotion {
|
en_data = EnemyDataNoMotion {
|
||||||
|
@ -608,23 +599,10 @@ local function sync_enemy(enemy_info_raw, force_no_cull)
|
||||||
EntitySetTransform(enemy_id, x, y)
|
EntitySetTransform(enemy_id, x, y)
|
||||||
end
|
end
|
||||||
local worm = EntityGetFirstComponentIncludingDisabled(enemy_id, "WormAIComponent")
|
local worm = EntityGetFirstComponentIncludingDisabled(enemy_id, "WormAIComponent")
|
||||||
|
or EntityGetFirstComponentIncludingDisabled(enemy_id, "BossDragonComponent")
|
||||||
if worm ~= nil and ffi.typeof(en_data) == EnemyDataWorm then
|
if worm ~= nil and ffi.typeof(en_data) == EnemyDataWorm then
|
||||||
local tx, ty = en_data.tx, en_data.ty
|
local tx, ty = en_data.tx, en_data.ty
|
||||||
ComponentSetValue2(worm, "mRandomTarget", tx, ty)
|
ComponentSetValue2(worm, "mTargetVec", tx, ty)
|
||||||
local ent
|
|
||||||
if en_data.peer_id == nil then
|
|
||||||
if ctx.entity_by_remote_id[en_data.target] ~= nil then
|
|
||||||
ent = ctx.entity_by_remote_id[en_data.target].id
|
|
||||||
end
|
|
||||||
else
|
|
||||||
--help quant :( GamePrint(ffi.string(en_data.peer_id))
|
|
||||||
--if ctx.players[ffi.string(en_data.peer_id)] ~= nil then
|
|
||||||
-- ent = ctx.players[ffi.string(en_data.peer_id)].entity
|
|
||||||
--end
|
|
||||||
end
|
|
||||||
if ent ~= nil then
|
|
||||||
ComponentSetValue2(worm, "mTargetEntityId", ent)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if ffi.typeof(en_data) == EnemyDataKolmi and en_data.enabled then
|
if ffi.typeof(en_data) == EnemyDataKolmi and en_data.enabled then
|
||||||
local lua_components = EntityGetComponentIncludingDisabled(enemy_id, "LuaComponent") or {}
|
local lua_components = EntityGetComponentIncludingDisabled(enemy_id, "LuaComponent") or {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue