예제 #1
0
    public void OnSpawnServer(SpawnInfo info)
    {
        if (!info.SpawnItems)
        {
            hasCables  = false;
            stateSync  = MountedMonitorState.OpenEmpty;
            statusText = GameManager.Instance.CentComm.CommandStatusString;
        }

        if (doorControllers.Count > 0)
        {
            OnTextBroadcastReceived(StatusDisplayChannel.DoorTimer);
            foreach (var door in doorControllers)
            {
                if (door.IsHackable)
                {
                    HackingNode outsideSignalOpen = door.HackingProcess.GetNodeWithInternalIdentifier(HackingIdentifier.OutsideSignalOpen);
                    outsideSignalOpen.AddConnectedNode(door.HackingProcess.GetNodeWithInternalIdentifier(HackingIdentifier.OpenDoor));
                    outsideSignalOpen.AddConnectedNode(door.HackingProcess.GetNodeWithInternalIdentifier(HackingIdentifier.CancelCloseTimer));

                    HackingNode outsideSignalClose = door.HackingProcess.GetNodeWithInternalIdentifier(HackingIdentifier.OutsideSignalClose);
                    outsideSignalClose.AddConnectedNode(door.HackingProcess.GetNodeWithInternalIdentifier(HackingIdentifier.CloseDoor));
                }
            }
        }
        SyncSprite(stateSync, stateSync);
        centComm = GameManager.Instance.CentComm;
        centComm.OnStatusDisplayUpdate.AddListener(OnTextBroadcastReceived);
    }
예제 #2
0
 public void LinkDoor(DoorController doorController)
 {
     doorControllers.Add(doorController);
     OnTextBroadcastReceived(StatusDisplayChannel.DoorTimer);
     if (stateSync == MountedMonitorState.Image)
     {
         stateSync = MountedMonitorState.StatusText;
     }
 }
예제 #3
0
        public void OnSpawnServer(SpawnInfo info)
        {
            if (!info.SpawnItems)
            {
                hasCables  = false;
                stateSync  = MountedMonitorState.OpenEmpty;
                statusText = GameManager.Instance.CentComm.CommandStatusString;
            }

            if (doorControllers.Count > 0 || NewdoorControllers.Count > 0)
            {
                OnTextBroadcastReceived(StatusDisplayChannel.DoorTimer);
            }

            SyncSprite(stateSync, stateSync);
            centComm = GameManager.Instance.CentComm;
            centComm.OnStatusDisplayUpdate.AddListener(OnTextBroadcastReceived);
        }
예제 #4
0
        public void SyncSprite(MountedMonitorState stateOld, MountedMonitorState stateNew)
        {
            stateSync = stateNew;
            if (stateNew == MountedMonitorState.Off)
            {
                MonitorSpriteHandler.SetSprite(closedOff);
                DisplaySpriteHandler.Empty(networked: false);
                this.TryStopCoroutine(ref blinkHandle);
                textField.text = "";
            }

            if (stateNew == MountedMonitorState.StatusText)
            {
                this.StartCoroutine(BlinkText(), ref blinkHandle);
                DisplaySpriteHandler.Empty(networked: false);
            }
            else if (stateNew == MountedMonitorState.Image)
            {
                DisplaySpriteHandler.SetSpriteSO(joeNews, networked: false);
                this.TryStopCoroutine(ref blinkHandle);
                textField.text = "";
            }
            else if (stateNew == MountedMonitorState.OpenCabled)
            {
                MonitorSpriteHandler.SetSprite(openCabled);
            }
            else if (stateNew == MountedMonitorState.NonScrewedPanel)
            {
                MonitorSpriteHandler.SetSprite(closedOff);
                DisplaySpriteHandler.Empty(networked: false);
                this.TryStopCoroutine(ref blinkHandle);
                textField.text = "";
            }
            else if (stateNew == MountedMonitorState.OpenEmpty)
            {
                MonitorSpriteHandler.SetSprite(openEmpty);
            }
        }
