예제 #1
0
        public void ServerPerformInteraction(AiActivate interaction)
        {
            if (isLocked)
            {
                Chat.AddExamineMsgFromServer(interaction.Performer, "The emitter has been locked");
                return;
            }

            if (isOn)
            {
                Chat.AddExamineMsgFromServer(interaction.Performer, "You turn the emitter off");

                TogglePower(false);
            }
            else if (isWelded)
            {
                Chat.AddExamineMsgFromServer(interaction.Performer, "You turn the emitter on");

                TogglePower(true);
            }
            else
            {
                Chat.AddExamineMsgFromServer(interaction.Performer, "The emitter has not been set up");
            }
        }
예제 #2
0
        public bool WillInteract(AiActivate interaction, NetworkSide side)
        {
            if (interaction.ClickType != AiActivate.ClickTypes.NormalClick)
            {
                return(false);
            }

            if (DefaultWillInteract.AiActivate(interaction, side) == false)
            {
                return(false);
            }

            if (isInCoolDown)
            {
                return(false);
            }

            //Trigger client cooldown only, or else it will break for local host
            if (CustomNetworkManager.IsServer == false)
            {
                StartCoroutine(SwitchCoolDown());
            }

            return(true);
        }
예제 #3
0
        public void ServerPerformInteraction(AiActivate interaction)
        {
            switch (interaction.ClickType)
            {
            //StopTimer
            case AiActivate.ClickTypes.CtrlClick:
                currentTimerSeconds = 0;
                break;

            //AddTime
            case AiActivate.ClickTypes.NormalClick:
                if (!countingDown)
                {
                    StartCoroutine(TickTimer());
                }
                currentTimerSeconds += 60;
                break;

            //RemoveTime
            case AiActivate.ClickTypes.ShiftClick:
                currentTimerSeconds -= 60;
                if (currentTimerSeconds < 0)
                {
                    currentTimerSeconds = 0;
                }
                break;

            default:
                break;
            }
        }
예제 #4
0
 public bool WillInteract(AiActivate interaction, NetworkSide side)
 {
     if (DefaultWillInteract.AiActivate(interaction, side) == false)
     {
         return(false);
     }
     return(true);
 }
예제 #5
0
        //Ai interaction
        public override void AiInteraction(AiActivate interaction)
        {
            if (interaction.ClickType == AiActivate.ClickTypes.AltClick)
            {
                operatingMode = operatingMode.Next();
            }
            else
            {
                isTurnedOn = !isTurnedOn;
            }

            UpdateState();
        }
예제 #6
0
        public bool WillInteract(AiActivate interaction, NetworkSide side)
        {
            if (interaction.ClickType != AiActivate.ClickTypes.NormalClick)
            {
                return(false);
            }

            if (DefaultWillInteract.AiActivate(interaction, side) == false)
            {
                return(false);
            }

            return(true);
        }
예제 #7
0
        public override void AiInteraction(AiActivate interaction)
        {
            if (interaction.ClickType == AiActivate.ClickTypes.NormalClick)
            {
                TabUpdateMessage.Send(interaction.Performer, gameObject, NetTabType.ThermoMachine, TabAction.Open);
                return;
            }

            if (interaction.ClickType == AiActivate.ClickTypes.AltClick)
            {
                targetTemperature = type == HeaterFreezerType.Heater ? maxTemperature : minTemperature;
                UpdateGui();
            }
        }
예제 #8
0
        private void CheckForInteractions(AiActivate.ClickTypes clickType)
        {
            var handApplyTargets = MouseUtils.GetOrderedObjectsUnderMouse();

            //go through the stack of objects and call AiActivate interaction components we find
            foreach (GameObject applyTarget in handApplyTargets)
            {
                var behaviours = applyTarget.GetComponents <IBaseInteractable <AiActivate> >()
                                 .Where(mb => mb != null && (mb as MonoBehaviour).enabled);

                var aiActivate = new AiActivate(gameObject, null, applyTarget, Intent.Help, clickType);
                InteractionUtils.ClientCheckAndTrigger(behaviours, aiActivate);
            }
        }
