Exemplo n.º 1
0
    public override bool Interact(GameObject originator, Vector3 position, string hand)
    {
        if (!CanUse(originator, hand, position, false))
        {
            return(false);
        }
        if (!isServer)
        {
            //ask server to perform the interaction
            InteractMessage.Send(gameObject, position, hand);
            return(true);
        }

        PlayerNetworkActions pna     = originator.GetComponent <PlayerNetworkActions>();
        GameObject           handObj = pna.Inventory[hand].Item;

        if (handObj == null)
        {
            if (!pipe.objectBehaviour.isNotPushable)
            {
                return(base.Interact(originator, position, hand));
            }
        }
        else
        {
            if (handObj.GetComponent <WrenchTrigger>())
            {
                pipe.WrenchAct();
            }
        }
        return(true);
    }
Exemplo n.º 2
0
    private static void PickupRandomItem()
    {
        PickUpTrigger[] items      = FindObjectsOfType <PickUpTrigger>();
        GameObject      gameObject = items[Random.Range(1, items.Length)].gameObject;

        InteractMessage.Send(gameObject, "id");
    }
Exemplo n.º 3
0
    public override void Interact(GameObject originator, Vector3 position, string hand)
    {
        if (!isServer)
        {
            UI_ItemSlot slot = UIManager.Hands.CurrentSlot;

            // Client pre-approval
            if (slot.CanPlaceItem())
            {
                //Client informs server of interaction attempt
                InteractMessage.Send(gameObject, position, slot.eventName);
                //Client simulation
                //				var placedOk = slot.PlaceItem(gameObject.transform.position);
                //				if ( !placedOk )
                //				{
                //					Logger.Log("Client placing error");
                //				}
            }
        }
        else
        {
            //Server actions
            if (!ValidateTableInteraction(originator, position, hand))
            {
                //Rollback prediction here
                //				originator.GetComponent<PlayerNetworkActions>().RollbackPrediction(hand);
            }
        }
    }
Exemplo n.º 4
0
 public override void Interact(GameObject originator, string hand)
 {
     //todo: validate fire attempts on server
     if (Input.GetKey(KeyCode.LeftControl))
     {
         return;
     }
     //shoot gun interation if its in hand
     if (gameObject == UIManager.Hands.CurrentSlot.GameObject())
     {
         AttemptToFireWeapon();
     }
     //if the weapon is not in our hands not in hands, pick it up
     else
     {
         if (!isServer)
         {                            //Client informs server of interaction attempt
             InteractMessage.Send(gameObject, UIManager.Hands.CurrentSlot.eventName);
         }
         else
         {                            //Server actions
             if (!ValidatePickUp(originator, hand))
             {
                 //Rollback prediction
             }
         }
     }
 }
Exemplo n.º 5
0
    public override bool Interact(GameObject originator, Vector3 position, string hand)
    {
        //TODO:  Fill this in.

        if (UIManager.Hands.CurrentSlot.Item != gameObject)
        {
            return(base.Interact(originator, position, hand));
        }
        var targetWorldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        if (PlayerManager.PlayerScript.IsInReach(targetWorldPos))
        {
            if (!isServer)
            {
                InteractMessage.Send(gameObject, hand);
            }
            else
            {
                var progressFinishAction = new FinishProgressAction(
                    FinishProgressAction.Action.CleanTile,
                    targetWorldPos,
                    this
                    );

                //Start the progress bar:
                UIManager.ProgressBar.StartProgress(Vector3Int.RoundToInt(targetWorldPos),
                                                    5f, progressFinishAction, originator);
            }
        }

        return(base.Interact(originator, position, hand));
    }
 public static void Transmit(InteractMessage message)
 {
     if (OnInteract != null)
     {
         OnInteract.Invoke(message);
     }
 }
Exemplo n.º 7
0
        public override void Interact(GameObject originator, string hand)
        {
            if (originator.GetComponent <PlayerScript>().canNotInteract())
            {
                return;
            }

            if (!isServer)
            {
                var uiSlotObject = new UISlotObject(hand, gameObject);

                //PreCheck
                if (UIManager.CanPutItemToSlot(uiSlotObject))
                {
                    //Simulation
//                    UIManager.UpdateSlot(uiSlotObject);

                    //Client informs server of interaction attempt
                    InteractMessage.Send(gameObject, hand);
                }
            }
            else
            {    //Server actions
                if (ValidatePickUp(originator, hand))
                {
                    GetComponent <RegisterTile>().RemoveTile();
                }
                else
                {
                    //Rollback prediction
//                    originator.GetComponent<PlayerNetworkActions>().RollbackPrediction(hand);
                }
            }
        }