예제 #5
0
    public void ServerPerformInteraction(HandApply interaction)
    {
        if (stateSync == MountedMonitorState.OpenCabled || stateSync == MountedMonitorState.OpenEmpty)
        {
            if (!hasCables && Validations.HasUsedItemTrait(interaction, CommonTraits.Instance.Cable) &&
                Validations.HasUsedAtLeast(interaction, 5))
            {
                //add 5 cables
                ToolUtils.ServerUseToolWithActionMessages(interaction, 2f,
                                                          "You start adding cables to the frame...",
                                                          $"{interaction.Performer.ExpensiveName()} starts adding cables to the frame...",
                                                          "You add cables to the frame.",
                                                          $"{interaction.Performer.ExpensiveName()} adds cables to the frame.",
                                                          () =>
                {
                    Inventory.ServerConsume(interaction.HandSlot, 5);
                    hasCables = true;
                    stateSync = MountedMonitorState.OpenCabled;
                });
            }
            else if (Validations.HasUsedItemTrait(interaction, CommonTraits.Instance.GlassSheet) &&
                     Validations.HasUsedAtLeast(interaction, 2))
            {
                //add 2 glass
                ToolUtils.ServerUseToolWithActionMessages(interaction, 2f,
                                                          "You start to put in the glass panel...",
                                                          $"{interaction.Performer.ExpensiveName()} starts to put in the glass panel...",
                                                          "You put in the glass panel.",
                                                          $"{interaction.Performer.ExpensiveName()} puts in the glass panel.",
                                                          () =>
                {
                    Inventory.ServerConsume(interaction.HandSlot, 2);
                    stateSync = MountedMonitorState.NonScrewedPanel;
                });
            }
            else if (hasCables && Validations.HasUsedItemTrait(interaction, CommonTraits.Instance.Wirecutter))
            {
                //cut out cables
                Chat.AddActionMsgToChat(interaction, $"You remove the cables.",
                                        $"{interaction.Performer.ExpensiveName()} removes the cables.");
                ToolUtils.ServerPlayToolSound(interaction);
                Spawn.ServerPrefab(CommonPrefabs.Instance.SingleCableCoil, SpawnDestination.At(gameObject), 5);
                stateSync           = MountedMonitorState.OpenEmpty;
                hasCables           = false;
                currentTimerSeconds = 0;
                doorControllers.Clear();
            }
        }
        else if (stateSync == MountedMonitorState.NonScrewedPanel)
        {
            if (Validations.HasUsedItemTrait(interaction, CommonTraits.Instance.Crowbar))
            {
                //remove glass
                Chat.AddActionMsgToChat(interaction, $"You remove the glass panel.",
                                        $"{interaction.Performer.ExpensiveName()} removes the glass panel.");
                ToolUtils.ServerPlayToolSound(interaction);
                Spawn.ServerPrefab(CommonPrefabs.Instance.GlassSheet, SpawnDestination.At(gameObject), 2);
                if (hasCables)
                {
                    stateSync = MountedMonitorState.OpenCabled;
                }
                else
                {
                    stateSync = MountedMonitorState.OpenEmpty;
                }
            }
            else if (Validations.HasUsedItemTrait(interaction, CommonTraits.Instance.Screwdriver))
            {
                //screw in monitor, completing construction
                Chat.AddActionMsgToChat(interaction, $"You connect the monitor.",
                                        $"{interaction.Performer.ExpensiveName()} connects the monitor.");
                ToolUtils.ServerPlayToolSound(interaction);
                if (hasCables)
                {
                    stateSync = MountedMonitorState.StatusText;
                }
            }
        }
        else
        {
            if (Validations.HasUsedItemTrait(interaction, CommonTraits.Instance.Screwdriver))
            {
                //disconnect the monitor
                Chat.AddActionMsgToChat(interaction, $"You disconnect the monitor.",
                                        $"{interaction.Performer.ExpensiveName()} disconnect the monitor.");
                ToolUtils.ServerPlayToolSound(interaction);
                stateSync = MountedMonitorState.NonScrewedPanel;
            }
            else if (stateSync == MountedMonitorState.Image)
            {
                ChangeChannelMessage(interaction);
                stateSync = MountedMonitorState.StatusText;
            }
            else if (stateSync == MountedMonitorState.StatusText)
            {
                if (channel == StatusDisplayChannel.DoorTimer)
                {
                    currentTimerSeconds += 60;
                    if (currentTimerSeconds > 600)
                    {
                        currentTimerSeconds = 1;
                    }

                    if (!countingDown)
                    {
                        StartCoroutine(TickTimer());
                    }
                    else
                    {
                        OnTextBroadcastReceived(StatusDisplayChannel.DoorTimer);
                    }
                }
                else
                {
                    ChangeChannelMessage(interaction);
                    stateSync = MountedMonitorState.Image;
                }
            }
        }
    }
