示例#1
0
        static void Postfix()
        {
            if (!Settings.mod_enabled || Settings.zone_mode || !Settings.draw_overlay || Find.CurrentMap == null)
            {
                return;
            }

            try
            {
                var t = Find.Selector.SingleSelectedThing;

                if (t == null)
                {
                    return;
                }
                if (t is Plant plant)
                {
                    if (Settings.draw_overlay && KeyBindingDefOf.Misc1.JustPressed)
                    {
                        GroupMaker.TryCreateGroup(Find.CurrentMap.GetComponent <MapCompGrowthSync>(), plant, true);
                    }

                    var group = GroupsUtils.GroupOf(plant);

                    if (group != null)
                    {
                        group.Draw(0);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        static void Postfix(ref string __result, RimWorld.Plant __instance)
        {
            if (!GroupsUtils.HasGroup(__instance))
            {
                return;
            }

            var stringBuilder = new StringBuilder(__result);
            var regex         = new Regex(("GrowthRate".Translate()) + ": [0-9]+%");
            var delta         = (GroupsUtils.GetGrowthMultiplierFor(__instance) - 1f) * 100f;

            //var shownDelta = Mathf.Round()

            if (delta >= 0.5 || delta <= -0.5)
            {
                if (regex.IsMatch(__result))
                {
                    var replace = "$0 (" + delta.ToString("+##;-##") + "%)";
                    __result = regex.Replace(__result, replace);
                }
            }
#if DEBUG
            else
            {
                __result += "\n(regex error)";
            }
            __result += "\nRaw delta = " + delta.ToString();
            __result += "\nCanHaveGroup() = " + GroupMaker.CanHaveGroup(__instance, true);
#endif
        }
        public void Bir_elemanli_liste_birerli_gruplanmak_istendiginde_grup_sayisi_bir_olmalidir()
        {
            var measurements = GenerateList(1);
            var groupMaker   = new GroupMaker(1);
            var groups       = groupMaker.MakeGroup(measurements);

            Assert.AreEqual(1, groups.Count);
        }
        public void Elli_elemanli_liste_onarli_gruplanmak_istendiginde_grup_sayisi_bes_olmalidir()
        {
            var measurements = GenerateList(50);

            var groupMaker = new GroupMaker(10);
            var groups     = groupMaker.MakeGroup(measurements);

            Assert.AreEqual(5, groups.Count);
        }
        public void Alti_elemanli_liste_ikiserli_gruplanmak_istendiginde_grup_sayisi_uc_olmalidir()
        {
            var measurements = GenerateList(6);

            var groupMaker = new GroupMaker(2);
            var groups     = groupMaker.MakeGroup(measurements);

            Assert.AreEqual(3, groups.Count);
        }