Example #1
0
    public override int CalculateProduction(Tile tile)
    {
        List <Tile> tilesInRange   = tile.GetAllTilesAround(collectionRange);
        int         collectedFunds = baseProduction;

        foreach (var tempTile in tilesInRange)
        {
            if (tempTile.placedBuilding == null)
            {
                continue;
            }

            if (tempTile.placedBuilding is Mill)
            {
                Mill mill = tempTile.placedBuilding as Mill;
                collectedFunds += mill.bonusForBrewery;
            }

            if (tempTile.placedBuilding is Field)
            {
                Field field = tempTile.placedBuilding as Field;
                collectedFunds += field.bonusForBrewery;
            }
        }

        return(collectedFunds + baseProduction);
    }
Example #2
0
    internal override int CalculateProductionChanges(Building newNeighbour, Tile neighbourTile)
    {
        int change = 0;

        if (newNeighbour is Mill)
        {
            Mill mill = newNeighbour as Mill;
            change += mill.bonusForBrewery;
        }

        if (newNeighbour is Field)
        {
            Field field = newNeighbour as Field;
            change += field.bonusForBrewery;
        }

        if (neighbourTile.placedBuilding != null)
        {
            if (neighbourTile.placedBuilding is Mill)
            {
                Mill mill = neighbourTile.placedBuilding as Mill;
                change -= mill.bonusForBrewery;
            }

            if (neighbourTile.placedBuilding is Field)
            {
                Field field = neighbourTile.placedBuilding as Field;
                change -= field.bonusForBrewery;
            }
        }

        return(change);
    }
        public CalibrationProgram GetOrCreateCalibrationProgram(Mill mill)
        {
            CalibrationProgram calibrationProgram;


            if (CPRGEid == null)
            {
                Logger.Info("cprg eid is creating one for " + this);

                var character = GetOwnerCharacter;

                //create item to ram
                var calibrationProgramDefinition = GetCalibrationTemplateDefinition();
                calibrationProgram       = (CalibrationProgram)Entity.Factory.CreateWithRandomEID(calibrationProgramDefinition);
                calibrationProgram.Owner = character.Eid;
                mill.GetStorage().AddChild(calibrationProgram);

                // db-be kell csinalni mert a dinamikus felulirja save-nel
                calibrationProgram.Save();

                Logger.Info("cprg created " + calibrationProgram);
            }
            else
            {
                //load from sql
                calibrationProgram = (CalibrationProgram)_itemHelper.LoadItemOrThrow((long)CPRGEid);
                Logger.Info("found and cprg loaded " + calibrationProgram);
            }

            return(calibrationProgram);
        }
Example #4
0
    public List <Instruction> GetInstructions(CharacterSheet sheet)
    {
        List <Instruction> instructions = new List <Instruction>();

        Instruction getWheat = new Instruction();

        getWheat.destination = sheet.baseCity.Barns[0].gameObject.GetComponent <NavigationWaypoint>();
        getWheat.building    = sheet.baseCity.Barns[0];
        getWheat.gather      = new ItemType[] { ItemType.WHEAT };
        getWheat.give        = new ItemType[] { };
        getWheat.fun1        = new instructionFunction((getWheat.building).GetItem);

        instructions.Add(getWheat);

        Instruction makeFlour   = new Instruction();
        Mill        destination = null;

        foreach (Mill mill in sheet.baseCity.Mills)
        {
            if (mill.workers.Contains(sheet))
            {
                destination = mill;
                break;
            }
        }

        if (destination == null)
        {
            foreach (Mill mill in sheet.baseCity.Mills)
            {
                if (mill.CurrentPositions[Jobs.MILLER] > 0)
                {
                    destination = mill;
                    mill.workers.Add(sheet);
                    mill.CurrentPositions[Jobs.MILLER]--;
                    break;
                }
            }
        }
        makeFlour.destination = destination.gameObject.GetComponent <NavigationWaypoint>();
        makeFlour.building    = destination;
        makeFlour.gather      = new ItemType[] { ItemType.FLOUR };
        makeFlour.give        = new ItemType[] { ItemType.WHEAT };
        makeFlour.recipe      = MasterRecipe.Instance.Armor;
        makeFlour.fun1        = new instructionFunction((makeFlour.building).MakeRecipe);

        instructions.Add(makeFlour);

        Instruction storeFlour = new Instruction();

        storeFlour.destination = destination.gameObject.GetComponent <NavigationWaypoint>();
        storeFlour.building    = destination;
        storeFlour.gather      = new ItemType[] { };
        storeFlour.give        = new ItemType[] { ItemType.FLOUR };
        storeFlour.fun1        = new instructionFunction((storeFlour.building).StoreItem);
        storeFlour.fun2        = new instructionFunction2((destination).ReleaseJob);
        instructions.Add(storeFlour);

        return(instructions);
    }
Example #5
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="mill">The underlying mill.</param>
 public MillMachine(Mill mill)
 {
     this.Mill = mill;
     this.MaxInputStackSize = new Dictionary <int, int>
     {
         [284] = new SObject(284, 1).maximumStackSize() / 3 // beet => 3 sugar (reduce stack to avoid overfilling output)
     };
 }