Exemplo n.º 8
0
    public override bool Interact(GameObject originator, Vector3 position, string hand)
    {
        if (UIManager.Hands.CurrentSlot.Item != gameObject)
        {
            return(base.Interact(originator, position, hand));
        }

        var targetWorldPos = Camera.main.ScreenToWorldPoint(CommonInput.mousePosition);

        if (PlayerManager.PlayerScript.IsInReach(targetWorldPos) && extinguisher.isOn)
        {
            if (!isServer)
            {
                InteractMessage.Send(gameObject, hand);
            }
            else
            {
                //Play sound and call spray
                SoundManager.PlayNetworkedAtPos("Extinguish", targetWorldPos);
                ReagentContainer cleanerContainer = GetComponent <ReagentContainer>();
                StartCoroutine(Spray.TriggerSpray(cleanerContainer, targetWorldPos, extinguish));
            }
        }

        return(base.Interact(originator, position, hand));
    }
Exemplo n.º 9
0
    public override void Interact(GameObject originator, Vector3 position, string hand)
    {
        if (!isServer)
        {
            if (!PlayerManager.LocalPlayerScript.IsInReach(spriteRenderer.transform.position, 1.2f) ||
                PlayerManager.LocalPlayerScript.playerMove.isGhost)
            {
                return;
            }

            //if the button is idle and not animating it can be pressed
            if (animator.GetCurrentAnimatorStateInfo(0).IsName("Idle"))
            {
                InteractMessage.Send(originator, hand);
            }
        }
        else
        {
            var ps = originator.GetComponent <PlayerScript>();
            if (!ps.IsInReach(spriteRenderer.transform.position, 1.2f) ||
                ps.playerMove.isGhost)
            {
                return;
            }
            for (int i = 0; i < doorControllers.Length; i++)
            {
                if (!doorControllers[i].IsOpened)
                {
                    doorControllers[i].Open();
                }
            }
            RpcPlayButtonAnim();
        }
    }
Exemplo n.º 10
0
    public override bool Interact(GameObject originator, Vector3 position, string hand)
    {
        if (!CanUse(originator, hand, position, false))
        {
            return(false);
        }
        if (!isServer)
        {
            //ask server to perform the interaction
            InteractMessage.Send(gameObject, position, hand);
            return(true);
        }

        if (!allowSell && deniedMessage != null && !GameData.Instance.testServer && !GameData.IsHeadlessServer)
        {
            UpdateChatMessage.Send(originator, ChatChannel.Examine, deniedMessage);
        }
        else if (allowSell)
        {
            allowSell = false;
            if (!GameData.Instance.testServer && !GameData.IsHeadlessServer)
            {
                UpdateChatMessage.Send(originator, ChatChannel.Examine, interactionMessage);
            }
            ServerVendorInteraction(position);
            StartCoroutine(VendorInputCoolDown());
        }

        return(true);
    }
Exemplo n.º 11
0
    public override void Interact(GameObject originator, Vector3 position, string hand)
    {
        if (!allowSell && deniedMessage != null && !GameData.Instance.testServer && !GameData.IsHeadlessServer)
        {
            UIManager.Chat.AddChatEvent(new ChatEvent(deniedMessage, ChatChannel.Examine));
        }
        // Client pre-approval
        else if (!isServer && allowSell)
        {
            allowSell = false;
            UI_ItemSlot slot = UIManager.Hands.CurrentSlot;
            UIManager.Chat.AddChatEvent(new ChatEvent(interactionMessage, ChatChannel.Examine));
            //Client informs server of interaction attempt
            InteractMessage.Send(gameObject, position, slot.eventName);
            StartCoroutine(VendorInputCoolDown());
        }
        else if (allowSell)
        {
            allowSell = false;
            if (!GameData.Instance.testServer && !GameData.IsHeadlessServer)
            {
                UIManager.Chat.AddChatEvent(new ChatEvent(interactionMessage, ChatChannel.Examine));
            }

            ServerVendorInteraction(originator, position, hand);
            StartCoroutine(VendorInputCoolDown());
        }
    }
