Пример #1
0
 protected override void Update()
 {
     this.ToggleIcons(false);
     if (TheForest.Utils.Input.GetButtonAfterDelay("Take", 0.5f, false))
     {
         if (this.CanGather)
         {
             LocalPlayer.Inventory.GatherWater(true);
             LocalPlayer.Sfx.PlayTwinkle();
         }
         else if ((double)this._fullness > 0.01)
         {
             LocalPlayer.Sfx.PlayWhoosh();
             if (this._meats > 0)
             {
             }
             int calories = this._meats * 600 + this._mushrooms * 10 + this._herbs * 5;
             StewCombo.SetIngredients(this._meats, this._mushrooms, this._herbs, this._hydration > 0.01f);
             LocalPlayer.Stats.AteCustom(this._fullness * StewCombo.FullnessRatio, this._health * StewCombo.HealthRatio, this._energy * StewCombo.EnergyRatio, this._isFresh > 0f, this._meats > 0, this.IsLimb, calories);
             if (this._remainsYield > 0)
             {
                 LocalPlayer.Inventory.AddItem(this._remainsItemId, this._remainsYield, true, false, null);
             }
             if (this._hydration > 0.01f)
             {
                 LocalPlayer.Sfx.PlayDrink();
                 LocalPlayer.Stats.Thirst = Mathf.Clamp01(LocalPlayer.Stats.Thirst - this._hydration);
             }
         }
         else if (this._hydration > 0.01f)
         {
             LocalPlayer.Sfx.PlayDrink();
             LocalPlayer.Stats.Thirst = Mathf.Clamp01(LocalPlayer.Stats.Thirst - this._hydration);
         }
         if (BoltNetwork.isRunning && base.entity && base.entity.isAttached)
         {
             if (base.entity.isOwner)
             {
                 BoltNetwork.Destroy(base.entity);
             }
             else
             {
                 RequestDestroy requestDestroy = RequestDestroy.Create(GlobalTargets.Everyone);
                 requestDestroy.Entity = base.entity;
                 requestDestroy.Send();
             }
         }
         else
         {
             UnityEngine.Object.Destroy(base.transform.parent.gameObject);
         }
     }
 }
Пример #2
0
    private void Update()
    {
        if (TheForest.Utils.Input.GetButtonAfterDelay("Take", 0.5f))
        {
            LocalPlayer.Sfx.PlayWhoosh();
            if (!this.IsWater)
            {
                if (!this.Burnt)
                {
                    Cook componentInParent = base.GetComponentInParent <Cook>();
                    switch ((!componentInParent) ? DecayingInventoryItemView.DecayStates.Fresh : componentInParent._decayState)
                    {
                    case DecayingInventoryItemView.DecayStates.None:
                    case DecayingInventoryItemView.DecayStates.Fresh:
                        LocalPlayer.Stats.AteFreshMeat(this.IsLimb, this.Size);
                        break;

                    case DecayingInventoryItemView.DecayStates.Edible:
                        LocalPlayer.Stats.AteEdibleMeat(this.IsLimb, this.Size);
                        break;

                    case DecayingInventoryItemView.DecayStates.Spoilt:
                        LocalPlayer.Stats.AteSpoiltMeat(this.IsLimb, this.Size);
                        break;
                    }
                }
                else
                {
                    LocalPlayer.Stats.AteBurnt(this.IsLimb, this.Size);
                }
                if (this._remainsYield > 0)
                {
                    LocalPlayer.Inventory.AddItem(this._remainsItemId, this._remainsYield, false, false, (WeaponStatUpgrade.Types)(-2));
                }
            }
            else
            {
                LocalPlayer.Sfx.PlayDrink();
                LocalPlayer.Stats.Thirst = 0f;
            }
            if (BoltNetwork.isRunning && this.entity && this.entity.isAttached)
            {
                RequestDestroy requestDestroy = RequestDestroy.Create(GlobalTargets.Everyone);
                requestDestroy.Entity = this.entity;
                requestDestroy.Send();
            }
            else
            {
                UnityEngine.Object.Destroy(base.transform.parent.gameObject);
            }
        }
    }
