Exemplo n.º 1
0
        /// <summary>
        /// UPON HOUSE BUILT
        /// </summary>
        public static string NameHouse
            (ushort building_ID)
        {
            string roadName = NetManager.instance.GetSegmentName(Logic_Tools.GetNearestSegment_toBuilding(BuildingManager.instance.m_buildings.m_buffer[building_ID].m_position));

            Logic_Roads.AddRoad(roadName);
            ushort alpha = (ushort)(2 * (Hook_Addresses_SaveGame.CitySave.Roads.IndexOf(roadName)));

            if (Hook_Addresses_SaveGame.CitySave.Options.ConsiderRoadSide == true)
            {
                string buildingName = RenameEvenOrOdd(Logic_Tools.DetermineSideOfRoad(BuildingManager.instance.m_buildings.m_buffer[building_ID].m_position), roadName);
                Hook_Addresses_SaveGame.CitySave.ModArray[alpha].Add(Logic_Tools.AddAnotherNumber(Hook_Addresses_SaveGame.CitySave.ModArray[alpha].Min(), roadName));
                return(buildingName);
            }
            else
            {
                string buildingName = NamingPatternCheck(roadName, Hook_Addresses_SaveGame.CitySave.ModArray[alpha].Min());
                Hook_Addresses_SaveGame.CitySave.ModArray[alpha].Add(Logic_Tools.AddAnotherNumber(Hook_Addresses_SaveGame.CitySave.ModArray[alpha].Min(), roadName));
                return(buildingName);
            }
        }
Exemplo n.º 2
0
        // Upon road with new name built
        public static void AddRoad
            (string roadName)
        {
            if (Hook_Addresses_SaveGame.CitySave.Roads.Contains(roadName))
            {
                return;
            }
            else
            {
                // add road to roads List
                Hook_Addresses_SaveGame.CitySave.Roads.Add(roadName);

                // add 2 Lists (available numbers/ used numbers), add first number (usually "1") to the first (= available) List after RNG check
                List <ushort> available            = new List <ushort>();
                List <ushort> used                 = new List <ushort>();
                ushort        initialHouseNumber_1 = 1;
                ushort        initialHouseNumber_2 = 2;

                // RNG options check
                if (Hook_Addresses_SaveGame.CitySave.Options.RandomNumbers == true)
                {
                    System.Random rnd = new System.Random();
                    initialHouseNumber_1 = (ushort)rnd.Next((Hook_Addresses_SaveGame.CitySave.Options.Offset + 1), Hook_Addresses_SaveGame.CitySave.Options.RandomNumbersRange);
                    initialHouseNumber_2 = Logic_Tools.AddAnotherNumber(initialHouseNumber_1, roadName);
                }
                else
                {
                    initialHouseNumber_1 = (ushort)(Hook_Addresses_SaveGame.CitySave.Options.Offset + 1);
                    initialHouseNumber_2 = (ushort)(Hook_Addresses_SaveGame.CitySave.Options.Offset + 2);
                }
                available.Add(initialHouseNumber_1);
                available.Add(initialHouseNumber_2);
                Hook_Addresses_SaveGame.CitySave.ModArray.Add(available);
                Hook_Addresses_SaveGame.CitySave.ModArray.Add(used);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// UPON HOUSE DESTROYED
        /// </summary>
        public static void RemoveHouse
            ()
        {
            // Get link of buildings in game to modArray - List of List of strings with key : 1 to 1 to Roads array
            ushort                alpha         = (ushort)(Hook_Addresses_SaveGame.CitySave.Roads.Count());
            List <string>         roadinstance  = new List <string>();
            List <List <string> > buildingNames = new List <List <string> >();

            for (ushort i = 0; i < alpha; i++)
            {
                buildingNames.Add(roadinstance);
            }
            for (ushort i = 0; i < BuildingManager.MAX_BUILDING_COUNT; i++)
            {
                string beta = BuildingManager.instance.GetBuildingName(i, WorldInfoPanel.GetCurrentInstanceID());
                if (beta != null)
                {
                    for (ushort j = 0; j < alpha; j++)
                    {
                        if ((beta.Contains(Hook_Addresses_SaveGame.CitySave.Roads[j])))
                        {
                            buildingNames[j].Add(beta);
                        }
                    }
                }
                else
                {
                    continue;
                }
            }
            // For each List in the new List...
            for (ushort i = 0; i < alpha; i++)
            {
                // ...check if number of simulation instance buildings using numbers is equal to number of "used" numbers in mod Array
                // in order to find the ONE List where that's not true
                if (buildingNames[i].Count() == (Hook_Addresses_SaveGame.CitySave.ModArray[1 + (2 * i)].Count() + Hook_Addresses_SaveGame.CitySave.ModArray[2 * i].Count()))
                {
                    continue;
                }
                else
                {
                    // Check which number is used by a building instance
                    List <ushort> numbers_Used = new List <ushort>();
                    ushort        delta        = (ushort)(buildingNames[i].Count());
                    for (ushort j = 0; j < delta; j++)
                    {
                        ushort usedNumber = Logic_Tools.ConvertToNumber(buildingNames[i][j]);
                        numbers_Used.Add(usedNumber);
                    }

                    // For each number in the modArray...
                    ushort epsilon = (ushort)(Hook_Addresses_SaveGame.CitySave.ModArray[1 + (2 * i)].Count());
                    for (ushort j = 0; j < epsilon; j++)
                    {
                        // ...skip numbers that are found in building instances...
                        if (numbers_Used.Contains(Hook_Addresses_SaveGame.CitySave.ModArray[1 + (2 * i)][j]))
                        {
                            continue;
                        }
                        // ...until the one number is found
                        else
                        {
                            // delete number from mod array
                            Hook_Addresses_SaveGame.CitySave.ModArray[1 + (2 * i)].Remove(Hook_Addresses_SaveGame.CitySave.ModArray[1 + (2 * i)][j]);

                            // and if this was the last building on a road, delete that road from all mod arrays.
                            // When the road WASN'T deleted, it get's added back in when the first new house is built on it
                            // => Logic_Roads.AddRoad() called in Logic_Buildings.NameHouse called after the EvenOnHouseBuilt
                            if (Hook_Addresses_SaveGame.CitySave.ModArray[1 + (2 * i)].Count() == 0)
                            {
                                Logic_Roads.RemoveRoad(Hook_Addresses_SaveGame.CitySave.Roads[i]);
                            }
                            return;
                        }
                    }
                }
            }
        }