Exemplo n.º 12
0
        public override void Interact(GameObject originator, Vector3 position, string hand)
        {
            if (originator.GetComponent <PlayerScript>().canNotInteract())
            {
                return;
            }

            if (!isServer)
            {
                UISlotObject uiSlotObject = new UISlotObject(hand, gameObject);

                //PreCheck
                if (UIManager.CanPutItemToSlot(uiSlotObject))
                {
                    //Simulation
                    //                    UIManager.UpdateSlot(uiSlotObject);

                    //Client informs server of interaction attempt
                    InteractMessage.Send(gameObject, hand);
                }
            }
            else
            {
                //Server actions
                if (ValidatePickUp(originator, hand))
                {
                    GetComponent <RegisterItem>().Unregister();
                }
            }
        }
Exemplo n.º 13
0
        public override void Interact(GameObject originator, Vector3 position, string hand)
        {
            if (originator.GetComponent <PlayerScript>().canNotInteract())
            {
                return;
            }

            if (!isServer)
            {
                UISlotObject uiSlotObject = new UISlotObject(hand, gameObject);

                //PreCheck
                if (UIManager.CanPutItemToSlot(uiSlotObject))
                {
                    //Simulation
                    gameObject.GetComponent <CustomNetTransform>().DisappearFromWorld();
                    //                    UIManager.UpdateSlot(uiSlotObject);

                    //Client informs server of interaction attempt
                    InteractMessage.Send(gameObject, hand);
                }
            }
            else
            {
                //Server actions
                if (!ValidatePickUp(originator, hand))
                {
                    //Rollback prediction (inform player about item's true state)
                    GetComponent <CustomNetTransform>().NotifyPlayer(originator);
                }
            }
        }
Exemplo n.º 14
0
    static void PickupRandomItem()
    {
        var items      = FindObjectsOfType <Items.PickUpTrigger>();
        var gameObject = items[Random.Range(1, items.Length)].gameObject;

        InteractMessage.Send(gameObject, "id");
    }
Exemplo n.º 15
0
    public override bool Interact(GameObject originator, Vector3 position, string hand)
    {
        if (!CanUse(originator, hand, position, false))
        {
            return(false);
        }
        if (!isServer)
        {
            //ask server to perform the interaction
            InteractMessage.Send(gameObject, position, hand);
            return(true);
        }

        PlayerNetworkActions pna = originator.GetComponent <PlayerNetworkActions>();

        if (IsClosed)
        {
            HandleInteraction(false, hand, pna);
        }
        else
        {
            GameObject handObj = pna.Inventory[hand].Item;
            if (isFull && !hasJustPlaced)
            {
                if (handObj == null)
                {
                    HandleInteraction(true, hand, pna);
                }
                else
                {
                    HandleInteraction(false, hand, pna);
                }
            }
            else
            {
                if (handObj != null)
                {
                    if (handObj.GetComponent <ItemAttributes>().itemName == "Extinguisher")
                    {
                        HandleInteraction(true, hand, pna);
                        hasJustPlaced = true;
                    }
                    else
                    {
                        HandleInteraction(false, hand, pna);
                        hasJustPlaced = false;
                    }
                }
                else
                {
                    HandleInteraction(false, hand, pna);
                    hasJustPlaced = false;
                }
            }
        }

        return(true);
    }
Exemplo n.º 16
0
    public override bool Interact(GameObject originator, Vector3 position, string hand)
    {
        if (!CanUse(originator, hand, position, false))
        {
            return(false);
        }
        if (!isServer)
        {
            //ask server to perform the interaction
            InteractMessage.Send(gameObject, position, hand);
            return(true);
        }

        PlayerNetworkActions pna     = originator.GetComponent <PlayerNetworkActions>();
        GameObject           handObj = pna.Inventory[hand].Item;

        if (handObj && handObj.GetComponent <WrenchTrigger>())
        {
            if (connector == null)
            {
                var foundConnectors = MatrixManager.GetAt <Connector>(registerTile.WorldPositionServer, true);
                for (int n = 0; n < foundConnectors.Count; n++)
                {
                    var conn = foundConnectors[n];
                    if (conn.objectBehaviour.isNotPushable)
                    {
                        connector = conn;
                        connector.ConnectCanister(this);
                        connectorRenderer.sprite      = connectorSprite;
                        objectBehaviour.isNotPushable = true;
                        return(true);
                    }
                }
            }
            else
            {
                connector.DisconnectCanister();
                connectorRenderer.sprite = null;
                connector = null;
                objectBehaviour.isNotPushable = false;
                return(true);
            }
        }

        //container.Opened = !container.Opened;


        base.Interact(originator, position, hand);

        /*
         * string msg = container.Opened ? $"The valve is open, outputting at {container.ReleasePressure} kPa." : "The valve is closed.";
         * UpdateChatMessage.Send(originator, ChatChannel.Examine, msg);
         */

        return(true);
    }
        public override void ClientAction()
        {
            UI_ItemSlot slot = UIManager.Hands.CurrentSlot;

            // Client pre-approval
            if (slot.CanPlaceItem())
            {
                InteractMessage.Send(gameObject, position, slot.eventName);
            }
        }