예제 #9
0
 public void ServerPerformInteraction(AiActivate interaction)
 {
     if (interaction.ClickType == AiActivate.ClickTypes.CtrlClick)
     {
         ResetTimer();
     }
     else if (interaction.ClickType == AiActivate.ClickTypes.NormalClick)
     {
         AddTime(60);
     }
     else if (interaction.ClickType == AiActivate.ClickTypes.ShiftClick)
     {
         RemoveTime(60);
     }
 }
예제 #10
0
        //Ai interaction
        public bool WillInteract(AiActivate interaction, NetworkSide side)
        {
            //Only alt and normal are used so dont need to check others, change if needed in the future
            if (interaction.ClickType != AiActivate.ClickTypes.NormalClick &&
                interaction.ClickType != AiActivate.ClickTypes.AltClick)
            {
                return(false);
            }

            if (DefaultWillInteract.AiActivate(interaction, side) == false)
            {
                return(false);
            }

            return(true);
        }
예제 #11
0
        public void ServerPerformInteraction(AiActivate interaction)
        {
            foreach (var validateNetTab in GetComponents <ICanOpenNetTab>())
            {
                if (validateNetTab.CanOpenNetTab(interaction.Performer, NetTabType))
                {
                    continue;
                }

                //If false block net tab opening
                return;
            }

            playerInteracted = interaction.Performer;
            TabUpdateMessage.Send(interaction.Performer, gameObject, NetTabType, TabAction.Open);
        }
예제 #12
0
 public void ServerPerformInteraction(AiActivate interaction)
 {
     //Start server cooldown
     StartCoroutine(SwitchCoolDown());
     TryInteraction();
 }
예제 #13
0
 public void ServerPerformInteraction(AiActivate interaction)
 {
     InternalToggleState();
 }
예제 #14
0
 public void ServerPerformInteraction(AiActivate interaction)
 {
     isOn = !isOn;
     UpdateServerState();
 }
예제 #15
0
 //Ai interaction
 public override void AiInteraction(AiActivate interaction)
 {
     TabUpdateMessage.Send(interaction.Performer, gameObject, NetTabType.Mixer, TabAction.Open);
 }
예제 #16
0
 public void ServerPerformInteraction(AiActivate interaction)
 {
     RunDoorController();
     RpcPlayButtonAnim(true);
 }
