Пример #1
0
        public static void PlaceBoard()
        {
            if (StuffPlacer.OkayToPlace)
            {
                foreach (var item in BoardPlacer.BoardBeingPlaced.GetComponentsInChildren <ObjectInfo>())
                {
                    var netObj = item.GetComponent <NetObject>() ?? item.gameObject.AddComponent <NetObject>();
                    netObj.NetID = NetObject.GetNewID();
                }

                foreach (var item in BoardPlacer.BoardBeingPlaced.GetComponentsInChildren <NetObject>())
                {
                    item.enabled = true;
                }

                var boardComp = BoardPlacer.BoardBeingPlaced.GetComponent <CircuitBoard>();
                var parent    = BoardPlacer.ReferenceObject.transform.parent;

                var packet = PlaceBoardPacket.BuildFromBoard(boardComp, parent);

                Network.SendPacket(packet);

                foreach (var item in boardComp.GetComponentsInChildren <CircuitOutput>())
                {
                    CircuitStatePacket.SetOutputState(item, item.On, true);
                }
            }
        }
Пример #2
0
        public static void Place(StackBoardMenu __instance)
        {
            if (!ModUtilities.GetFieldValue <bool>(__instance, "CurrentPlacementIsValid"))
            {
                return;
            }

            var allBoards   = ModUtilities.GetFieldValue <List <GameObject> >(__instance, "AllSubBoardsInvolvedWithStacking");
            var parentBoard = ModUtilities.GetFieldValue <GameObject>(__instance, "BoardBeingStacked");
            var firstBoard  = allBoards.First(o => o != parentBoard);

            foreach (var item in firstBoard.GetComponentsInChildren <ObjectInfo>())
            {
                var netObj = item.GetComponent <NetObject>() ?? item.gameObject.AddComponent <NetObject>();
                netObj.NetID = NetObject.GetNewID();
            }

            var packet = PlaceBoardPacket.BuildFromBoard(firstBoard.GetComponent <CircuitBoard>(), parentBoard.transform);

            Network.SendPacket(packet);
        }