예제 #6
0
 public void ServerPerformInteraction(HandApply interaction)
 {
     if (stateSync == MountedMonitorState.OpenCabled || stateSync == MountedMonitorState.OpenEmpty)
     {
         if (!hasCables && Validations.HasUsedItemTrait(interaction, CommonTraits.Instance.Cable) &&
             Validations.HasUsedAtLeast(interaction, 5))
         {
             //add 5 cables
             ToolUtils.ServerUseToolWithActionMessages(interaction, 2f,
                                                       "You start adding cables to the frame...",
                                                       $"{interaction.Performer.ExpensiveName()} starts adding cables to the frame...",
                                                       "You add cables to the frame.",
                                                       $"{interaction.Performer.ExpensiveName()} adds cables to the frame.",
                                                       () =>
             {
                 Inventory.ServerConsume(interaction.HandSlot, 5);
                 hasCables = true;
                 stateSync = MountedMonitorState.OpenCabled;
             });
         }
         else if (Validations.HasUsedItemTrait(interaction, CommonTraits.Instance.GlassSheet) &&
                  Validations.HasUsedAtLeast(interaction, 2))
         {
             //add 2 glass
             ToolUtils.ServerUseToolWithActionMessages(interaction, 2f,
                                                       "You start to put in the glass panel...",
                                                       $"{interaction.Performer.ExpensiveName()} starts to put in the glass panel...",
                                                       "You put in the glass panel.",
                                                       $"{interaction.Performer.ExpensiveName()} puts in the glass panel.",
                                                       () =>
             {
                 Inventory.ServerConsume(interaction.HandSlot, 2);
                 stateSync = MountedMonitorState.NonScrewedPanel;
             });
         }
         else if (hasCables && Validations.HasUsedItemTrait(interaction, CommonTraits.Instance.Wirecutter))
         {
             //cut out cables
             Chat.AddActionMsgToChat(interaction, $"You remove the cables.",
                                     $"{interaction.Performer.ExpensiveName()} removes the cables.");
             ToolUtils.ServerPlayToolSound(interaction);
             Spawn.ServerPrefab(CommonPrefabs.Instance.SingleCableCoil, SpawnDestination.At(gameObject), 5);
             stateSync           = MountedMonitorState.OpenEmpty;
             hasCables           = false;
             currentTimerSeconds = 0;
             doorControllers.Clear();
             NewdoorControllers.Clear();
         }
     }
     else if (stateSync == MountedMonitorState.NonScrewedPanel)
     {
         if (Validations.HasUsedItemTrait(interaction, CommonTraits.Instance.Crowbar))
         {
             //remove glass
             Chat.AddActionMsgToChat(interaction, $"You remove the glass panel.",
                                     $"{interaction.Performer.ExpensiveName()} removes the glass panel.");
             ToolUtils.ServerPlayToolSound(interaction);
             Spawn.ServerPrefab(CommonPrefabs.Instance.GlassSheet, SpawnDestination.At(gameObject), 2);
             if (hasCables)
             {
                 stateSync = MountedMonitorState.OpenCabled;
             }
             else
             {
                 stateSync = MountedMonitorState.OpenEmpty;
             }
         }
         else if (Validations.HasUsedItemTrait(interaction, CommonTraits.Instance.Screwdriver))
         {
             //screw in monitor, completing construction
             Chat.AddActionMsgToChat(interaction, $"You connect the monitor.",
                                     $"{interaction.Performer.ExpensiveName()} connects the monitor.");
             ToolUtils.ServerPlayToolSound(interaction);
             if (hasCables)
             {
                 stateSync = MountedMonitorState.StatusText;
             }
         }
     }
     else
     {
         if (Validations.HasUsedItemTrait(interaction, CommonTraits.Instance.Screwdriver))
         {
             //disconnect the monitor
             Chat.AddActionMsgToChat(interaction, $"You disconnect the monitor.",
                                     $"{interaction.Performer.ExpensiveName()} disconnect the monitor.");
             ToolUtils.ServerPlayToolSound(interaction);
             stateSync = MountedMonitorState.NonScrewedPanel;
         }
         else if (stateSync == MountedMonitorState.Image)
         {
             ChangeChannelMessage(interaction);
             stateSync = MountedMonitorState.StatusText;
         }
         else if (stateSync == MountedMonitorState.StatusText)
         {
             if (channel == StatusDisplayChannel.DoorTimer)
             {
                 if (AccessRestrictions == null || AccessRestrictions.CheckAccess(interaction.Performer))
                 {
                     AddTime(60);
                 }
                 else
                 {
                     Chat.AddExamineMsg(interaction.Performer, $"Access Denied.");
                     // Play sound
                     SoundManager.PlayNetworkedAtPos(CommonSounds.Instance.AccessDenied,
                                                     gameObject.AssumedWorldPosServer(), sourceObj: gameObject);
                 }
             }
             else
             {
                 ChangeChannelMessage(interaction);
                 stateSync = MountedMonitorState.Image;
             }
         }
     }
 }