示例#1
0
        public void Deserialize(NetDataReader reader)
        {
            TechBonuses      = new PlayerTechBonuses();
            Inventory        = new StorageComponent(4);
            ReactorStorage   = new StorageComponent(4);
            WarpStorage      = new StorageComponent(1);
            Forge            = new MechaForge();
            Forge.tasks      = new List <ForgeTask>();
            Forge.extraItems = new ItemPack();
            TechBonuses.Deserialize(reader);
            SandCount     = reader.GetInt();
            CoreEnergy    = reader.GetDouble();
            ReactorEnergy = reader.GetDouble();
            bool isPayloadPresent = reader.GetBool();

            if (isPayloadPresent)
            {
                int    mechaLength = reader.GetInt();
                byte[] mechaBytes  = new byte[mechaLength];
                reader.GetBytes(mechaBytes, mechaLength);
                using (MemoryStream ms = new MemoryStream(mechaBytes))
                    using (BinaryReader br = new BinaryReader(ms))
                    {
                        Inventory.Import(br);
                        ReactorStorage.Import(br);
                        WarpStorage.Import(br);
                        Forge.Import(br);
                    }
            }
        }
示例#2
0
 public MechaData()
 {
     //This is needed for the serialization and deserialization
     Forge = new MechaForge
     {
         tasks = new List <ForgeTask>()
     };
     TechBonuses = new PlayerTechBonuses();
 }
示例#3
0
 public MechaData(int sandCount, double coreEnergy, double reactorEnergy, StorageComponent inventory, StorageComponent reactorStorage, StorageComponent warpStorage, MechaForge forge)
 {
     SandCount      = sandCount;
     CoreEnergy     = coreEnergy;
     ReactorEnergy  = reactorEnergy;
     ReactorStorage = reactorStorage;
     WarpStorage    = warpStorage;
     Forge          = forge;
     Inventory      = inventory;
     TechBonuses    = new PlayerTechBonuses();
 }
示例#4
0
        public static bool Prefix(MechaForge __instance, ForgeTask __result, int recipeId, int count)
        {
            ForgeTask recipe = new ForgeTask(recipeId, count);

            for (int i = 0; i < recipe.productIds.Length; i++)
            {
                GameMain.mainPlayer.package.AddItemStacked(recipe.productIds[i], count);
            }
            __result = null;
            return(false);
        }
示例#5
0
            public static void OnOkButtonClick(UIReplicatorWindow __instance, ref RecipeProto ___selectedRecipe, ref Dictionary <int, int> ___multipliers, ref MechaForge ___mechaForge)
            {
                if (___selectedRecipe != null)
                {
                    int num = 1;

                    if (___multipliers.ContainsKey(___selectedRecipe.ID))
                    {
                        num = ___multipliers[___selectedRecipe.ID];
                    }

                    if (num < 1)
                    {
                        num = 1;
                    }

                    int num2 = ___mechaForge.PredictTaskCount(___selectedRecipe.ID, 99);
                    if (num > num2)
                    {
                        num = num2;
                    }
                    ___mechaForge.AddTask(___selectedRecipe.ID, num);
                }
            }
            public static bool OnMinusButtonClick(UIReplicatorWindow __instance, ref RecipeProto ___selectedRecipe, ref Dictionary <int, int> ___multipliers, ref Text ___multiValueText, ref MechaForge ___mechaForge)
            {
                if (___selectedRecipe == null)
                {
                    return(false);
                }

                var stepModifier = 1;

                if (Input.GetKey(KeyCode.LeftControl))
                {
                    stepModifier = 10;
                }
                if (Input.GetKey(KeyCode.LeftShift))
                {
                    stepModifier = 100;
                }
                if (Input.GetKey(KeyCode.LeftAlt))
                {
                    stepModifier = ___mechaForge.PredictTaskCount(___selectedRecipe.ID, 1000000) - 1;
                }

                if (!__instance.multipliers.ContainsKey(___selectedRecipe.ID))
                {
                    __instance.multipliers[___selectedRecipe.ID] = 1;
                }
                int num = __instance.multipliers[___selectedRecipe.ID] - 1 * stepModifier;

                if (num < 1)
                {
                    num = 1;
                }
                __instance.multipliers[___selectedRecipe.ID] = num;
                ___multiValueText.text = num.ToString() + "x";

                return(false);
            }
示例#7
0
            static bool Prefix(UIReplicatorWindow __instance, RecipeProto ___selectedRecipe, MechaForge ___mechaForge)
            {
                if (___selectedRecipe == null)
                {
                    return(false);
                }

                if (!___selectedRecipe.Handcraft)
                {
                    UIRealtimeTip.Popup("该配方".Translate() + ___selectedRecipe.madeFromString + "生产".Translate(), true, 0);
                }
                else
                {
                    int id = ___selectedRecipe.ID;
                    if (!GameMain.history.RecipeUnlocked(id))
                    {
                        UIRealtimeTip.Popup("配方未解锁".Translate(), true, 0);
                    }
                    else
                    {
                        int num = ___mechaForge.PredictTaskCount(___selectedRecipe.ID, 500);

                        var count = 1;

                        if (Input.GetKey(KeyCode.LeftControl))
                        {
                            count *= 10;
                        }
                        if (Input.GetKey(KeyCode.LeftShift))
                        {
                            count *= 100;
                        }
                        if (Input.GetKey(KeyCode.LeftAlt))
                        {
                            count *= num;
                        }

                        if (count > num)
                        {
                            count = num;
                        }
                        if (count == 0)
                        {
                            UIRealtimeTip.Popup("材料不足".Translate(), true, 0);
                        }
                        else if (___mechaForge.AddTask(id, count) == null)
                        {
                            UIRealtimeTip.Popup("材料不足".Translate(), true, 0);
                        }
                        else
                        {
                            GameMain.history.RegFeatureKey(1000104);
                        }
                    }
                }

                return(false);
            }