local npcManager = require("npcManager")

local ludwigShell = {}
local npcID = NPC_ID


function ludwigShell.onInitAPI()
	npcManager.registerEvent(npcID, ludwigShell, "onTickNPC")
end


function ludwigShell.onTickNPC(v)
	if Defines.levelFreeze then return end

	if v.despawnTimer <= 0 then
		return
	end

	-- Kill Everyone
	for _,npc in NPC.iterateIntersecting(v.x,v.y,v.x + v.width,v.y + v.height) do
		if npc ~= v and npc.despawnTimer > 0 and not npc.isGenerator and not npc.friendly and NPC.HITTABLE_MAP[npc.id] then
			npc:harm(HARM_TYPE_NPC)
		end
	end

	if not v.collidesBlockLeft and not v.collidesBlockRight then
		v:mem(0x120,FIELD_BOOL,false)
	end
end


return ludwigShell