Пример #3
0
    public IEnumerator DelayedCollapse()
    {
        base.enabled = false;
        base.GetComponent <Collider>().enabled = false;
        yield return(YieldPresets.WaitTwoSeconds);

        int childCount = base.transform.parent.childCount;

        for (int i = childCount - 1; i >= 0; i--)
        {
            if (base.transform.parent.GetChild(i) != base.transform)
            {
                UnityEngine.Object.Destroy(base.transform.parent.GetChild(i).gameObject);
            }
        }
        LocalPlayer.Sfx.PlayStructureFall(base.gameObject, 0.01f);
        UnityEngine.Object.Instantiate <GameObject>(Prefabs.Instance.DestroyedLeafShelter, base.transform.position, base.transform.rotation);
        yield return(YieldPresets.WaitOneSecond);

        if (this && base.transform)
        {
            if (!BoltNetwork.isClient)
            {
                if (!BoltNetwork.isRunning)
                {
                    UnityEngine.Object.Destroy(base.transform.parent.gameObject);
                }
                else
                {
                    BoltNetwork.Destroy(base.transform.parent.gameObject);
                }
            }
            else
            {
                RequestDestroy requestDestroy = RequestDestroy.Create(GlobalTargets.OnlyServer);
                requestDestroy.Entity = base.transform.parent.GetComponent <BoltEntity>();
                requestDestroy.Send();
            }
        }
        yield break;
    }
Пример #4
0
    protected virtual void Update()
    {
        if (this.ShowIconsPastPress && !this.MyPickUp.activeSelf && TheForest.Utils.Input.IsPastButtonPress("Take"))
        {
            this.ToggleIcons(false);
            if (this.DisablePastPress)
            {
                this.DisablePastPress.GrabExit();
            }
        }
        if (TheForest.Utils.Input.GetButtonAfterDelay("Take", 0.5f, false))
        {
            LocalPlayer.Sfx.PlayWhoosh();
            if (!this.IsWater)
            {
                Cook componentInParent = base.GetComponentInParent <Cook>();
                int  num = (int)(600f * this.Size);
                if (componentInParent)
                {
                    Item item = ItemDatabase.ItemById(componentInParent._itemId);
                    if (item != null)
                    {
                        if (item._usedStatEffect.Any((StatEffect use) => use._type == StatEffect.Types.EatenCalories))
                        {
                            num = (int)item._usedStatEffect.First((StatEffect use) => use._type == StatEffect.Types.EatenCalories)._amount;
                        }
                    }
                }
                if (!this.Burnt)
                {
                    LocalPlayer.SpecialActions.SendMessage("eatMeatRoutine", false, SendMessageOptions.DontRequireReceiver);
                    switch ((!componentInParent) ? DecayingInventoryItemView.DecayStates.Fresh : componentInParent._decayState)
                    {
                    case DecayingInventoryItemView.DecayStates.None:
                    case DecayingInventoryItemView.DecayStates.Fresh:
                    case DecayingInventoryItemView.DecayStates.DriedFresh:
                        LocalPlayer.Stats.AteFreshMeat(this.IsLimb, this.Size, num);
                        break;

                    case DecayingInventoryItemView.DecayStates.Edible:
                    case DecayingInventoryItemView.DecayStates.DriedEdible:
                        LocalPlayer.Stats.AteEdibleMeat(this.IsLimb, this.Size, num);
                        break;

                    case DecayingInventoryItemView.DecayStates.Spoilt:
                    case DecayingInventoryItemView.DecayStates.DriedSpoilt:
                        LocalPlayer.Stats.AteSpoiltMeat(this.IsLimb, this.Size, num);
                        break;
                    }
                    if (this.Dried)
                    {
                        LocalPlayer.Stats.Thirst += 0.05f * GameSettings.Survival.DriedMeatThirstRatio;
                    }
                }
                else
                {
                    LocalPlayer.SpecialActions.SendMessage("eatMeatRoutine", true, SendMessageOptions.DontRequireReceiver);
                    LocalPlayer.Stats.AteBurnt(this.IsLimb, this.Size, num / 2);
                    LocalPlayer.Stats.Thirst += 0.1f * GameSettings.Survival.DriedMeatThirstRatio;
                }
                if (this._remainsYield > 0)
                {
                    LocalPlayer.Inventory.AddItem(this._remainsItemId, this._remainsYield, true, false, null);
                }
            }
            else
            {
                LocalPlayer.Sfx.PlayDrink();
                LocalPlayer.Stats.Thirst = 0f;
            }
            if (BoltNetwork.isRunning && base.entity && base.entity.isAttached)
            {
                if (base.entity.isOwner)
                {
                    BoltNetwork.Destroy(base.entity);
                }
                else
                {
                    RequestDestroy requestDestroy = RequestDestroy.Create(GlobalTargets.Everyone);
                    requestDestroy.Entity = base.entity;
                    requestDestroy.Send();
                }
            }
            else
            {
                UnityEngine.Object.Destroy(base.transform.parent.gameObject);
            }
        }
    }