private IEnumerator ConstructAsync(Constructable c, bool state)
        {
            float amount = ((!state) ? powerConsumptionDeconstruct : powerConsumptionConstruct) * Time.deltaTime;

            this.EnergyMixin.ConsumeEnergy(amount);
            bool constructed    = c.constructed;
            bool wasConstructed = c.constructed;
            bool flag;

            if (state)
            {
                flag = c.Construct();
            }
            else
            {
#if SUBNAUTICA_EXP || BZ
                TaskResult <bool> result = new TaskResult <bool>();
                yield return(c.DeconstructAsync(result));

                flag   = result.Get();
                result = null;
#elif SUBNAUTICA_STABLE
                flag = c.Deconstruct();
#endif
            }

            if (!flag && state && !wasConstructed)
            {
                Utils.PlayFMODAsset(this.completeSound, c.transform, 20f);
            }
            yield break;
        }
Exemplo n.º 2
0
 private bool Construct(Constructable c, bool state)
 {
     if (c != null && !c.constructed && this.EnergyMixin.charge > 0f)
     {
         float amount = ((!state) ? powerConsumptionDeconstruct : powerConsumptionConstruct) * Time.deltaTime;
         this.EnergyMixin.ConsumeEnergy(amount);
         bool constructed = c.constructed;
         _ = (!state) ? c.Deconstruct() : c.Construct();
         if (state && !constructed)
         {
             global::Utils.PlayFMODAsset(completeSound, c.transform, 20f);
         }
         return(true);
     }
     return(false);
 }
Exemplo n.º 3
0
 //=====================================================================
 // Construct
 //
 // Figure out whether we're starting, ending, or continuing
 // construction and plays the appropriate sounds
 //=====================================================================
 private bool Construct(Constructable c, bool state)
 {
     if (c != null && !c.constructed)
     {
         bool constructed = c.constructed;
         bool flag        = (!state) ? c.Deconstruct() : c.Construct();
         if (flag)
         {
             this.constructable = c;
         }
         else if (state && !constructed)
         {
             global::Utils.PlayFMODAsset(this.completeSound, c.transform, 20f);
         }
         return(true);
     }
     return(false);
 }
Exemplo n.º 4
0
        private bool Construct(Constructable c, bool state)
        {
            float amount = ((!state) ? this.powerConsumptionDeconstruct : this.powerConsumptionConstruct) * Time.deltaTime;

            if (c != null && !c.constructed && this.energyMixin.GetPower() > amount)
            {
                float consumed;
                this.energyMixin.ConsumeEnergy(amount, out consumed);
                bool constructed = c.constructed;
                bool flag        = (!state) ? c.Deconstruct() : c.Construct();
                if (flag)
                {
                    this.constructable = c;
                }
                else if (state && !constructed)
                {
                    global::Utils.PlayFMODAsset(this.completeSound, c.transform, 20f);
                }
                return(true);
            }
            return(false);
        }