mod: entity prototype improvements and refactoring
- refactor and move queue & emitter classes for consistency - don't emit all prototypes at once - add simple queue for 'instant' packets so the printer doesn't get overwhelmed and mix up the output
This commit is contained in:
parent
ae0eb98f12
commit
90aa086dd4
33 changed files with 742 additions and 652 deletions
|
|
@ -1,21 +1,20 @@
|
|||
local ____exports = {}
|
||||
local ____PacketEmitter = require("main.PacketEmitter")
|
||||
local PacketEmitter = ____PacketEmitter.default
|
||||
local ____kafkatorio_2Dschema = require("generated.kafkatorio-schema")
|
||||
local KafkatorioPacketData = ____kafkatorio_2Dschema.KafkatorioPacketData
|
||||
local Type = KafkatorioPacketData.Type
|
||||
local ____KafkatorioPacketQueue = require("main.emitting.KafkatorioPacketQueue")
|
||||
local KafkatorioPacketQueue = ____KafkatorioPacketQueue.default
|
||||
script.on_event(
|
||||
defines.events.on_console_chat,
|
||||
function(event)
|
||||
local update = {type = Type.ConsoleChatUpdate, authorPlayerIndex = event.player_index or nil, content = event.message}
|
||||
PacketEmitter:emitInstantPacket(update)
|
||||
local update = {type = KafkatorioPacketData.Type.ConsoleChatUpdate, authorPlayerIndex = event.player_index or nil, content = event.message}
|
||||
KafkatorioPacketQueue:enqueue(update)
|
||||
end
|
||||
)
|
||||
script.on_event(
|
||||
defines.events.on_console_command,
|
||||
function(event)
|
||||
local update = {type = Type.ConsoleCommandUpdate, authorPlayerIndex = event.player_index or nil, command = event.command, parameters = event.parameters}
|
||||
PacketEmitter:emitInstantPacket(update)
|
||||
local update = {type = KafkatorioPacketData.Type.ConsoleCommandUpdate, authorPlayerIndex = event.player_index or nil, command = event.command, parameters = event.parameters}
|
||||
KafkatorioPacketQueue:enqueue(update)
|
||||
end
|
||||
)
|
||||
return ____exports
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue