-
Notifications
You must be signed in to change notification settings - Fork 2
/
control.lua
72 lines (58 loc) · 2.72 KB
/
control.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
-- This file is part of Storage Energistics
-- Author: Nividica
-- Created: 2017-10-17
-- Description: Execution entrypoint for the mod
-- The SE variable contains references to all instances used by the mod
-- Very few things live in the lua global table, and only nodes live in the factorio global table
-- Create the instance container
SE = {
-- Map<ItemName :: string -> MaxStackSize :: int>
StackSizeCache = {}
}
function SE.CachePrototypes()
-- Get item stack sizes
for name, proto in pairs(game.item_prototypes) do
SE.StackSizeCache[name] = proto.stack_size
end
end
-- Define Mod --
-- This section defines and loads all tables used by the mod
-- Create constants
SE.Constants = (require "SEConstants")()
-- Get settings
SE.Settings = (require "SESettings")()
-- Create the logger
SE.Logger = (require "Utils/Logger")()
-- Log trace messages
SE.Logger.EnableTrace = true
SE.Logger.EnableLogging = false
-- Create the data store
SE.DataStore = (require "SEDataStore")()
-- Create the storage networks manager
SE.Networks = (require "StorageNetwork/NetworksManager")()
-- Create the storage network handler
SE.NetworkHandler = (require "StorageNetwork/NetworkHandler")()
-- Create node handlers
SE.NodeHandlers = (require "StorageNetwork/HandlerRegistry")()
local BaseHandler = (require "StorageNetwork/NodeHandlers/BaseNode")()
SE.NodeHandlers.AddHandler(BaseHandler)
SE.NodeHandlers.AddHandler((require "StorageNetwork/NodeHandlers/ControllerNode")(BaseHandler))
SE.NodeHandlers.AddHandler((require "StorageNetwork/NodeHandlers/EnergyAcceptorNode")(BaseHandler))
SE.NodeHandlers.AddHandler((require "StorageNetwork/NodeHandlers/InterfaceNode")(BaseHandler))
SE.NodeHandlers.AddHandler((require "StorageNetwork/NodeHandlers/StorageNode")(BaseHandler))
-- Link node handlers with entities
local protoNames = SE.Constants.Names.Proto
local handlerNames = SE.Constants.Names.NodeHandlers
SE.NodeHandlers.AddEntityHandler(protoNames.Controller.Entity, handlerNames.Controller)
SE.NodeHandlers.AddEntityHandler(protoNames.EnergyAcceptor.Entity, handlerNames.EnergyAcceptor)
SE.NodeHandlers.AddEntityHandler(protoNames.StorageChestMk1.Entity, handlerNames.Storage)
SE.NodeHandlers.AddEntityHandler(protoNames.StorageChestMk2.Entity, handlerNames.Storage)
SE.NodeHandlers.AddEntityHandler(protoNames.RequesterChest.Entity, handlerNames.Storage)
SE.NodeHandlers.AddEntityHandler(protoNames.InterfaceChest.Entity, handlerNames.Interface)
SE.NodeHandlers.AddEntityHandler(protoNames.ProviderChest.Entity, handlerNames.Interface)
-- Create the Gui manager
SE.GuiManager = (require "Guis/GuiManager")()
-- Create the game event manager
SE.GameEventManager = (require "GameEvents/GameEventManager")()
-- Register for events
SE.GameEventManager.RegisterHandlers()