/// <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.Construction); 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; partsInFrame = machine.PartsInFrame; basicPartsUsed = machine.BasicPartsUsed; // Save vendor content if necessary, which is stored temporarily in the machine frame and transferred to the restock item if it exists var vendor = machine.GetComponent <Vendor>(); if (vendor != null) { previousVendorContent = vendor.VendorContent; } TryTransferVendorContent(); allowedTraits.Clear(); if (machineParts == null || machineParts.machineParts == null) { Logger.LogError($"Failed to find machine parts for {machineParts.OrNull()?.name ?? board.ExpensiveName()}"); } else { foreach (var list in machineParts.machineParts) { allowedTraits.Add(new AllowedTraitList(list.itemTrait)); } } // Put it in Inventory.ServerAdd(board, circuitBoardSlot); // Set initial state objectBehaviour.ServerSetPushable(false); stateful.ServerChangeState(partsAddedState); putBoardInManually = false; }
/// <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)); } netIdentity.isDirty = true; Inventory.ServerTransfer(interaction.HandSlot, circuitBoardSlot); stateful.ServerChangeState(circuitAddedState); putBoardInManually = true; spriteHandler.ChangeSprite((int)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); } }
/// <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; }
public void SetMachineParts(MachineParts machineParts) { MachineParts = machineParts; }