Exemple #1
0
        public ISignalNode GetNodeAt(NodePos pos)
        {
            ISignalNode node;

            nodes.TryGetValue(pos, out node);
            return(node);
        }
 public void OnValueChanged(NodePos pos, byte value)
 {
     if (value > 0 && currentState == false)
     {
         SwitchOn();
     }
     if (value == 0 && currentState == true)
     {
         SwitchOff();
     }
 }
Exemple #3
0
 public ISignalNode GetNodeAt(NodePos pos)
 {
     foreach (ISignalNode node in nodes)
     {
         if (node.Pos == pos)
         {
             return(node);
         }
     }
     return(null);
 }
Exemple #4
0
        public void OnNodeUpdate(NodePos pos)
        {
            ISignalNode node = this.GetNodeAt(pos);

            if (node == null)
            {
                return;
            }
            IBESignalReceptor receptor = this.Blockentity as IBESignalReceptor;

            receptor?.OnValueChanged(pos, node.value);

            return;
        }
        public override void Initialize(ICoreAPI api, JsonObject properties)
        {
            //initialize the nodes
            base.Initialize(api, properties);

            NodePos pos1 = new NodePos(this.Pos, 0);
            NodePos pos2 = new NodePos(this.Pos, 1);

            ISignalNode node1 = GetNodeAt(pos1);
            ISignalNode node2 = GetNodeAt(pos2);

            if (node1 == null || node2 == null)
            {
                return;
            }

            node1.Connections.Add(new Connection(pos1, pos2));
            node2.Connections.Add(new Connection(pos2, pos1));

            //return;

            /*JsonObject[] conON = properties["connectionsON"]?.AsArray();
             * JsonObject[] conOFF = properties["connectionsOFF"]?.AsArray();
             *
             * if (conON != null)
             * {
             *  foreach (JsonObject json in conON)
             *  {
             *      int index1 = json["i1"].AsInt(-1);
             *      int index2 = json["i2"].AsInt(-1);
             *      if (!IsConnectionValid(index1, index2)) continue;
             *      BlockPos pos = this.Blockentity.Pos;
             *      NodePos pos1 = new NodePos(pos, index1);
             *      NodePos pos2 = new NodePos(pos, index2);
             *
             *      Connection con = new Connection(pos1, pos2);
             *
             *  }
             * }*/
        }
Exemple #6
0
 public Connection(NodePos pos1, NodePos pos2)
 {
     this.pos1 = pos1;
     this.pos2 = pos2;
 }
Exemple #7
0
 public void OnNodeUpdate(NodePos pos)
 {
 }
Exemple #8
0
 public Vec3f GetNodePosinBlock(NodePos pos)
 {
     return(null);
 }
Exemple #9
0
 public Vec3f GetNodePosinBlock(NodePos pos)
 {
     return(new Vec3f(0.5f, 0.5f, 0.5f));
 }