Exemplo n.º 1
0
        static bool Prefix(CharacterMaster master, PickupIndex pickupIndex)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.GenericPickupController::SendPickupMessage(RoR2.CharacterMaster,RoR2.PickupIndex)' called on client");
                return(false);
            }

            var highStacks = Precipitation.RainServer.GetToggle("high_stacks");

            uint pickupQuantity = highStacks ? 10u : 1u;

            if (master.inventory && !highStacks)
            {
                PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
                ItemIndex itemIndex = (pickupDef != null) ? pickupDef.itemIndex : ItemIndex.None;
                if (itemIndex != ItemIndex.None)
                {
                    pickupQuantity = (uint)master.inventory.GetItemCount(itemIndex);
                }
            }

            var msg = new PickupMessage
            {
                masterGameObject = master.gameObject,
                pickupIndex      = pickupIndex,
                pickupQuantity   = pickupQuantity
            };

            NetworkServer.SendByChannelToAll(57, msg, RoR2.Networking.QosChannelIndex.chat.intVal);

            return(false);
        }
Exemplo n.º 2
0
    // Client
    public void OnPickupInteraction(NetworkMessage _networkMessage)
    {
        PickupMessage msg = _networkMessage.ReadMessage <PickupMessage>();

        PlayerManager tempPlayer = NetworkHelper.GetObjectByNetIdValue <PlayerManager>(msg.playerId, false);

        if (msg.isStarting)
        {
            if (msg.pType == 0)
            {
                // Canvas stuff
            }
            else
            {
                // Canvas stuff

                tempPlayer.OnSpeedPickup();
            }
        }
        else
        {
            if (msg.pType == 0)
            {
                // Canvas stuff
            }
            else
            {
                // Canvas stuff

                tempPlayer.ResetSpeed();
            }
        }
    }
Exemplo n.º 3
0
    // Server
    public void OnPickupInteraction(uint _playerId, Pickup.PickupType _pType, int _spawnIndex)
    {
        Debug.Log("Player " + _playerId.ToString() + " has interacted with a pickup!");
        this.hasPickup[_spawnIndex] = false;

        // Find player
        int index = 0;

        for (int i = 0; i < this.playerInfoList.Count; i++)
        {
            if (this.playerInfoList[i].playerObjectId == _playerId)
            {
                index = i;
            }
        }

        // send msg for speed - its controlled on the client side
        if (_pType == Pickup.PickupType.Damage)
        {
            this.hasDamagePowerup.Add((int)_playerId);
        }

        // Send msg
        PickupMessage msg = new PickupMessage();

        msg.playerId   = _playerId;
        msg.pType      = (int)_pType;
        msg.isStarting = true;

        NetworkServer.SendToClient(this.playerInfoList[index].connectionId, CustomMsgType.Pickup, msg);

        this.StartCoroutine(this.ResetPlayer(this.playerInfoList[index].connectionId, _playerId, (int)_pType));
    }
Exemplo n.º 4
0
    private IEnumerator ResetPlayer(int _connectionId, uint _playerId, int _pType)
    {
        yield return(new WaitForSeconds(this.pickupDuration));

        if (_pType == 0)
        {
            if (this.hasDamagePowerup.Contains((int)_playerId))
            {
                this.hasDamagePowerup.RemoveAll(item => item == (int)_playerId);
            }
        }

        // Send msg
        PickupMessage msg = new PickupMessage();

        msg.playerId   = _playerId;
        msg.pType      = _pType;
        msg.isStarting = false;

        NetworkServer.SendToClient(_connectionId, CustomMsgType.Pickup, msg);

        yield return(null);
    }