public override void Initialize(ICoreAPI api, JsonObject properties) { base.Initialize(api, properties); api.Logger.Debug("Initializing device at {0}", this.Blockentity.Pos); wireMod = api.ModLoader.GetModSystem <HangingWiresMod>(); signalMod = api.ModLoader.GetModSystem <SignalNetworkMod>(); Pos = this.Blockentity?.Pos; //TODO, test if nodes have already been initialized via TreeAttributes JsonObject[] nodesTree = properties["signalNodes"]?.AsArray(); if (nodesTree != null) { //TODO check duplicated index foreach (JsonObject json in nodesTree) { int index = json["index"].AsInt(); bool isSource = json.KeyExists("isSource") ? json["isSource"].AsBool(): false; BaseNode newNode = new BaseNode(); newNode.output = isSource ? (byte)15 : (byte)0; newNode.Pos = new NodePos(this.Blockentity.Pos, index); newNode.Connections.AddRange(wireMod.GetWireConnectionsFrom(newNode.Pos)); //TODO add internal connections nodes.Add(newNode); } } signalMod.OnDeviceInitialized(this); }
public void Init(SignalNetworkMod mod) { this.mod = mod; chunksize = mod.Api.World.BlockAccessor.ChunkSize; }
public SignalNetwork(SignalNetworkMod mod, long networkId) { this.networkId = networkId; Init(mod); }