protected override void AddIngredient(int ingredientNum)
        {
            if (CheatMenuPlusCtrl.Options.Player.InstantBuild)
            {
                BuildIngredients ingredients = _requiredIngredients[ingredientNum];
                if (BoltNetwork.isRunning)
                {
                    AddIngredient ingredient = new AddIngredient();
                    typeof(Bolt.Event).GetField("Targets", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(ingredient, (byte)Bolt.GlobalTargets.OnlyServer);
                    typeof(Bolt.Event).GetField("TargetConnection", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(ingredient, null);
                    typeof(Bolt.Event).GetField("Reliability", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(ingredient, Bolt.ReliabilityModes.ReliableOrdered);

                    ingredient.IngredientNum = ingredientNum;
                    ingredient.Construction  = base.GetComponentInParent <BoltEntity>();
                    ingredient.Send();
                }
                else
                {
                    base.AddIngrendient_Actual(ingredientNum, true);
                }
            }
            else
            {
                base.AddIngredient(ingredientNum);
            }
        }
Esempio n. 2
0
        private void MakeComplete(Craft_Structure structure)
        {
            try
            {
                if (structure._requiredIngredients.Count <= 0)
                {
                    return;
                }

                for (int i = 0; i < structure._requiredIngredients.Count; ++i)
                {
                    Craft_Structure.BuildIngredients buildIngredients = structure._requiredIngredients[i];
                    if (structure.GetPresentIngredients().Length <= i)
                    {
                        continue;
                    }

                    ReceipeIngredient receipeIngredient = structure.GetPresentIngredients()[i];
                    if (receipeIngredient._amount >= buildIngredients._amount)
                    {
                        continue;
                    }

                    for (int j = 0; j < buildIngredients._amount - receipeIngredient._amount; j++)
                    {
                        if (BoltNetwork.isRunning)
                        {
                            AddIngredient ingredient = AddIngredient.Create(GlobalTargets.OnlyServer);
                            ingredient.IngredientNum = i;
                            ingredient.ItemId        = buildIngredients._itemID;
                            ingredient.Construction  = structure.entity;
                            ingredient.Send();
                        }
                        else
                        {
                            structure.AddIngrendient_Actual(i, true);
                        }

                        SleepFor(0.300f);
                    }

                    SleepFor(0.300f);
                }
            }
            catch
            { }
        }
Esempio n. 3
0
 protected override void AddIngredient(int ingredientNum)
 {
     if (!CheatMenuComponent.InstantBuild)
     {
         base.AddIngredient(ingredientNum);
         return;
     }
     Craft_Structure.BuildIngredients buildIngredients = this._requiredIngredients[ingredientNum];
     LocalPlayer.Sfx.PlayHammer();
     if (BoltNetwork.isRunning)
     {
         AddIngredient addIngredient = global::AddIngredient.Create(GlobalTargets.OnlyServer);
         addIngredient.IngredientNum = ingredientNum;
         addIngredient.ItemId        = buildIngredients._itemID;
         addIngredient.Construction  = base.GetComponentInParent <BoltEntity>();
         addIngredient.Send();
         return;
     }
     base.AddIngrendient_Actual(ingredientNum, true, null);
 }
Esempio n. 4
0
 private void AddIngredient(int ingredientNum)
 {
     Craft_Structure.BuildIngredients buildIngredients = this._requiredIngredients[ingredientNum];
     if (LocalPlayer.Inventory.RemoveItem(buildIngredients._itemID, 1, false) || Cheats.Creative)
     {
         LocalPlayer.Sfx.PlayHammer();
         Scene.HudGui.AddIcon.SetActive(false);
         if (BoltNetwork.isRunning)
         {
             AddIngredient addIngredient = global::AddIngredient.Raise(GlobalTargets.OnlyServer);
             addIngredient.IngredientNum = ingredientNum;
             addIngredient.Construction  = base.GetComponentInParent <BoltEntity>();
             addIngredient.Send();
         }
         else
         {
             this.AddIngrendient_Actual(ingredientNum, true);
         }
     }
 }
Esempio n. 5
0
 private void AddIngredient(int ingredientNum)
 {
     Craft_Structure.BuildIngredients buildIngredients = this._requiredIngredients[ingredientNum];
     if (LocalPlayer.Inventory.RemoveItem(buildIngredients._itemID, 1, false, true) || Cheats.Creative)
     {
         LocalPlayer.Sfx.PlayHammer();
         if (!Cheats.Creative || Time.frameCount % 3 == 0)
         {
             Scene.HudGui.AddBuildingIngredientIcon.SetActive(false);
         }
         if (BoltNetwork.isRunning)
         {
             if (BoltNetwork.isClient)
             {
                 bool flag = true;
                 for (int i = 0; i < this._requiredIngredients.Count; i++)
                 {
                     if (this._presentIngredients[i]._amount < this._requiredIngredients[i]._amount && (i != ingredientNum || this._presentIngredients[i]._amount + 1 < this._requiredIngredients[i]._amount))
                     {
                         flag = false;
                         break;
                     }
                 }
                 if (flag)
                 {
                     this.Build();
                 }
             }
             AddIngredient addIngredient = global::AddIngredient.Create(GlobalTargets.OnlyServer);
             addIngredient.IngredientNum = ingredientNum;
             addIngredient.ItemId        = buildIngredients._itemID;
             addIngredient.Construction  = base.GetComponentInParent <BoltEntity>();
             addIngredient.Send();
         }
         else
         {
             this.AddIngrendient_Actual(ingredientNum, true, null);
         }
     }
 }
Esempio n. 6
0
 public static void InstantBuilder(Craft_Structure structure)
 {
     try
     {
         if (structure._requiredIngredients.Count > 0)
         {
             for (int i = 0; i < structure._requiredIngredients.Count; i++)
             {
                 Craft_Structure.BuildIngredients buildIngredients = structure._requiredIngredients[i];
                 if (structure.GetPresentIngredients().Length > i)
                 {
                     ReceipeIngredient receipeIngredient = structure.GetPresentIngredients()[i];
                     if (receipeIngredient._amount < buildIngredients._amount)
                     {
                         for (int j = 0; j < buildIngredients._amount - receipeIngredient._amount; j++)
                         {
                             if (BoltNetwork.isRunning)
                             {
                                 AddIngredient ingredient = AddIngredient.Create(GlobalTargets.OnlyServer);
                                 ingredient.IngredientNum = i;
                                 ingredient.ItemId        = buildIngredients._itemID;
                                 ingredient.Construction  = structure.entity;
                                 ingredient.Send();
                             }
                             else
                             {
                                 structure.AddIngrendient_Actual(i, true, null);
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (System.Exception)
     {
     }
 }