Exemplo n.º 18
0
 public override void UI_Interact(GameObject originator, string hand)
 {
     if (!isServer)
     {
         InteractMessage.Send(gameObject, hand, true);
     }
     else
     {
         StartCoroutine(TimeExplode(originator));
     }
 }
Exemplo n.º 19
0
 public override void Interact(GameObject originator, Vector3 position, string hand)
 {
     if (!isServer)
     {
         InteractMessage.Send(gameObject, hand);
     }
     else
     {
         isOn = !isOn;
         CheckState(isOn);
     }
 }
Exemplo n.º 20
0
 public override void Interact(GameObject originator, Vector3 position, string hand)
 {
     //Interact stuff with the SMES here
     if (!isServer)
     {
         InteractMessage.Send(gameObject, hand);
     }
     else
     {
         isOn = !isOn;
     }
 }
Exemplo n.º 21
0
    public override bool Interact(GameObject originator, Vector3 position, string hand)
    {
        var playerScript = originator.GetComponent <PlayerScript>();

        //do nothing if player is not in reach of the specified position
        if (!playerScript.IsInReach(position, false))
        {
            return(false);
        }

        if (PlayerManager.PlayerScript == playerScript)
        {
            //we are initiating the interaction locally

            //if the mop is not in our hand, pick it up
            if (UIManager.Hands.CurrentSlot.Item != gameObject)
            {
                return(base.Interact(originator, position, hand));
            }

            //ask the server to let us mop if it's in reach
            if (PlayerManager.PlayerScript.IsInReach(position, false))
            {
                if (!isServer)
                {
                    //ask to mop
                    InteractMessage.Send(gameObject, position.RoundToInt(), hand);
                }
                else
                {
                    //we're the server so we can just go ahead and mop
                    ServerMop(originator, position);
                }

                return(true);
            }
        }
        else if (isServer)
        {
            //server is being asked to mop on behalf of some other player.
            //if mop is not in their hand, pick it up by delegating to Pickuptrigger
            var targetSlot = InventoryManager.GetSlotFromOriginatorHand(originator, hand);
            if (targetSlot.Item == null)
            {
                return(base.Interact(originator, position, hand));
            }

            //mop is in their hand, let them mop
            ServerMop(originator, position);
        }

        return(false);
    }
Exemplo n.º 22
0
    public override bool Interact(GameObject originator, Vector3 position, string hand)
    {
        if (!CanUse(originator, hand, position, false))
        {
            return(false);
        }
        if (!isServer)
        {
            //ask server to perform the interaction
            InteractMessage.Send(gameObject, position, hand);
            return(true);
        }

        PlayerNetworkActions pna     = originator.GetComponent <PlayerNetworkActions>();
        GameObject           handObj = pna.Inventory[hand].Item;

        if (handObj == null)
        {
            return(false);
        }
        if (handObj.GetComponent <MetalTrigger>())
        {
            var progressFinishAction = new FinishProgressAction(
                reason =>
            {
                if (reason == FinishProgressAction.FinishReason.COMPLETED)
                {
                    ConstructWall(handObj);
                }
            }
                );
            UIManager.ProgressBar.StartProgress(position.RoundToInt(), 5f, progressFinishAction, originator);
        }

        if (handObj.GetComponent <WrenchTrigger>())
        {
            SoundManager.PlayAtPosition("Wrench", transform.localPosition);
            var progressFinishAction = new FinishProgressAction(
                reason =>
            {
                if (reason == FinishProgressAction.FinishReason.COMPLETED)
                {
                    Disassemble();
                }
            }
                );
            UIManager.ProgressBar.StartProgress(position.RoundToInt(), 5f, progressFinishAction, originator);
        }


        return(true);
    }