Example #6
0
        /*********
        ** Internal Methods
        *********/
        /// <summary>The prefix for the <see cref="StardewValley.Buildings.Mill.doAction(Microsoft.Xna.Framework.Vector2, StardewValley.Farmer)"/> method.</summary>
        /// <param name="tileLocation">The tile on the mill the player clicked on.</param>
        /// <param name="who">The player who clicked on the mill.</param>
        /// <param name="__instance">The current <see cref="StardewValley.Buildings.Mill"/> instance being patched.</param>
        /// <param name="__result">The return value of the method being patched.</param>
        /// <returns><see langword="false"/>, meaning the original method will not get ran.</returns>
        /// <remarks>This reimplements the original method to add the custom millables.</remarks>
        internal static bool DoActionPrefix(Vector2 tileLocation, Farmer who, Mill __instance, ref bool __result)
        {
            if (__instance.daysOfConstructionLeft <= 0)
            {
                // check if the player is clicking on the part of the mill to input new items
                if (tileLocation.X == __instance.tileX + 1 && tileLocation.Y == __instance.tileY + 1)
                {
                    // ensure player is holding an item
                    if (who != null && who.ActiveObject != null)
                    {
                        var item = who.ActiveObject;

                        // ensure held item is millable
                        var isItemMillable = false;
                        if (ModEntry.Instance.Recipes.Any(recipe => recipe.InputId == item.ParentSheetIndex))
                        {
                            isItemMillable = true;
                        }
                        if (!isItemMillable)
                        {
                            Game1.showRedMessage(Game1.content.LoadString("Strings\\Buildings:CantMill"));
                            __result = false;
                            return(false);
                        }

                        // place held object in mill
                        who.ActiveObject = null;
                        item             = (StardewValley.Object)MillPatch.AddItemToThisInventoryList(item, __instance.input.Value.items, 36);
                        if (item != null)
                        {
                            who.ActiveObject = item;
                            Game1.showRedMessage(Game1.content.LoadString("Strings\\Buildings:MillFull"));
                        }

                        typeof(Mill).GetField("hasLoadedToday", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(__instance, true);
                        Game1.playSound("Ship");
                    }
                }

                // check if the player is clicking on the part of the mill to pick up processed items
                else if (tileLocation.X == __instance.tileX + 3 && tileLocation.Y == __instance.tileY + 1)
                {
                    Utility.CollectSingleItemOrShowChestMenu(__instance.output.Value, __instance);
                    __result = true;
                    return(false);
                }
            }

            // call the base doAction method
            // this approach isn't ideal but when using regular reflection and invoking the MethodInfo directly, it would call this patch (instead of the base method) resulting in a stack overflow
            // https://stackoverflow.com/questions/4357729/use-reflection-to-invoke-an-overridden-base-method/14415506#14415506
            var baseMethod      = typeof(Building).GetMethod("doAction", BindingFlags.Public | BindingFlags.Instance);
            var functionPointer = baseMethod.MethodHandle.GetFunctionPointer();
            var function        = (Func <Vector2, Farmer, bool>)Activator.CreateInstance(typeof(Func <Vector2, Farmer, bool>), __instance, functionPointer);

            __result = function(tileLocation, who);
            return(false);
        }
        public object getReplacement()
        {
            Mill building = new Mill(new BluePrint("GreenhouseConstruction_SpecialGreenhouse"), new Vector2(this.tileX.Value, this.tileY.Value));

            building.indoors.Value = this.indoors.Value;
            building.daysOfConstructionLeft.Value = this.daysOfConstructionLeft.Value;
            building.tileX.Value = this.tileX.Value;
            building.tileY.Value = this.tileY.Value;
            return(building);
        }
Example #8
0
    internal override int CalculateProductionChanges(Building newNeighbour, Tile neighbourTile)
    {
        if (newNeighbour is Mill)
        {
            Mill mill = newNeighbour as Mill;
            return(mill.bonusForBakery);
        }

        return(0);
    }
        public object getReplacement()
        {
            Mill building = new Mill(new BluePrint("Mill"), new Vector2(tileX, tileY));

            building.indoors.Value = indoors.Value;
            building.daysOfConstructionLeft.Value = daysOfConstructionLeft.Value;
            building.tileX.Value = tileX.Value;
            building.tileY.Value = tileY.Value;
            return(building);
        }
Example #10
0
        public void rebuild(Dictionary <string, string> additionalSaveData, object replacement)
        {
            Mill building = (Mill)replacement;

            indoors.Value = building.indoors.Value;
            daysOfConstructionLeft.Value = building.daysOfConstructionLeft.Value;
            tileX.Value = building.tileX.Value;
            tileY.Value = building.tileY.Value;

            indoors.Value.map = Game1.content.Load <xTile.Map>("Maps\\MiniSpa");
            indoors.Value.updateWarps();
            updateInteriorWarps();
        }
Example #11
0
        public void rebuild(Dictionary <string, string> additionalSaveData, object replacement)
        {
            Mill building = (Mill)replacement;

            indoors.Value = building.indoors.Value;
            daysOfConstructionLeft.Value = building.daysOfConstructionLeft.Value;
            tileX.Value = building.tileX.Value;
            tileY.Value = building.tileY.Value;

            indoors.Value.map = Game1.content.Load <xTile.Map>("Maps\\SpookyShed");
            indoors.Value.GetType().GetMethod("updateWarps", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(indoors.Value, new object[] { });
            updateInteriorWarps();
        }
Example #12
0
 public LoginPage()
 {
     InitializeComponent();
     DT           = (MainView)DataContext;
     DT.LoginM.Id = Mill.GetXaml();
     if (DT.LoginM.Id == "")
     {
         Username.Focus();
     }
     else
     {
         Passwords.Focus();
     }
 }
        /// <summary>
        /// Data from the line is transferred to CPRG
        /// </summary>
        /// <returns></returns>
        public CalibrationProgram ExtractCalibrationProgram(Mill mill)
        {
            var character = GetOwnerCharacter;

            var calibrationProgram = GetOrCreateCalibrationProgram(mill);

            int materialEfficiency;
            int timeEfficiency;

            CalculateDecalibrationPenalty(character, out materialEfficiency, out timeEfficiency);

            calibrationProgram.MaterialEfficiencyPoints = materialEfficiency;
            calibrationProgram.TimeEfficiencyPoints     = timeEfficiency;

            return(calibrationProgram);
        }
Example #14
0
        private static Miller GenerateMill(Area area, int x, int y, string name)
        {
            var mill   = new Mill(Guid.NewGuid(), "Mill", area, x, y, 20, 20, true);
            var barn   = new Barn(Guid.NewGuid(), "Barn", area, x + RandomSingleton.Instance.Random.Next(-10, 30), y + 20 + RandomSingleton.Instance.Random.Next(-5, 20), 10, 10);
            var person = new Miller(Guid.NewGuid(), name, mill);

            person.Inventory.AddResource(Constants.ResourceIdCoin, 100);
            mill.Owner = person;

            person.AddOwnerShip(mill);
            person.AddOwnerShip(barn);
            area.AddLocation(mill);
            area.AddLocation(barn);

            return(person);
        }
        public void Split_Timer(Stopwatch Timer, ref string Time)
        {
            int t = Timer.Elapsed.Milliseconds;

            int Min, Sec, Mill;

            Min = t / (60 * 1000);

            t = t - (Min * 60000);

            Sec = t / 1000;

            t = t - (Sec * 1000);

            Mill = t;

            if (Min <= 9)
            {
                Time = "0" + Min;
            }
            else
            {
                Time = Min.ToString();
            }

            Time = Time + " : ";

            if (Sec <= 9)
            {
                Time = Time + "0" + Sec;
            }
            else
            {
                Time = Time + Sec.ToString();
            }

            Time = Time + " : ";

            if (Mill <= 9)
            {
                Time = Time + "0" + Mill;
            }
            else
            {
                Time = Time + Mill.ToString();
            }
        }
Example #16
0
    void OnParticleCollision(GameObject other)
    {
        if (hasSplashed == false && (other.GetComponent <FloorPiece>() || other.GetComponent <Pipe>()))
        {
            hasSplashed = true;
            splash.Play();
        }

        if (other.GetComponent <Mill> ())
        {
            Mill myMill = other.GetComponent <Mill> ();
            if (!myMill.isRotating)
            {
                myMill.ActivateMill();
            }
        }
    }
Example #17
0
        /// <summary>The prefix for the <see cref="StardewValley.Buildings.Mill.dayUpdate(int)"/> method.</summary>
        /// <param name="dayOfMonth">The current day of month.</param>
        /// <param name="__instance">The current <see cref="StardewValley.Buildings.Mill"/> instance being patched.</param>
        /// <returns><see langword="false"/>, meaning the original method will not get ran.</returns>
        /// <remarks>This reimplements the original method to add the custom millables.</remarks>
        internal static bool DayUpdatePrefix(int dayOfMonth, Mill __instance)
        {
            // reset hasLoadedToday
            typeof(Mill).GetField("hasLoadedToday", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(__instance, false);

            // convert all inputs
            for (int i = __instance.input.Value.items.Count - 1; i >= 0; i--)
            {
                // ensure there's an item in the input slot
                var item = __instance.input.Value.items[i];
                if (item == null)
                {
                    continue;
                }

                // get the recipe output
                var recipe = ModEntry.Instance.Recipes.FirstOrDefault(r => r.InputId == item.ParentSheetIndex);
                if (recipe == null)
                {
                    ModEntry.Instance.Monitor.Log($"Failed to retreive recipe that has an input id of {item.ParentSheetIndex}, mill input will be deleted", LogLevel.Error);
                    __instance.input.Value.items[i] = null;
                }
                var outputObject = new StardewValley.Object(recipe.Output.Id, item.Stack * recipe.Output.Amount);

                // try to add the item to the output
                if (Utility.canItemBeAddedToThisInventoryList(outputObject, __instance.output.Value.items, 36))
                {
                    __instance.input.Value.items[i] = MillPatch.AddItemToThisInventoryList(outputObject, __instance.output.Value.items, 36);
                }
            }

            // call the base dayUpdate method
            // this approach isn't ideal but when using regular reflection and invoking the MethodInfo directly, it would call this patch (instead of the base method) resulting in a stack overflow
            // https://stackoverflow.com/questions/4357729/use-reflection-to-invoke-an-overridden-base-method/14415506#14415506
            var baseMethod      = typeof(Building).GetMethod("dayUpdate", BindingFlags.Public | BindingFlags.Instance);
            var functionPointer = baseMethod.MethodHandle.GetFunctionPointer();
            var function        = (Func <int, bool>)Activator.CreateInstance(typeof(Func <int, bool>), __instance, functionPointer);

            function(dayOfMonth);
            return(false);
        }
Example #18
0
        public void HandleRequest(IRequest request)
        {
            using (var scope = Db.CreateTransaction())
            {
                var character   = request.Session.Character;
                var lineId      = request.Data.GetOrDefault <int>(k.ID);
                var rounds      = request.Data.GetOrDefault <int>(k.rounds);
                var facilityEid = request.Data.GetOrDefault <long>(k.facility);

                _productionManager.GetFacilityAndCheckDocking(facilityEid, character, out Mill mill);

                ProductionLine.LoadById(lineId, out ProductionLine productionLine).ThrowIfError();

                productionLine.CharacterId.ThrowIfNotEqual(character.Id, ErrorCodes.OwnerMismatch);

                var maxRounds = Mill.GetMaxRounds(character);

                if (rounds > maxRounds)
                {
                    rounds = maxRounds;
                }

                ProductionLine.SetRounds(rounds, productionLine.Id).ThrowIfError();

                var linesList    = mill.GetLinesList(character);
                var facilityInfo = mill.GetFacilityInfo(character);

                var reply = new Dictionary <string, object>
                {
                    { k.lineCount, linesList.Count },
                    { k.lines, linesList },
                    { k.facility, facilityInfo }
                };

                Message.Builder.SetCommand(Commands.ProductionLineList).WithData(reply).ToClient(request.Session).Send();

                scope.Complete();
            }
        }
Example #19
0
    public override bool CheckForNeighbouringBuildings()
    {
        Debug.Log("Checks for mill");
        List <Mill> chainBuildings = GetNeighbouringBuildings <Mill>();

        if (nextInChain == null && chainBuildings.Count >= 1)
        {
            Debug.Log(">= 1");
            nextInChain = chainBuildings[0];
            AssignCarrierDestination();
        }

        Debug.Log("Checks for distillery");
        List <Distillery> chainBuildings2 = GetNeighbouringBuildings <Distillery>();

        if (alternativeChain == null && chainBuildings2.Count >= 1)
        {
            Debug.Log(">= 1");
            alternativeChain = chainBuildings2[0];
            AssignCarrierAlternativeDestination();
        }

        return((nextInChain == null && chainBuildings.Count >= 1) || (alternativeChain == null && chainBuildings2.Count >= 1));
    }
Example #20
0
        private void Login()
        {
            if (IsNullFill())
            {
                MessageBox.Show(Language.NullFill, Language.Notification);
                return;
            }
            ConnectData.RandomToken();
            string ID          = LoginM.Id; ConnectData.Username = ID;
            string Password    = LoginM.Password; ConnectData.Password = Password;
            string loginResult = ConnectData.Login();

            switch (loginResult)
            {
            case "NullFill":
                MessageBox.Show(Language.NullFill, Language.Notification);
                return;

            case "false":
                MessageBox.Show(Language.ErrorConnect, Language.Notification);
                return;

            case "Exception":
                MessageBox.Show(Language.ErrorAccount, Language.Notification);
                return;

            case "wrong":
                LoadWor.Read = true;
                MessageBox.Show(Language.Wrong, Language.Notification, MessageBoxButton.OK, MessageBoxImage.Error);
                return;

            case "Shell":
                LoadWor.Read = true;
                MessageBox.Show(Language.Wrong, Language.ShellNew, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            dynamic data = JsonConvert.DeserializeObject(loginResult);

            if (data.banned == "1")
            {
                MessageBox.Show(Language.BannedAccount, Language.Notification, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            LoginM.Type    = Language.TypeMember[data.is_admin];
            LoginM.Email   = data.email;
            LoginM.Gender  = data.gender;
            LoginM.RegDate = data.register_date;
            LoginM.Server  = ConnectData.ServerName;

            dynamic Online = ConnectData.Online();

            if (Online.Online == "true")
            {
                MessageBoxResult _returnReg = MessageBox.Show(Language.Set(Language.OutNow, ID), Language.Notification, MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (_returnReg == MessageBoxResult.No)
                {
                    return;
                }
                if (_returnReg == MessageBoxResult.Yes)
                {
                    ConnectData.Logout(true);
                    return;
                }
            }
            else if (Online.Online == "Error")
            {
                MessageBox.Show(Language.ErrorConnect, Language.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            GetDataInfo();
            string InOnline = ConnectData.InInsertOnline();

            if (InOnline == "false" || InOnline == "Error")
            {
                MessageBox.Show(Language.ErrorConnect, Language.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            ConnectData.LogoutKey = true;
            if (Mill.FilePath())
            {
                Mill.CreateXaml(LoginM.Id);
            }
            else
            {
                Mill.SetXaml(LoginM.Id);
            }

            Start();
        }
Example #21
0
        // Save and open

        public static void Saveing(AccountModel R)
        {
            try
            {
                #region main

                Mill.IniWrite(KeyString.Main[0], KeyString.Main[1], R.AutoInput);
                Mill.IniWrite(KeyString.Main[0], KeyString.Main[2], R.IsHp);
                Mill.IniWrite(KeyString.Main[0], KeyString.Main[3], R.HpInput);
                Mill.IniWrite(KeyString.Main[0], KeyString.Main[4], R.IsMp);
                Mill.IniWrite(KeyString.Main[0], KeyString.Main[5], R.MpInput);
                Mill.IniWrite(KeyString.Main[0], KeyString.Main[6], R.IsExP);
                Mill.IniWrite(KeyString.Main[0], KeyString.Main[7], R.ExpInput);
                Mill.IniWrite(KeyString.Main[0], KeyString.Main[8], R.IsCut);
                Mill.IniWrite(KeyString.Main[0], KeyString.Main[9], R.CutInput);
                Mill.IniWrite(KeyString.Main[0], KeyString.Main[10], R.IsClickSpeed);
                Mill.IniWrite(KeyString.Main[0], KeyString.Main[11], R.IsAutoClick);
                Mill.IniWrite(KeyString.Main[0], KeyString.Main[12], R.IsMouseClick);

                #endregion main

                #region train

                Mill.IniWrite(KeyString.Train[0], KeyString.Train[1], R.IsKillToDie);
                Mill.IniWrite(KeyString.Train[0], KeyString.Train[2], R.IsAutoBuff);
                Mill.IniWrite(KeyString.Train[0], KeyString.Train[3], R.IsShutdown);
                Mill.IniWrite(KeyString.Train[0], KeyString.Train[4], R.HpShutDown);
                Mill.IniWrite(KeyString.Train[0], KeyString.Train[5], R.ReadRangeInput);
                Mill.IniWrite(KeyString.Train[0], KeyString.Train[6], R.RadiusInput);
                Mill.IniWrite(KeyString.Train[0], KeyString.Train[7], R.LagInput);

                #endregion train

                #region Skill

                Mill.IniWrite(KeyString.Skill[0], KeyString.Skill[1], R.IComboxName);
                Mill.IniWrite(KeyString.Skill[0], KeyString.Skill[2], R.IsAttack);
                Mill.IniWrite(KeyString.Skill[0], KeyString.Skill[3], R.ISkillAttack);
                Mill.IniWrite(KeyString.Skill[0], KeyString.Skill[4], R.IsBuff[0]);
                Mill.IniWrite(KeyString.Skill[0], KeyString.Skill[5], R.ISkillBuff_1);
                Mill.IniWrite(KeyString.Skill[0], KeyString.Skill[6], R.STimeSkill[0]);
                Mill.IniWrite(KeyString.Skill[0], KeyString.Skill[7], R.LoadSkill[0]);
                Mill.IniWrite(KeyString.Skill[0], KeyString.Skill[8], R.IsBuff[1]);
                Mill.IniWrite(KeyString.Skill[0], KeyString.Skill[9], R.ISkillBuff_2);
                Mill.IniWrite(KeyString.Skill[0], KeyString.Skill[10], R.STimeSkill[1]);
                Mill.IniWrite(KeyString.Skill[0], KeyString.Skill[11], R.LoadSkill[1]);
                Mill.IniWrite(KeyString.Skill[0], KeyString.Skill[12], R.IsBuff[2]);
                Mill.IniWrite(KeyString.Skill[0], KeyString.Skill[13], R.ISkillBuff_3);
                Mill.IniWrite(KeyString.Skill[0], KeyString.Skill[14], R.STimeSkill[2]);
                Mill.IniWrite(KeyString.Skill[0], KeyString.Skill[15], R.LoadSkill[2]);
                Mill.IniWrite(KeyString.Skill[0], KeyString.Skill[16], R.IsBuff[3]);
                Mill.IniWrite(KeyString.Skill[0], KeyString.Skill[17], R.ISkillBuff_4);
                Mill.IniWrite(KeyString.Skill[0], KeyString.Skill[18], R.STimeSkill[3]);
                Mill.IniWrite(KeyString.Skill[0], KeyString.Skill[19], R.LoadSkill[3]);

                #endregion Skill

                if (R.ListCord.Count > 0)
                {
                    foreach (var item in R.ListCord)
                    {
                        Mill.IniWrite(KeyString.NameAdd[1], Mill.Change(item.Id), item.X, item.Y);
                        Thread.Sleep(1);
                    }
                }

                MessageBox.Show(Language.Set(Language.Saveing, Mill.IniFile.Path()), Language.Notification);
            }
            catch
            {
                MessageBox.Show(Language.ErrorSaveing, Language.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #22
0
        public static void Open(AccountModel R)
        {
            try
            {
                try
                {
                    #region main

                    R.AutoInput    = Mill.Change(KeyString.Main[0], KeyString.Main[1], R.AutoInput);
                    R.IsHp         = Mill.Change(KeyString.Main[0], KeyString.Main[2], R.IsHp);
                    R.HpInput      = Mill.Change(KeyString.Main[0], KeyString.Main[3], R.HpInput);
                    R.IsMp         = Mill.Change(KeyString.Main[0], KeyString.Main[4], R.IsMp);
                    R.MpInput      = Mill.Change(KeyString.Main[0], KeyString.Main[5], R.MpInput);
                    R.IsExP        = Mill.Change(KeyString.Main[0], KeyString.Main[6], R.IsExP);
                    R.ExpInput     = Mill.Change(KeyString.Main[0], KeyString.Main[7], R.ExpInput);
                    R.IsCut        = Mill.Change(KeyString.Main[0], KeyString.Main[8], R.IsCut);
                    R.CutInput     = Mill.Change(KeyString.Main[0], KeyString.Main[9], R.CutInput);
                    R.IsClickSpeed = Mill.Change(KeyString.Main[0], KeyString.Main[10], R.IsClickSpeed);
                    R.IsAutoClick  = Mill.Change(KeyString.Main[0], KeyString.Main[11], R.IsAutoClick);
                    R.IsMouseClick = Mill.Change(KeyString.Main[0], KeyString.Main[12], R.IsMouseClick);

                    #endregion main

                    #region train

                    R.IsKillToDie    = Mill.Change(KeyString.Train[0], KeyString.Train[1], R.IsKillToDie);
                    R.IsAutoBuff     = Mill.Change(KeyString.Train[0], KeyString.Train[2], R.IsAutoBuff);
                    R.IsShutdown     = Mill.Change(KeyString.Train[0], KeyString.Train[3], R.IsShutdown);
                    R.HpShutDown     = Mill.Change(KeyString.Train[0], KeyString.Train[4], R.HpShutDown);
                    R.ReadRangeInput = Mill.Change(KeyString.Train[0], KeyString.Train[5], R.ReadRangeInput);
                    R.RadiusInput    = Mill.Change(KeyString.Train[0], KeyString.Train[6], R.RadiusInput);
                    R.LagInput       = Mill.Change(KeyString.Train[0], KeyString.Train[7], R.LagInput);

                    #endregion train

                    #region Skill

                    R.IComboxName   = Mill.Change(KeyString.Skill[0], KeyString.Skill[1], R.IComboxName);
                    R.IsAttack      = Mill.Change(KeyString.Skill[0], KeyString.Skill[2], R.IsAttack);
                    R.ISkillAttack  = Mill.Change(KeyString.Skill[0], KeyString.Skill[3], R.ISkillAttack);
                    R.IsBuff[0]     = Mill.Change(KeyString.Skill[0], KeyString.Skill[4], R.IsBuff[0]);
                    R.ISkillBuff_1  = Mill.Change(KeyString.Skill[0], KeyString.Skill[5], R.ISkillBuff_1);
                    R.STimeSkill[0] = Mill.Change(KeyString.Skill[0], KeyString.Skill[6], R.STimeSkill[0]);
                    R.LoadSkill[0]  = Mill.Change(KeyString.Skill[0], KeyString.Skill[7], R.LoadSkill[0]);
                    R.IsBuff[1]     = Mill.Change(KeyString.Skill[0], KeyString.Skill[8], R.IsBuff[1]);
                    R.ISkillBuff_2  = Mill.Change(KeyString.Skill[0], KeyString.Skill[9], R.ISkillBuff_2);
                    R.STimeSkill[1] = Mill.Change(KeyString.Skill[0], KeyString.Skill[10], R.STimeSkill[1]);
                    R.LoadSkill[1]  = Mill.Change(KeyString.Skill[0], KeyString.Skill[11], R.LoadSkill[1]);
                    R.IsBuff[2]     = Mill.Change(KeyString.Skill[0], KeyString.Skill[12], R.IsBuff[2]);
                    R.ISkillBuff_3  = Mill.Change(KeyString.Skill[0], KeyString.Skill[13], R.ISkillBuff_3);
                    R.STimeSkill[2] = Mill.Change(KeyString.Skill[0], KeyString.Skill[14], R.STimeSkill[2]);
                    R.LoadSkill[2]  = Mill.Change(KeyString.Skill[0], KeyString.Skill[15], R.LoadSkill[2]);
                    R.IsBuff[3]     = Mill.Change(KeyString.Skill[0], KeyString.Skill[16], R.IsBuff[3]);
                    R.ISkillBuff_4  = Mill.Change(KeyString.Skill[0], KeyString.Skill[17], R.ISkillBuff_4);
                    R.STimeSkill[3] = Mill.Change(KeyString.Skill[0], KeyString.Skill[18], R.STimeSkill[3]);
                    R.LoadSkill[3]  = Mill.Change(KeyString.Skill[0], KeyString.Skill[19], R.LoadSkill[3]);

                    #endregion Skill
                }
                catch { }
                string[] SetGet = null;
                R.ListCord.Clear();

                for (int i = 1; i <= 999999999; i++)
                {
                    try
                    {
                        ListCord Cort = new ListCord();
                        SetGet  = Mill.IniRead(KeyString.NameAdd[1], i);
                        Cort.Id = i;
                        Cort.X  = Mill.Change(Cort.X, SetGet[0]);
                        Cort.Y  = Mill.Change(Cort.Y, SetGet[1]);
                        R.ListCord.Add(Cort);
                        Thread.Sleep(10);
                    }
                    catch
                    {
                        break;
                    }
                }
                MessageBox.Show(Language.Success, Language.Notification);
            }
            catch
            {
                MessageBox.Show(Language.ErrorOpen, Language.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #23
0
        /// <summary>The prefix for the <see cref="StardewValley.Buildings.Mill.draw(Microsoft.Xna.Framework.Graphics.SpriteBatch)"/> method.</summary>
        /// <param name="b">The <see cref="Microsoft.Xna.Framework.Graphics.SpriteBatch"/> to draw the mill to.</param>
        /// <param name="__instance">The current <see cref="StardewValley.Buildings.Mill"/> instance being patched.</param>
        /// <returns><see lanword="false"/>, meaning the original method will not get ran.</returns>
        /// <remarks>This reimplements the original method to remove the check when drawing the item overlay on the output chest (so any item in the output chest can get drawn).</remarks>
        internal static bool DrawPrefix(SpriteBatch b, Mill __instance)
        {
            if (__instance.isMoving)
            {
                return(false);
            }

            // draw mill differently when under construction
            if (__instance.daysOfConstructionLeft > 0)
            {
                __instance.drawInConstruction(b);
                return(false);
            }

            // get private members
            var baseSourceRect = (Rectangle)typeof(Mill).GetField("baseSourceRect", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance);
            var alpha          = (NetFloat)typeof(Mill).GetField("alpha", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance);
            var hasLoadedToday = (bool)typeof(Mill).GetField("hasLoadedToday", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance);

            __instance.drawShadow(b);

            // draw base
            b.Draw(
                texture: __instance.texture.Value,
                position: Game1.GlobalToLocal(
                    viewport: Game1.viewport,
                    globalPosition: new Vector2(__instance.tileX * 64, __instance.tileY * 64 + __instance.tilesHigh * 64)),
                sourceRectangle: baseSourceRect,
                color: __instance.color.Value * alpha,
                rotation: 0,
                origin: new Vector2(0, __instance.texture.Value.Bounds.Height),
                scale: 4,
                effects: SpriteEffects.None,
                layerDepth: (__instance.tileY + __instance.tilesHigh - 1) * 64 / 10000f
                );

            // draw spinning propeller
            b.Draw(
                texture: __instance.texture.Value,
                position: Game1.GlobalToLocal(
                    viewport: Game1.viewport,
                    globalPosition: new Vector2(__instance.tileX * 64 + 32, __instance.tileY * 64 + __instance.tilesHigh * 64 + 4)),
                sourceRectangle: new Rectangle(
                    x: 64 + (int)Game1.currentGameTime.TotalGameTime.TotalMilliseconds % 800 / 89 * 32 % 160,
                    y: (int)Game1.currentGameTime.TotalGameTime.TotalMilliseconds % 800 / 89 * 32 / 160 * 32,
                    width: 32,
                    height: 32),
                color: __instance.color.Value * alpha,
                rotation: 0,
                origin: new Vector2(0f, __instance.texture.Value.Bounds.Height),
                scale: 4,
                effects: SpriteEffects.None,
                layerDepth: (__instance.tileY + __instance.tilesHigh) * 64 / 10000f
                );

            // draw sprinning gear if something has been placing in it
            if (hasLoadedToday)
            {
                b.Draw(
                    texture: __instance.texture.Value,
                    position: Game1.GlobalToLocal(
                        viewport: Game1.viewport,
                        globalPosition: new Vector2(__instance.tileX * 64 + 52, __instance.tileY * 64 + __instance.tilesHigh * 64 + 276)),
                    sourceRectangle: new Rectangle(64 + (int)Game1.currentGameTime.TotalGameTime.TotalMilliseconds % 700 / 100 * 21, 72, 21, 8),
                    color: __instance.color.Value * alpha,
                    rotation: 0f,
                    origin: new Vector2(0f, __instance.texture.Value.Bounds.Height),
                    scale: 4f,
                    effects: SpriteEffects.None,
                    layerDepth: (__instance.tileY + __instance.tilesHigh) * 64 / 10000f
                    );
            }

            // draw object overlay when output is collectible
            if (__instance.output.Value.items.Count > 0 && __instance.output.Value.items[0] != null)
            {
                float yOffset = 4f * (float)Math.Round(Math.Sin(Game1.currentGameTime.TotalGameTime.TotalMilliseconds / 250.0), 2);
                b.Draw(
                    texture: Game1.mouseCursors,
                    position: Game1.GlobalToLocal(
                        viewport: Game1.viewport,
                        globalPosition: new Vector2(__instance.tileX * 64 + 192, __instance.tileY * 64 - 96 + yOffset)),
                    sourceRectangle: new Rectangle(141, 465, 20, 24),
                    color: Color.White * .75f,
                    rotation: 0,
                    origin: Vector2.Zero,
                    scale: 4,
                    effects: SpriteEffects.None,
                    layerDepth: (__instance.tileY + 1 * 64) / 10000f + .0000001f + __instance.tileX / 10000f
                    );

                b.Draw(
                    texture: Game1.objectSpriteSheet,
                    position: Game1.GlobalToLocal(
                        viewport: Game1.viewport,
                        globalPosition: new Vector2(__instance.tileX * 64 + 192 + 32 + 4, __instance.tileY * 64 - 64 + 8 + yOffset)),
                    sourceRectangle: Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, __instance.output.Value.items[0].parentSheetIndex, 16, 16),
                    color: Color.White * .75f,
                    rotation: 0,
                    origin: new Vector2(8),
                    scale: 4,
                    effects: SpriteEffects.None,
                    layerDepth: (__instance.tileY + 1) * 64 / 10000f + .000001f + __instance.tileX / 10000f
                    );
            }

            return(false);
        }
Example #24
0
    void Update()
    {
        if (Manager._instance.isMainMenu || Manager._instance.isPaused)
        {
            return;
        }

        cPop              = 0;
        totalMiners       = 0;
        totalJacks        = 0;
        totalPowerWorkers = 0;
        maxPopulation     = 0;

        maxMineWorkers = 0;
        maxMillWorkers = 0;
        foreach (Building building in Building.buildings)
        {
            switch (building.tile.buildingType.name)
            {
            case "Mine":
                Mine mine = (Mine)building;
                maxMineWorkers += mine.maxWorkers;
                break;

            case "Mill":
                Mill mill = (Mill)building;
                maxMillWorkers += mill.maxWorkers;
                break;
            }
        }

        foreach (House house in houses)
        {
            cPop          += house.occupancy;
            maxPopulation += house.maxCapacity;

            int mi = totalMiners;
            int jo = totalJacks;

            totalMiners = Mathf.Min(maxMineWorkers, totalMiners + house.miners);
            totalJacks  = Mathf.Min(maxMillWorkers, totalJacks + house.lumberjacks);

            house.lumberProvided = totalJacks - jo;
            house.minerProvided  = totalMiners - mi;
            //totalPowerWorkers += house.power;
        }

        PeopleCount.text = string.Format("Total: {0}/{1}  Miners: {2}/{3}  Lumberjacks: {4}/{5}", cPop, maxPopulation, totalMiners, maxMineWorkers, totalJacks, maxMillWorkers);
        foreach (Building building in Building.buildings)
        {
            switch (building.tile.buildingType.name)
            {
            case "Mine":
                Mine mine = (Mine)building;
                if (mine.workers >= mine.maxWorkers)
                {
                    continue;
                }
                int inc = Mathf.Min(mine.maxWorkers, totalMiners);
                mine.workers = inc;
                totalMiners -= inc;
                break;

            case "Mill":
                Mill mill = (Mill)building;
                if (mill.workers >= mill.maxWorkers)
                {
                    continue;
                }
                inc          = Mathf.Min(mill.maxWorkers, totalJacks);
                mill.workers = inc;
                totalJacks  -= inc;
                break;
            }
        }

        foreach (KeyValuePair <string, BuildingType> bType in buildings)
        {
            if (Input.GetKey(bType.Value.hotkey))
            {
                if (hoverTile != null)
                {
                    if (hoverTile.buildingType == null)
                    {
                        if (canBuild(hoverTile, bType.Value))
                        {
                            buildOnTile(bType.Key);
                        }
                    }
                }
            }
        }

        PowerManager._instance.powerSupply = 0;
        float powerLimitOverall = 0;

        foreach (Building building in Building.buildings)
        {
            if (building.tile.buildingType.name != "PowerPlant")
            {
                powerLimitOverall += building.powerLimit;
            }
        }

        foreach (PowerPlant building in plants)
        {
            PowerManager._instance.powerSupply += building.powerStored;
            building.powerStored = 0;
        }

        string resource = "";

        foreach (KeyValuePair <OreTypes, int> entry in GenWorld._instance.Resources)
        {
            resource += entry.Key.ToString() + ": " + entry.Value + " ";
        }

        ResourceCount.text = resource;
        PowerManager._instance.powerStored += (Mathf.Round(PowerManager._instance.powerSupply) * Time.deltaTime) - (Mathf.Round(PowerManager._instance.powerDraw) * Time.deltaTime);
        updatePowerInfo();

        PowerForground.transform.localScale = new Vector3(Mathf.Min(/*(GenWorld._instance.powerSupply / GenWorld._instance.powerDraw)*/ PowerManager._instance.powerStored / powerLimitOverall, 1), 1, 1);

        if (houses.Count > Mathf.Min(10, Mathf.Pow(2f, GenWorld._instance.expandCount)))
        {
            GenWorld._instance.expandMap(5);
            GenWorld._instance.expandCount++;
        }
    }
        public bool buildStructure(BluePrint structureForPlacement, Vector2 tileLocation, Farmer who, bool magicalConstruction = false, bool skipSafetyChecks = false)
        {
            if (!skipSafetyChecks)
            {
                for (int y2 = 0; y2 < structureForPlacement.tilesHeight; y2++)
                {
                    for (int x2 = 0; x2 < structureForPlacement.tilesWidth; x2++)
                    {
                        pokeTileForConstruction(new Vector2(tileLocation.X + (float)x2, tileLocation.Y + (float)y2));
                    }
                }
                for (int y3 = 0; y3 < structureForPlacement.tilesHeight; y3++)
                {
                    for (int x3 = 0; x3 < structureForPlacement.tilesWidth; x3++)
                    {
                        Vector2 currentGlobalTilePosition2 = new Vector2(tileLocation.X + (float)x3, tileLocation.Y + (float)y3);
                        if (!isBuildable(currentGlobalTilePosition2))
                        {
                            return(false);
                        }
                        foreach (Farmer farmer in farmers)
                        {
                            if (farmer.GetBoundingBox().Intersects(new Microsoft.Xna.Framework.Rectangle(x3 * 64, y3 * 64, 64, 64)))
                            {
                                return(false);
                            }
                        }
                    }
                }
                if (structureForPlacement.humanDoor != new Point(-1, -1))
                {
                    Vector2 doorPos = tileLocation + new Vector2(structureForPlacement.humanDoor.X, structureForPlacement.humanDoor.Y + 1);
                    if (!isBuildable(doorPos) && !isPath(doorPos))
                    {
                        return(false);
                    }
                }
            }
            Building b;

            switch (structureForPlacement.name)
            {
            case "Stable":
                b = new Stable(StardewValley.Util.GuidHelper.NewGuid(), structureForPlacement, tileLocation);
                break;

            case "Coop":
            case "Big Coop":
            case "Deluxe Coop":
                b = new Coop(structureForPlacement, tileLocation);
                break;

            case "Barn":
            case "Big Barn":
            case "Deluxe Barn":
                b = new Barn(structureForPlacement, tileLocation);
                break;

            case "Mill":
                b = new Mill(structureForPlacement, tileLocation);
                break;

            case "Junimo Hut":
                b = new JunimoHut(structureForPlacement, tileLocation);
                break;

            case "Shipping Bin":
                b = new ShippingBin(structureForPlacement, tileLocation);
                break;

            case "Fish Pond":
                b = new FishPond(structureForPlacement, tileLocation);
                break;

            default:
                b = new Building(structureForPlacement, tileLocation);
                break;
            }
            b.owner.Value = who.UniqueMultiplayerID;
            if (!skipSafetyChecks)
            {
                string finalCheckResult = b.isThereAnythingtoPreventConstruction(this);
                if (finalCheckResult != null)
                {
                    Game1.addHUDMessage(new HUDMessage(finalCheckResult, Color.Red, 3500f));
                    return(false);
                }
            }
            for (int y = 0; y < structureForPlacement.tilesHeight; y++)
            {
                for (int x = 0; x < structureForPlacement.tilesWidth; x++)
                {
                    Vector2 currentGlobalTilePosition = new Vector2(tileLocation.X + (float)x, tileLocation.Y + (float)y);
                    terrainFeatures.Remove(currentGlobalTilePosition);
                }
            }
            buildings.Add(b);
            b.performActionOnConstruction(this);
            return(true);
        }
Example #26
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="mill">The underlying mill.</param>
 public MillMachine(Mill mill)
 {
     this.Mill = mill;
 }
Example #27
0
        /*********
        ** Private methods
        *********/
        /// <summary>The method invoked when the player presses a controller, keyboard, or mouse button.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event data.</param>
        private void InputEvents_ButtonPressed(object sender, EventArgsInput e)
        {
            if (!e.IsActionButton && !(e.Button == SButton.ControllerA) && !(e.Button == SButton.ControllerX))
            {
                return;
            }
            Mill mill = this.GetBuildingAt(e.Cursor.GrabTile) as Mill;

            if (mill == null)
            {
                return;
            }

            //if(!e.IsSuppressed)
            e.SuppressButton();


            if (Game1.player.CurrentItem is StardewValley.Object currentObj && currentObj.category == -75)
            {
                if (currentObj.parentSheetIndex == 262 && this.Config.ProcessWheat) // Do things for Wheat.
                {
                    Game1.addHUDMessage(new HUDMessage(currentObj.stack + " " + currentObj.displayName + " added to the mill.", 3)
                    {
                        noIcon = true, timeLeft = HUDMessage.defaultTime
                    });
                    Item remaining = mill.input.addItem(currentObj);
                    if (remaining == null)
                    {
                        DeleteHeld();
                    }
                    //this.Helper.Reflection.GetField<bool>(mill, "hasLoadedToday").SetValue(true);
                    Game1.playSound("Ship");
                }
                //else if (currentObj.parentSheetIndex == 262 && !this.Config.ProcessWheat)
                //{
                //    Game1.showRedMessage(Game1.content.LoadString("Strings\\Buildings:CantMill"));
                //}
                if (currentObj.parentSheetIndex == 270 && this.Config.ProcessCorn) // Do things for Corn.
                {
                    Game1.addHUDMessage(new HUDMessage(currentObj.stack + " " + currentObj.displayName + " added to the mill.", 3)
                    {
                        noIcon = true, timeLeft = HUDMessage.defaultTime
                    });
                    Item remaining = mill.input.addItem(currentObj);
                    if (remaining == null)
                    {
                        DeleteHeld();
                    }
                    //this.Helper.Reflection.GetField<bool>(mill, "hasLoadedToday").SetValue(true);
                    Game1.playSound("Ship");
                }
                if (currentObj.parentSheetIndex == 300 && this.Config.ProcessAmaranth) // Do things for Amaranth.
                {
                    Game1.addHUDMessage(new HUDMessage(currentObj.stack + " " + currentObj.displayName + " added to the mill.", 3)
                    {
                        noIcon = true, timeLeft = HUDMessage.defaultTime
                    });
                    Item remaining = mill.input.addItem(currentObj);
                    if (remaining == null)
                    {
                        DeleteHeld();
                    }
                    //this.Helper.Reflection.GetField<bool>(mill, "hasLoadedToday").SetValue(true);
                    Game1.playSound("Ship");
                }
                if (currentObj.parentSheetIndex == 284 && this.Config.ProcessBeet) // Do things for beets.
                {
                    Game1.addHUDMessage(new HUDMessage(currentObj.stack + " " + currentObj.displayName + " added to the mill.", 3)
                    {
                        noIcon = true, timeLeft = HUDMessage.defaultTime
                    });
                    Item remaining = mill.input.addItem(currentObj);
                    if (remaining == null)
                    {
                        DeleteHeld();
                    }
                    //this.Helper.Reflection.GetField<bool>(mill, "hasLoadedToday").SetValue(true);
                    Game1.playSound("Ship");
                }
            }



            //if (Game1.player.CurrentItem is StardewValley.Object currentObj && currentObj.parentSheetIndex == 262 && currentObj.category == -75) { }// wheat
        }
        public IDictionary <string, object> LineStartInMill(Character character, Container sourceContainer, int lineId, int cycles, bool useCorporationWallet, bool searchInRobots, Mill mill, int rounds)
        {
            const int maxCycles = 1;

            cycles.ThrowIfGreater(maxCycles, ErrorCodes.ProductionMaxCyclesExceeded);

            var maxRounds = Mill.GetMaxRounds(character);

            if (rounds > maxRounds)
            {
                rounds = maxRounds;
            }

            ProductionLine productionLine;

            ProductionLine.LoadById(lineId, out productionLine).ThrowIfError();

            productionLine.CharacterId.ThrowIfNotEqual(character.Id, ErrorCodes.OwnerMismatch);
            productionLine.IsActive().ThrowIfTrue(ErrorCodes.ProductionIsRunningOnThisLine);
            productionLine.IsAtZero().ThrowIfTrue(ErrorCodes.ProductionLineIsAtZero);

            if (productionLine.Rounds != rounds)
            {
                ProductionLine.SetRounds(rounds, productionLine.Id).ThrowIfError();
                productionLine.Rounds = rounds;
            }

            bool hasBonus;
            var  newProduction = mill.LineStart(character, productionLine, sourceContainer, cycles, useCorporationWallet, out hasBonus);

            if (newProduction == null)
            {
                if (useCorporationWallet)
                {
                    throw new PerpetuumException(ErrorCodes.CorporationNotEnoughMoney);
                }

                throw new PerpetuumException(ErrorCodes.CharacterNotEnoughMoney);
            }

            //return info
            var replyDict = new Dictionary <string, object>();

            var linesList = mill.GetLinesList(character);

            replyDict.Add(k.lines, linesList);
            replyDict.Add(k.lineCount, linesList.Count);

            var productionDict = newProduction.ToDictionary();

            replyDict.Add(k.production, productionDict);

            var informDict = sourceContainer.ToDictionary();

            replyDict.Add(k.sourceContainer, informDict);

            var facilityInfo = mill.GetFacilityInfo(character);

            replyDict.Add(k.facility, facilityInfo);

            replyDict.Add(k.hasBonus, hasBonus);

            return(replyDict);
        }
        // Token: 0x0600106B RID: 4203 RVA: 0x00152DC4 File Offset: 0x00150FC4
        public bool buildStructure(BluePrint structureForPlacement, Vector2 tileLocation, bool serverMessage, Farmer who, bool magicalConstruction = false)
        {
            if (!serverMessage || !Game1.IsClient)
            {
                for (int y = 0; y < structureForPlacement.tilesHeight; y++)
                {
                    for (int x = 0; x < structureForPlacement.tilesWidth; x++)
                    {
                        Vector2 currentGlobalTilePosition = new Vector2(tileLocation.X + (float)x, tileLocation.Y + (float)y);
                        if (!this.isBuildable(currentGlobalTilePosition))
                        {
                            return(false);
                        }
                        for (int i = 0; i < this.farmers.Count; i++)
                        {
                            if (this.farmers[i].GetBoundingBox().Intersects(new Microsoft.Xna.Framework.Rectangle(x * Game1.tileSize, y * Game1.tileSize, Game1.tileSize, Game1.tileSize)))
                            {
                                return(false);
                            }
                        }
                    }
                }
                if (Game1.IsMultiplayer)
                {
                    MultiplayerUtility.broadcastBuildingChange(0, tileLocation, structureForPlacement.name, this.name, who.uniqueMultiplayerID);
                    if (Game1.IsClient)
                    {
                        return(false);
                    }
                }
            }
            string   name = structureForPlacement.name;
            uint     num  = < PrivateImplementationDetails >.ComputeStringHash(name);
            Building b;

            if (num <= 1972213674u)
            {
                if (num <= 846075854u)
                {
                    if (num != 45101750u)
                    {
                        if (num != 846075854u)
                        {
                            goto IL_251;
                        }
                        if (!(name == "Big Barn"))
                        {
                            goto IL_251;
                        }
                        goto IL_233;
                    }
                    else
                    {
                        if (!(name == "Stable"))
                        {
                            goto IL_251;
                        }
                        b = new Stable(structureForPlacement, tileLocation);
                        goto IL_259;
                    }
                }
                else if (num != 1684694008u)
                {
                    if (num != 1972213674u)
                    {
                        goto IL_251;
                    }
                    if (!(name == "Big Coop"))
                    {
                        goto IL_251;
                    }
                }
                else if (!(name == "Coop"))
                {
                    goto IL_251;
                }
            }
            else if (num <= 2601855023u)
            {
                if (num != 2575064728u)
                {
                    if (num != 2601855023u)
                    {
                        goto IL_251;
                    }
                    if (!(name == "Deluxe Barn"))
                    {
                        goto IL_251;
                    }
                    goto IL_233;
                }
                else
                {
                    if (!(name == "Junimo Hut"))
                    {
                        goto IL_251;
                    }
                    b = new JunimoHut(structureForPlacement, tileLocation);
                    goto IL_259;
                }
            }
            else if (num != 3183088828u)
            {
                if (num != 3734277467u)
                {
                    if (num != 3933183203u)
                    {
                        goto IL_251;
                    }
                    if (!(name == "Mill"))
                    {
                        goto IL_251;
                    }
                    b = new Mill(structureForPlacement, tileLocation);
                    goto IL_259;
                }
                else if (!(name == "Deluxe Coop"))
                {
                    goto IL_251;
                }
            }
            else
            {
                if (!(name == "Barn"))
                {
                    goto IL_251;
                }
                goto IL_233;
            }
            b = new Coop(structureForPlacement, tileLocation);
            goto IL_259;
IL_233:
            b = new Barn(structureForPlacement, tileLocation);
            goto IL_259;
IL_251:
            b = new Building(structureForPlacement, tileLocation);
IL_259:
            b.owner = who.uniqueMultiplayerID;
            string finalCheckResult = b.isThereAnythingtoPreventConstruction(this);

            if (finalCheckResult != null)
            {
                Game1.addHUDMessage(new HUDMessage(finalCheckResult, Color.Red, 3500f));
                return(false);
            }
            this.buildings.Add(b);
            b.performActionOnConstruction(this);
            return(true);
        }
        public static IDictionary <string, object> LineQuery(Character character, Container container, long cprgEid, Mill mill)
        {
            var calibrationProgram = (CalibrationProgram)container.GetItemOrThrow(cprgEid);

            var targetDefinition = calibrationProgram.TargetDefinition;

            targetDefinition.ThrowIfEqual(0, ErrorCodes.CPRGNotProducible);
            var targetDefault = EntityDefault.Get(targetDefinition);

            if (calibrationProgram.IsMissionRelated || targetDefault.CategoryFlags.IsCategory(CategoryFlags.cf_random_items))
            {
                if (mill.GetDockingBase().IsOnGammaZone())
                {
                    throw new PerpetuumException(ErrorCodes.MissionItemCantBeProducedOnGamma);
                }
            }


            calibrationProgram.HasComponents.ThrowIfFalse(ErrorCodes.CPRGNotProducible);

            var replyDict = mill.QueryMaterialAndTime(calibrationProgram, character, targetDefinition, calibrationProgram.MaterialEfficiencyPoints, calibrationProgram.TimeEfficiencyPoints);

            replyDict.Add(k.materialEfficiency, calibrationProgram.MaterialEfficiencyPoints);
            replyDict.Add(k.timeEfficiency, calibrationProgram.TimeEfficiencyPoints);

            return(replyDict);
        }
Example #31
0
 private void checkMill(int a, int b, int c, Tile movedTile, TileStatus ts,ReactiveCollection<Tile> tiles, ref Mill tofill)
 {
     if (tiles[a].Status == ts && tiles[b].Status == ts && tiles[c].Status == ts &&
         (movedTile == tiles[a] ||
          movedTile == tiles[b] ||
          movedTile == tiles[c]))
         tofill = new Mill(tiles[a], tiles[b], tiles[c]);
 }