예제 #17
0
        public override void Process(NetMessage msg)
        {
            var ComponentType    = msg.ComponentType;
            var InteractionType  = msg.InteractionType;
            var ProcessorObject  = msg.ProcessorObject;
            var Intent           = msg.Intent;
            var TargetObject     = msg.TargetObject;
            var UsedObject       = msg.UsedObject;
            var TargetBodyPart   = msg.TargetBodyPart;
            var TargetVector     = msg.TargetVector;
            var MouseButtonState = msg.MouseButtonState;
            var IsAltUsed        = msg.IsAltUsed;
            var Storage          = msg.Storage;
            var SlotIndex        = msg.SlotIndex;
            var NamedSlot        = msg.NamedSlot;
            var connectionPointA = msg.connectionPointA;
            var connectionPointB = msg.connectionPointB;
            var RequestedOption  = msg.RequestedOption;

            var performer = SentByPlayer.GameObject;

            if (SentByPlayer == null || SentByPlayer.Script == null)
            {
                return;
            }

            if (SentByPlayer.Script.DynamicItemStorage == null)
            {
                if (InteractionType == typeof(AiActivate))
                {
                    LoadMultipleObjects(new uint[] { TargetObject, ProcessorObject });
                    var targetObj    = NetworkObjects[0];
                    var processorObj = NetworkObjects[1];

                    var interaction = new AiActivate(performer, null, targetObj, Intent, msg.ClickTypes);
                    ProcessInteraction(interaction, processorObj, ComponentType);
                }

                return;
            }

            if (InteractionType == typeof(PositionalHandApply))
            {
                //look up item in active hand slot
                var clientStorage = SentByPlayer.Script.DynamicItemStorage;
                var usedSlot      = clientStorage.GetActiveHandSlot();
                var usedObject    = clientStorage.GetActiveHandSlot().ItemObject;
                LoadMultipleObjects(new uint[] {
                    TargetObject, ProcessorObject
                });
                var targetObj    = NetworkObjects[0];
                var processorObj = NetworkObjects[1];
                CheckMatrixSync(ref targetObj);
                CheckMatrixSync(ref processorObj);

                var interaction = PositionalHandApply.ByClient(performer, usedObject, targetObj, TargetVector, usedSlot, Intent, TargetBodyPart);
                ProcessInteraction(interaction, processorObj, ComponentType);
            }
            else if (InteractionType == typeof(HandApply))
            {
                var clientStorage = SentByPlayer.Script.DynamicItemStorage;
                var usedSlot      = clientStorage.GetActiveHandSlot();
                var usedObject    = clientStorage.GetActiveHandSlot()?.ItemObject;
                LoadMultipleObjects(new uint[] {
                    TargetObject, ProcessorObject
                });
                var targetObj    = NetworkObjects[0];
                var processorObj = NetworkObjects[1];
                CheckMatrixSync(ref targetObj);
                CheckMatrixSync(ref processorObj);

                var interaction = HandApply.ByClient(performer, usedObject, targetObj, TargetBodyPart, usedSlot, Intent, IsAltUsed);
                ProcessInteraction(interaction, processorObj, ComponentType);
            }
            else if (InteractionType == typeof(AimApply))
            {
                var clientStorage = SentByPlayer.Script.DynamicItemStorage;
                var usedSlot      = clientStorage.GetActiveHandSlot();
                var usedObject    = clientStorage.GetActiveHandSlot().ItemObject;
                LoadNetworkObject(ProcessorObject);
                var processorObj = NetworkObject;
                CheckMatrixSync(ref processorObj);

                var interaction = AimApply.ByClient(performer, TargetVector, usedObject, usedSlot, MouseButtonState, Intent);
                ProcessInteraction(interaction, processorObj, ComponentType);
            }
            else if (InteractionType == typeof(MouseDrop))
            {
                LoadMultipleObjects(new uint[] { UsedObject,
                                                 TargetObject, ProcessorObject });

                var usedObj      = NetworkObjects[0];
                var targetObj    = NetworkObjects[1];
                var processorObj = NetworkObjects[2];
                CheckMatrixSync(ref targetObj);
                CheckMatrixSync(ref processorObj);

                var interaction = MouseDrop.ByClient(performer, usedObj, targetObj, Intent);
                ProcessInteraction(interaction, processorObj, ComponentType);
            }
            else if (InteractionType == typeof(HandActivate))
            {
                LoadNetworkObject(ProcessorObject);

                var processorObj = NetworkObject;
                CheckMatrixSync(ref processorObj);

                var performerObj = SentByPlayer.GameObject;
                //look up item in active hand slot
                var clientStorage = SentByPlayer.Script.DynamicItemStorage;
                var usedSlot      = clientStorage.GetActiveHandSlot();
                var usedObject    = clientStorage.GetActiveHandSlot().ItemObject;
                var interaction   = HandActivate.ByClient(performer, usedObject, usedSlot, Intent);
                ProcessInteraction(interaction, processorObj, ComponentType);
            }
            else if (InteractionType == typeof(InventoryApply))
            {
                LoadMultipleObjects(new uint[] { ProcessorObject, UsedObject,
                                                 Storage });
                var processorObj = NetworkObjects[0];
                var usedObj      = NetworkObjects[1];
                var storageObj   = NetworkObjects[2];
                CheckMatrixSync(ref processorObj);

                ItemSlot targetSlot = null;
                if (SlotIndex == -1)
                {
                    targetSlot = ItemSlot.GetNamed(storageObj.GetComponents <ItemStorage>()[msg.StorageIndexOnGameObject], NamedSlot);
                }
                else
                {
                    targetSlot = ItemSlot.GetIndexed(storageObj.GetComponents <ItemStorage>()[msg.StorageIndexOnGameObject], SlotIndex);
                }

                //if used object is null, then empty hand was used
                ItemSlot fromSlot = null;
                if (usedObj == null)
                {
                    fromSlot = SentByPlayer.Script.DynamicItemStorage.GetActiveHandSlot();
                }
                else
                {
                    fromSlot = usedObj.GetComponent <Pickupable>().ItemSlot;
                }
                var interaction = InventoryApply.ByClient(performer, targetSlot, fromSlot, Intent, IsAltUsed);
                ProcessInteraction(interaction, processorObj, ComponentType);
            }
            else if (InteractionType == typeof(TileApply))
            {
                var clientStorage = SentByPlayer.Script.DynamicItemStorage;
                var usedSlot      = clientStorage.GetActiveHandSlot();
                var usedObject    = clientStorage.GetActiveHandSlot().ItemObject;
                LoadNetworkObject(ProcessorObject);
                var processorObj = NetworkObject;
                CheckMatrixSync(ref processorObj);

                processorObj.GetComponent <InteractableTiles>().ServerProcessInteraction(SentByPlayer.GameObject,
                                                                                         TargetVector, processorObj, usedSlot, usedObject, Intent,
                                                                                         TileApply.ApplyType.HandApply);
            }
            else if (InteractionType == typeof(TileMouseDrop))
            {
                LoadMultipleObjects(new uint[] { UsedObject,
                                                 ProcessorObject });

                var usedObj      = NetworkObjects[0];
                var processorObj = NetworkObjects[1];
                CheckMatrixSync(ref processorObj);

                processorObj.GetComponent <InteractableTiles>().ServerProcessInteraction(SentByPlayer.GameObject,
                                                                                         TargetVector, processorObj, null, usedObj, Intent,
                                                                                         TileApply.ApplyType.MouseDrop);
            }
            else if (InteractionType == typeof(ConnectionApply))
            {
                //look up item in active hand slot
                var clientStorage = SentByPlayer.Script.DynamicItemStorage;
                var usedSlot      = clientStorage.GetActiveHandSlot();
                var usedObject    = clientStorage.GetActiveHandSlot().ItemObject;
                LoadMultipleObjects(new uint[] {
                    TargetObject, ProcessorObject
                });
                var targetObj    = NetworkObjects[0];
                var processorObj = NetworkObjects[1];
                CheckMatrixSync(ref targetObj);
                CheckMatrixSync(ref processorObj);

                var interaction = ConnectionApply.ByClient(performer, usedObject, targetObj, connectionPointA, connectionPointB, TargetVector, usedSlot, Intent);
                ProcessInteraction(interaction, processorObj, ComponentType);
            }
            else if (InteractionType == typeof(ContextMenuApply))
            {
                LoadMultipleObjects(new uint[] { TargetObject, ProcessorObject });
                var clientStorage = SentByPlayer.Script.DynamicItemStorage;
                var usedObj       = clientStorage.GetActiveHandSlot().ItemObject;
                var targetObj     = NetworkObjects[0];
                var processorObj  = NetworkObjects[1];
                CheckMatrixSync(ref targetObj);
                CheckMatrixSync(ref processorObj);

                var interaction = ContextMenuApply.ByClient(performer, usedObj, targetObj, RequestedOption, Intent);
                ProcessInteraction(interaction, processorObj, ComponentType);
            }
        }
예제 #18
0
 /// <summary>
 /// Default WillInteract logic for AiActivate interactions
 /// </summary>
 public static bool AiActivate(AiActivate interaction, NetworkSide side, bool lineCast = true)
 {
     return(Validations.CanApply(interaction, side, lineCast));
 }
예제 #19
0
 public void ServerPerformInteraction(AiActivate interaction)
 {
     ToggleSwitch();
 }
예제 #20
0
 public void ServerPerformInteraction(AiActivate interaction)
 {
     AiInteraction(interaction);
 }
예제 #21
0
 public virtual void AiInteraction(AiActivate interaction)
 {
 }
예제 #22
0
 public void ServerPerformInteraction(AiActivate interaction)
 {
     Chat.AddExamineMsgFromServer(interaction.Performer, ReadMeter());
 }
예제 #23
0
 public void ServerPerformInteraction(AiActivate interaction)
 {
     ServerToggleOutputMode();
 }
예제 #24
0
 //Ai interaction
 public override void AiInteraction(AiActivate interaction)
 {
     ToggleState();
 }