/// <summary>
        /// Initializes this frame's state to be from a just-deconstructed machine
        /// </summary>
        /// <param name="machine"></param>
        public void ServerInitFromComputer(Machine machine)
        {
            spriteRender.sprite = boxCircuit;
            ServerChangeSprite(SpriteStates.BoxCircuit);

            // Create the circuit board
            var board = Spawn.ServerPrefab(machine.MachineBoardPrefab).GameObject;

            board.GetComponent <MachineCircuitBoard>().SetMachineParts(machine.MachineParts);                                    // Basic item requirements to the circuit board

            board.GetComponent <ItemAttributesV2>().ServerSetArticleName(machine.MachineParts.NameOfCircuitBoard);               // Sets name of board

            board.GetComponent <ItemAttributesV2>().ServerSetArticleDescription(machine.MachineParts.DescriptionOfCircuitBoard); // Sets desc of board

            // Basic items to the machine frame from the despawned machine
            machineParts = machine.MachineParts;

            allowedTraits.Clear();

            foreach (var list in machineParts.machineParts)
            {
                allowedTraits.Add(new AllowedTraitList(list.itemTrait));
            }

            partsInFrame = machine.PartsInFrame;

            basicPartsUsed = machine.BasicPartsUsed;

            // Put it in
            Inventory.ServerAdd(board, circuitBoardSlot);

            // Set initial state
            objectBehaviour.ServerSetPushable(false);
            stateful.ServerChangeState(partsAddedState);
        }
        /// <summary>
        /// Stage 3, add circuit board which contains data for construction, or use wrench to go back to stage 2
        /// </summary>
        /// <param name="interaction"></param>
        private void WrenchedStateInteraction(HandApply interaction)
        {
            if (Validations.HasUsedComponent <MachineCircuitBoard>(interaction) && circuitBoardSlot.IsEmpty)
            {
                //Transfer parts data
                machineParts = interaction.UsedObject.GetComponent <MachineCircuitBoard>().MachinePartsUsed;

                if (machineParts == null)
                {
                    Chat.AddExamineMsgFromServer(interaction.Performer, "The machine circuit board is not specialised.");
                    return;
                }

                //stick in the circuit board
                Chat.AddActionMsgToChat(interaction, $"You place the {interaction.UsedObject.ExpensiveName()} inside the frame.",
                                        $"{interaction.Performer.ExpensiveName()} places the {interaction.UsedObject.ExpensiveName()} inside the frame.");

                //Syncing allowed traits to clients
                allowedTraits.Clear();

                foreach (var list in machineParts.machineParts)
                {
                    allowedTraits.Add(new AllowedTraitList(list.itemTrait));
                }

                Inventory.ServerTransfer(interaction.HandSlot, circuitBoardSlot);
                stateful.ServerChangeState(circuitAddedState);
                putBoardInManually = true;

                //sprite change
                spriteRender.sprite = boxCircuit;
                ServerChangeSprite(SpriteStates.BoxCircuit);
            }
            else if (Validations.HasUsedItemTrait(interaction, CommonTraits.Instance.Wrench))
            {
                //unwrench
                ToolUtils.ServerUseToolWithActionMessages(interaction, 2f,
                                                          "You start to unfasten the frame...",
                                                          $"{interaction.Performer.ExpensiveName()} starts to unfasten the frame...",
                                                          "You unfasten the frame.",
                                                          $"{interaction.Performer.ExpensiveName()} unfastens the frame.",
                                                          () => objectBehaviour.ServerSetAnchored(false, interaction.Performer));
                stateful.ServerChangeState(cablesAddedState);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Initializes this frame's state to be from a just-deconstructed machine
        /// </summary>
        /// <param name="machine"></param>
        public void ServerInitFromComputer(Machine machine)
        {
            spriteHandler.ChangeSprite((int)SpriteStates.BoxCircuit);

            // Create the circuit board
            var board = Spawn.ServerPrefab(machine.MachineBoardPrefab).GameObject;

            if (board == null)
            {
                Logger.LogWarning("MachineBoardPrefab was null", Category.ItemSpawn);
                return;
            }

            board.GetComponent <MachineCircuitBoard>().SetMachineParts(machine.MachineParts);            // Basic item requirements to the circuit board

            //PM: Below is commented out because I've decided to make all the machines use appropriate machine board .prefabs instead of the blank board.

            /*
             * board.GetComponent<ItemAttributesV2>().ServerSetArticleName(machine.MachineParts.NameOfCircuitBoard); // Sets name of board
             *
             * board.GetComponent<ItemAttributesV2>().ServerSetArticleDescription(machine.MachineParts.DescriptionOfCircuitBoard); // Sets desc of board
             */

            // Basic items to the machine frame from the despawned machine
            machineParts = machine.MachineParts;

            allowedTraits.Clear();

            foreach (var list in machineParts.machineParts)
            {
                allowedTraits.Add(new AllowedTraitList(list.itemTrait));
            }

            partsInFrame = machine.PartsInFrame;

            basicPartsUsed = machine.BasicPartsUsed;

            // Put it in
            Inventory.ServerAdd(board, circuitBoardSlot);

            // Set initial state
            objectBehaviour.ServerSetPushable(false);
            stateful.ServerChangeState(partsAddedState);
            putBoardInManually = false;
        }
Beispiel #4
0
 public void SetMachineParts(MachineParts machineParts)
 {
     MachineParts = machineParts;
 }
Beispiel #5
0
 public void SetMachineParts(MachineParts MachineParts)
 {
     machineParts = MachineParts;
 }