You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
2.5 KiB
Lua
70 lines
2.5 KiB
Lua
local function print_aoi_events(aoi_events)
|
|
print("==========print_aoi_events========")
|
|
-- for watcher, grid_info in pairs(aoi_events) do
|
|
-- print("watcher", watcher)
|
|
-- for grid_idx, event_list in pairs(grid_info) do
|
|
-- --print("grid_idx", grid_idx)
|
|
-- for i = 1, 3 do
|
|
-- local sub_event_list = event_list[i]
|
|
-- if sub_event_list then
|
|
-- for _, e in ipairs(sub_event_list) do
|
|
-- if(e[1]==1 or e[1] == 'A') then
|
|
-- print(string.format("event:A,id:%d,x:%d,y:%d",e[2],e[3],e[4]))
|
|
-- elseif(e[1]==2 or e[1] == 'D') then
|
|
-- print(string.format("event:D,id:%d,x:%d,y:%d",e[2],e[3],e[4]))
|
|
-- else
|
|
-- print(string.format("event:U,id:%d,x:%d,y:%d",e[2],e[3],e[4]))
|
|
-- end
|
|
-- end
|
|
-- end
|
|
-- end
|
|
|
|
-- end
|
|
-- end
|
|
for watcher, watch_ret in pairs(aoi_events) do
|
|
print("watcher", watcher)
|
|
for _, data in ipairs(watch_ret) do
|
|
for _, e in ipairs(data) do
|
|
if (e[1] == 1 or e[1] == 'A') then
|
|
print(string.format("event:A,id:%d,x:%d,y:%d", e[2], e[3], e[4]))
|
|
elseif (e[1] == 2 or e[1] == 'D') then
|
|
print(string.format("event:D,id:%d,x:%d,y:%d", e[2], e[3], e[4]))
|
|
else
|
|
print(string.format("event:U,id:%d,x:%d,y:%d", e[2], e[3], e[4]))
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
local function my_aoi_test()
|
|
local my_aoi = require "laoi"
|
|
local world = my_aoi.create_world(4, 3)
|
|
my_aoi.add_obj(world, 7, 2, 2, 1, 1) -- my_aoi.add_obj(world, 7, 2,2,1,1)
|
|
my_aoi.add_obj(world, 1, 2, 2, 1, 1)
|
|
my_aoi.add_obj(world, 6, 3, 3, 1, 1)
|
|
print_aoi_events(my_aoi.update_aoi(world))
|
|
print_aoi_events(my_aoi.update_aoi(world))
|
|
|
|
my_aoi.set_obj(world, 7, 2, 3)
|
|
print_aoi_events(my_aoi.update_aoi(world))
|
|
|
|
my_aoi.add_obj(world, 2, 1, 1, 1, 1)
|
|
my_aoi.set_obj(world, 2, 1, 2)
|
|
print_aoi_events(my_aoi.update_aoi(world))
|
|
|
|
my_aoi.add_obj(world, 3, 2, 2, 1, 1)
|
|
my_aoi.del_obj(world, 3)
|
|
print_aoi_events(my_aoi.update_aoi(world))
|
|
|
|
my_aoi.set_obj(world, 2, 3, 3)
|
|
my_aoi.set_obj(world, 7, 1, 1)
|
|
print_aoi_events(my_aoi.update_aoi(world))
|
|
|
|
my_aoi.set_obj(world, 2, 3, 2)
|
|
my_aoi.set_obj(world, 2, 3, 1)
|
|
print_aoi_events(my_aoi.update_aoi(world))
|
|
end
|
|
|
|
my_aoi_test()
|