Exemplo n.º 23
0
 public override bool Interact(GameObject originator, Vector3 position, string hand)
 {
     if (!isServer)
     {
         InteractMessage.Send(gameObject, hand);
     }
     else
     {
         isOn = !isOn;
         UpdateServerState(isOn);
     }
     return(true);
 }
    public static InteractMessage Send(GameObject subject, Vector3 position, string hand)
    {
        InteractMessage msg = new InteractMessage
        {
            Subject  = subject.GetComponent <NetworkIdentity>().netId,
            Position = position,
            Hand     = encodeHand(hand)
        };

        msg.Send();
        //		InputTrigger.msgCache[msg.Subject] = Time.time;
        return(msg);
    }
Exemplo n.º 25
0
    public override bool Interact(GameObject originator, Vector3 position, string hand)
    {
        if (!CanUse(originator, hand, position, false))
        {
            return(false);
        }
        if (!isServer)
        {
            //ask server to perform the interaction
            InteractMessage.Send(gameObject, position, hand);
            return(true);
        }

        PlayerNetworkActions pna     = originator.GetComponent <PlayerNetworkActions>();
        GameObject           handObj = pna.Inventory[hand].Item;

        if (IsClosed)
        {
            if (isFull && !handObj)
            {
                RemoveExtinguisher(pna, hand);
            }
            IsClosed = false;
        }
        else
        {
            if (isFull)
            {
                if (handObj == null)
                {
                    RemoveExtinguisher(pna, hand);
                }
                else
                {
                    IsClosed = true;
                }
            }
            else
            {
                if (handObj && handObj.GetComponent <FireExtinguisher>())
                {
                    AddExtinguisher(pna, hand, handObj);
                }
                else
                {
                    IsClosed = true;
                }
            }
        }
        return(true);
    }
Exemplo n.º 26
0
 public override void Interact(GameObject originator, string hand)
 {
     if (!isServer)
     {    //Client informs server of interaction attempt
         InteractMessage.Send(gameObject, UIManager.Hands.CurrentSlot.eventName);
     }
     else
     {    //Server actions
         if (!ValidatePickUp(originator, hand))
         {
             //Rollback prediction
         }
     }
 }
Exemplo n.º 27
0
    public static InteractMessage Send(GameObject subject, string hand, bool UITrigger)
    {
        InteractMessage msg = new InteractMessage
        {
            Subject   = subject.GetComponent <NetworkIdentity>().netId,
            Position  = subject.transform.position,
            Hand      = encodeHand(hand),
            UITrigger = true
        };

        msg.Send();
        //		InputTrigger.msgCache[msg.Subject] = Time.time;
        return(msg);
    }
Exemplo n.º 28
0
    public override bool Interact(GameObject originator, Vector3 position, string hand)
    {
        var playerScript = originator.GetComponent <PlayerScript>();

        if (playerScript.canNotInteract() || !playerScript.IsInReach(gameObject, false))
        {     //check for both client and server
            return(true);
        }

        if (!isServer)
        {
            //Client wants this code to be run on server
            InteractMessage.Send(gameObject, hand);
        }
        else
        {
            //Server actions
            TabUpdateMessage.Send(originator, gameObject, NetTabType, TabAction.Open);
            if (State == TabState.None)
            {
                State = TabState.Normal;
            }
            switch (State)
            {
            case TabState.Normal:
                if (UsedEmag(originator, hand))
                {
                    //todo sparks
                    State = TabState.Emagged;
                }
                break;

            case TabState.Emagged:
                if (UsedEmag(originator, hand))
                {
                    State = TabState.Off;
                }
                break;

            case TabState.Off:
                if (UsedEmag(originator, hand))
                {
                    State = TabState.Normal;
                }
                break;
            }
        }
        return(true);
    }
Exemplo n.º 29
0
    public override bool Interact(GameObject originator, Vector3 position, string hand)
    {
        //Interact stuff with the Radiation collector here
        if (!isServer)
        {
            InteractMessage.Send(gameObject, hand);
        }
        else
        {
            isOn = !isOn;
            UpdateServerState(isOn);
        }

        return(true);
    }
Exemplo n.º 30
0
    public override void Interact(GameObject originator, string hand)
    {
        if (!isServer)
        {            //Client informs server of interaction attempt
            InteractMessage.Send(gameObject, UIManager.Hands.CurrentSlot.eventName);
        }
        else
        {               //Server actions
            if (!ValidateTableInteraction(originator, hand))
            {
                //Rollback prediction here
//				Debug.Log("Uh-oh, failed table interaction");
            }
        }
    }