Пример #1
0
    /// <summary>
    /// Calls the end of the round which plays a sound and shows the round report. Server only
    /// </summary>
    public void EndRound()
    {
        if (CustomNetworkManager.Instance._isServer == false)
        {
            return;
        }

        if (CurrentRoundState != RoundState.Started)
        {
            if (CurrentRoundState == RoundState.Ended)
            {
                Logger.Log("Cannot end round, round has already ended!", Category.Round);
            }
            else
            {
                Logger.Log("Cannot end round, round has not started yet!", Category.Round);
            }

            return;
        }

        CurrentRoundState = RoundState.Ended;
        EventManager.Broadcast(Event.RoundEnded, true);
        counting = false;

        StartCoroutine(WaitForRoundRestart());
        GameMode.EndRoundReport();

        _ = SoundManager.PlayNetworked(endOfRoundSounds.GetRandomClip());
    }
Пример #2
0
        private bool TryTransferToMicrowave(PositionalHandApply interaction)
        {
            // Close the microwave if nothing is held.
            if (interaction == null || interaction.UsedObject == null)
            {
                SoundManager.PlayNetworkedAtPos(doorSFX.GetRandomClip(), WorldPosition, sourceObj: gameObject);
                return(false);
            }

            // Add held item to the microwave.
            ItemSlot storageSlot = storage.GetNextFreeIndexedSlot();
            bool     added       = false;

            if (interaction.HandSlot.ItemObject.TryGetComponent(out Stackable stack))
            {
                if (stack.Amount == 1)
                {
                    added = Inventory.ServerTransfer(interaction.HandSlot, storageSlot);
                }
                else
                {
                    var item = stack.ServerRemoveOne();
                    added = Inventory.ServerAdd(item, storageSlot);
                    if (!added)
                    {
                        stack.ServerIncrease(1);                         // adds back the lost amount to prevent microwaves from eating stackable items
                    }
                }
            }
            else
            {
                added = Inventory.ServerTransfer(interaction.HandSlot, storageSlot);
            }
            if (storageSlot == null || added == false)
            {
                Chat.AddActionMsgToChat(interaction, "The microwave's matter bins are full!", string.Empty);
                return(true);
            }

            if (storageSlot.ItemObject.TryGetComponent(out Cookable cookable) && cookable.CookableBy.HasFlag(CookSource.Microwave))
            {
                storedCookables.Add(storageSlot, cookable);
            }
Пример #3
0
    private void ValidatePlayer(GameObject player, bool isEntering)
    {
        if (player == null)
        {
            return;
        }
        if (player != PlayerManager.LocalPlayer)
        {
            return;
        }

        if (isEntering)
        {
            PlayAudio(enteringSoundTrack.GetRandomClip());
        }
        else
        {
            PlayAudio(leavingSoundTrack.GetRandomClip());
        }
    }
Пример #4
0
        private bool TryTransferToMicrowave(PositionalHandApply interaction)
        {
            // Close the microwave if nothing is held.
            if (interaction == null || interaction.UsedObject == null)
            {
                SoundManager.PlayNetworkedAtPos(doorSFX.GetRandomClip(), WorldPosition, sourceObj: gameObject);
                return(false);
            }

            // Add held item to the microwave.
            ItemSlot storageSlot = storage.GetNextFreeIndexedSlot();

            if (storageSlot == null || Inventory.ServerTransfer(interaction.HandSlot, storageSlot) == false)
            {
                Chat.AddActionMsgToChat(interaction, "The microwave's matter bins are full!", string.Empty);
                return(true);
            }

            if (storageSlot.ItemObject.TryGetComponent(out Cookable cookable) && cookable.CookableBy.HasFlag(CookSource.Microwave))
            {
                storedCookables.Add(storageSlot, cookable);
            }