Beispiel #1
0
        public override DelayedActionInstance InteractWith(Interactable interactable, Interaction interaction, bool doAction = true)
        {
            DelayedActionInstance delayedActionInstance = new DelayedActionInstance {
                Duration      = 0f,
                ActionMessage = interactable.ContextualName
            };
            InteractableType action = interactable.Action;

            if (interaction.SourceSlot.Occupant is Screwdriver)
            {
                if (action == InteractableType.Button1)
                {
                    SimpleFabricatorBase nextReadable = GetNextReadable(CurrentFabricator, base.InputNetwork1DevicesSorted, interaction.AltKey);
                    if (!nextReadable)
                    {
                        return(delayedActionInstance.Fail(InterfaceStrings.LogicNoReadableDevices));
                    }
                    delayedActionInstance.StateMessage = string.Format(InterfaceStrings.ChangeSettingTo, nextReadable.ToTooltip());
                    if (!KeyManager.GetButton(KeyMap.QuantityModifier))
                    {
                        delayedActionInstance.ExtendedMessage = InterfaceStrings.HoldForPreviousObject;
                    }
                    if (!doAction)
                    {
                        return(delayedActionInstance.Succeed());
                    }
                    if (GameManager.IsServer)
                    {
                        NetworkServer.SendByChannelToAll(1077, new SetHashGenMessage {
                            FabricatorId  = nextReadable.netId,
                            LogicReaderId = base.netId
                        }, 0);
                        CurrentFabricator = nextReadable;
                        Setting           = 0.0;
                    }
                    return(delayedActionInstance.Succeed());
                }
            }
            else
            {
                if (action == InteractableType.Button1)
                {
                    if (!doAction)
                    {
                        return(delayedActionInstance.Succeed());
                    }
                    foreach (int key in InputPrefabs.PrefabReferences.Keys)
                    {
                        InputPrefabs.PrefabReferences[key].SetVisible(false);
                    }
                    if (InventoryManager.ParentHuman.IsLocalPlayer)
                    {
                        if (CurrentFabricator != null && CurrentFabricator)
                        {
                            if (InputPrefabs.ShowInputPanel("Recipe Hash Selector", null, CurrentFabricator.DynamicThings, CurrentFabricator.CurrentBuildState.ManufactureDat.MachinesTier))
                            {
                                InputPrefabs.OnSubmit += InputFinished;
                                StartCoroutine(WaitForDropdown());
                            }
                        }
                        else
                        {
                            if (InputPrefabs.ShowInputPanel("Recipe Hash Selector", null, GetDynamicThings(), MachineTier.Max))
                            {
                                InputPrefabs.OnSubmit += InputFinished;
                                StartCoroutine(WaitForDropdown());
                            }
                        }
                    }
                    return(delayedActionInstance.Succeed());
                }
            }
            return(base.InteractWith(interactable, interaction, doAction));
        }
 public override DelayedActionInstance InteractWith(Interactable interactable, Interaction interaction, bool doAction = true)
 {
     if (interactable.Action == InteractableType.Activate || interactable.Action == InteractableType.Button1 || interactable.Action == InteractableType.Button2)
     {
         DelayedActionInstance delayedActionInstance = new DelayedActionInstance {
             Duration      = 0f,
             ActionMessage = interactable.ContextualName
         };
         bool isLocked = IsLocked;
         if (isLocked)
         {
             return(delayedActionInstance.Fail(HelpTextDevice.DeviceLocked));
         }
         if (!IsAuthorized(interaction.SourceThing))
         {
             return(delayedActionInstance.Fail(Localization.ParseTooltip("Unable to interact as you do not have the required {SLOT:AccessCard}", false)));
         }
         if (!OnOff)
         {
             return(delayedActionInstance.Fail(HelpTextDevice.DeviceNotOn));
         }
         if (!Powered)
         {
             return(delayedActionInstance.Fail(HelpTextDevice.DeviceNoPower));
         }
         if (Exporting != 0)
         {
             return(delayedActionInstance.Fail(HelpTextDevice.DeviceLocked));
         }
         if (interactable.Action == InteractableType.Activate)
         {
             if (!CurrentSlot.Occupant || !HasSomething)
             {
                 return(delayedActionInstance.Fail("Nothing selected to dispense"));
             }
             if (!doAction)
             {
                 return(delayedActionInstance.Succeed());
             }
             bool isServer = GameManager.IsServer;
             if (isServer)
             {
                 OnServer.MoveToSlot(CurrentSlot.Occupant, ExportSlot);
                 OnServer.Interact(InteractExport, 1, false);
             }
             return(delayedActionInstance.Succeed());
         }
         else
         {
             if ((interactable.Action == InteractableType.Button1 || interactable.Action == InteractableType.Button2) && KeyManager.GetButton(KeyMap.QuantityModifier))
             {
                 if (!HasSomething)
                 {
                     delayedActionInstance.ActionMessage = "Access Inventory List";
                     return(delayedActionInstance.Fail("Nothing inside to list"));
                 }
                 if (!doAction)
                 {
                     return(delayedActionInstance.Succeed());
                 }
                 foreach (int key in InputPrefabs.PrefabReferences.Keys)
                 {
                     InputPrefabs.PrefabReferences[key].SetVisible(false);
                 }
                 if (InputPrefabs.ShowInputPanel("Vending Machine", null, GetDynamicThings(), MachineTier.Max))
                 {
                     InputPrefabs.OnSubmit += InputFinished;
                 }
                 return(delayedActionInstance.Succeed());
             }
             else if (interactable.Action == InteractableType.Button1)
             {
                 if (!HasSomething)
                 {
                     delayedActionInstance.ActionMessage = ActionStrings.Down;
                     return(delayedActionInstance.Fail("Nothing inside to change too"));
                 }
                 Slot slot = SamplePlanBackward();
                 delayedActionInstance.StateMessage = string.Format(InterfaceStrings.ChangeSettingTo, slot.Occupant ? slot.Occupant.ToTooltip() : CurrentSlot.ToTooltip());
                 if (!doAction)
                 {
                     return(delayedActionInstance.Succeed());
                 }
                 bool isServer2 = GameManager.IsServer;
                 if (isServer2)
                 {
                     PlanBackward();
                 }
                 return(delayedActionInstance.Succeed());
             }
             else if (interactable.Action == InteractableType.Button2)
             {
                 if (!HasSomething)
                 {
                     delayedActionInstance.ActionMessage = ActionStrings.Up;
                     return(delayedActionInstance.Fail("Nothing inside to change too"));
                 }
                 Slot slot2 = SamplePlanForward();
                 delayedActionInstance.StateMessage = string.Format(InterfaceStrings.ChangeSettingTo, slot2.Occupant ? slot2.Occupant.ToTooltip() : CurrentSlot.ToTooltip());
                 if (!doAction)
                 {
                     return(delayedActionInstance.Succeed());
                 }
                 bool isServer3 = GameManager.IsServer;
                 if (isServer3)
                 {
                     PlanForward();
                 }
                 return(delayedActionInstance.Succeed());
             }
         }
     }
     return(base.InteractWith(interactable, interaction, doAction));
 }