Beispiel #1
0
        private void Start()
        {
            if (CustomNetworkManager.IsServer == false)
            {
                return;
            }

            if (startSetUp)
            {
                isWelded   = true;
                isWrenched = true;
                directional.LockDirection = true;
                objectBehaviour.ServerSetPushable(false);
            }
        }
 private void UpdateConnected()
 {
     ToolUtils.ServerPlayToolSound(interaction);
     RefreshOverlays();
     objectBehaviour.ServerSetPushable(!IsConnected);
     ServerOnConnectionStatusChange.Invoke(IsConnected);
 }
Beispiel #3
0
    void UpdateSecured(bool _isSecured)
    {
        isSecured = _isSecured;
        if (isServer)
        {
            objectBehaviour.ServerSetPushable(!isSecured);
        }


        SoundManager.PlayAtPosition("Wrench", transform.position);

        if (!isSecured)
        {
            spriteRend.sprite = generatorUnSecuredSprite;
        }
        else
        {
            if (!isOn)
            {
                spriteRend.sprite = generatorSecuredSprite;
            }
            else
            {
                spriteRend.sprite = generatorOnSprite;
            }
        }
    }
        /// <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);
        }
Beispiel #5
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.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;
        }
Beispiel #6
0
        private void Start()
        {
            if (CustomNetworkManager.IsServer == false)
            {
                return;
            }

            ChangeState(startingState);
            rotation = -startingAngle;
            transform.localEulerAngles       = new Vector3(0, 0, rotation);
            spriteTransform.localEulerAngles = Vector3.zero;

            if (startSetUp)
            {
                isWelded = true;
                objectBehaviour.ServerSetPushable(false);
            }
        }
Beispiel #7
0
 private void Disconnect()
 {
     if (isConnected)
     {
         if (connector != null)
         {
             connector.DisconnectCanister();
         }
         else if (connectorFuel != null)
         {
             connectorFuel.DisconnectCanister();
         }
         isConnected = false;
         connectorRenderer.sprite = null;
         SetConnectedSprite(null);
         objectBehaviour.ServerSetPushable(true);
         ServerOnConnectionStatusChange.Invoke(false);
     }
 }
Beispiel #8
0
 public virtual void SetAnchored(bool value)
 {
     anchored = value;
     objectBehaviour.ServerSetPushable(!value);
     //now that it's anchored, it can't be picked up
     //TODO: This is getting called client side when joining, which is bad because it's only meant
     //to be called server side. Most likely late joining clients have the wrong
     //client-side state due to this issue.
     pickupable.ServerSetCanPickup(!value);
 }
Beispiel #9
0
	/// <summary>
	/// Initializes this frame's state to be from a just-deconstructed computer
	/// </summary>
	/// <param name="computer"></param>
	public void ServerInitFromComputer(Computer computer)
	{
		//create the circuit board
		var board = Spawn.ServerPrefab(computer.CircuitBoardPrefab);
		//put it in
		Inventory.ServerAdd(board.GameObject, circuitBoardSlot);

		//set initial state
		objectBehaviour.ServerSetPushable(false);
		stateful.ServerChangeState(glassAddedState);
	}
Beispiel #10
0
        /// <summary>
        /// Initializes this frame's state to be from a just-deconstructed machine
        /// </summary>
        /// <param name="machine"></param>
        public void ServerInitFromComputer(APC apc)
        {
            ItemSlot apcPowerControlSlot = apc.GetComponent <ItemStorage>().GetIndexedItemSlot(0);
            ItemSlot apcPowerCellSlot    = apc.GetComponent <ItemStorage>().GetIndexedItemSlot(1);

            Inventory.ServerTransfer(apcPowerControlSlot, powerControlSlot);
            Inventory.ServerTransfer(apcPowerCellSlot, powerCellSlot);

            spriteHandler.ChangeSprite((int)SpriteStates.FrameWrenched);

            // Set initial state
            objectBehaviour.ServerSetPushable(false);
            stateful.ServerChangeState(wrenchedState);
        }
Beispiel #11
0
        private void UpdateConnected()
        {
            ToolUtils.ServerPlayToolSound(interaction);
            RefreshOverlays();
            objectBehaviour.ServerSetPushable(!IsConnected);
            ServerOnConnectionStatusChange.Invoke(IsConnected);

            // Will release gas if canister valve was not turned off before disconnecting from a connector,
            // or stop the release of gas if canister valve is open and is now connected.
            if (ValveIsOpen)
            {
                GasContainer.SetVent(!IsConnected);
            }
        }
        /// <summary>
        /// Creating an airlock assembly from a deconstructed airlock.
        /// </summary>
        /// <param name="airlockElectronicsPrefab">prefab to create airlock electronics</param>
        /// <param name="airlockAccess">access for installation in the airlock electronics</param>
        /// <param name="isWindowed">add glass or not</param>
        public void ServerInitFromComputer(GameObject airlockElectronicsPrefab, Access airlockAccess, bool isWindowed)
        {
            //create the airlock electronics
            var airlockElectronics = Spawn.ServerPrefab(airlockElectronicsPrefab, SpawnDestination.At(gameObject)).GameObject;

            airlockElectronics.GetComponent <AirlockElectronics>().CurrentAccess = airlockAccess;

            objectBehaviour.ServerSetPushable(false);
            stateful.ServerChangeState(cablesAddedState);
            overlayHackingHandler.ChangeSprite((int)Panel.WiresAdded);
            if (isWindowed)
            {
                overlayFillHandler.ChangeSprite((int)Fill.GlassFill);
                glassAdded = true;
            }
        }
Beispiel #13
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;
        }
 /// <summary>
 /// Useful for mapping in disposal machine. Just place the machine over a disposal pipe terminal during mapping.
 /// </summary>
 protected virtual void SpawnMachineAsInstalled()
 {
     SetMachineInstalled();
     objectBehaviour.ServerSetPushable(false);
 }
Beispiel #15
0
 void ToggleAnchored(bool value)
 {
     objectBehaviour.ServerSetPushable(!value);
     anchored = value;
 }