Exemple #1
0
        public static void Object_minutesElapsed_Postfix(Object __instance, int minutes, GameLocation environment)
        {
            if (__instance.name.Equals("Slime Incubator") && __instance.heldObject?.Value?.name?.EndsWith("Familiar Egg") == true && __instance.minutesUntilReady <= 0)
            {
                Vector2 v    = new Vector2((float)((int)__instance.tileLocation.X), (float)((int)__instance.tileLocation.Y + 1)) * 64f;
                string  name = __instance.heldObject.Value.name;

                if (!name.EndsWith("Familiar Egg"))
                {
                    return;
                }

                Familiar familiar = null;

                Monitor.Log($"Hatched a familiar from {__instance.heldObject.Value.name} time {Game1.timeOfDay} owner {__instance.owner}");

                long owner = __instance.owner;
                if (owner == 0)
                {
                    owner = Game1.MasterPlayer.UniqueMultiplayerID;
                }

                switch (__instance.heldObject.Value.name)
                {
                case "Dino Familiar Egg":
                    familiar = new DinoFamiliar(v, owner);
                    break;

                case "Dust Sprite Familiar Egg":
                    familiar = new DustSpriteFamiliar(v, owner);
                    break;

                case "Bat Familiar Egg":
                    familiar = new BatFamiliar(v, owner);
                    break;

                case "Junimo Familiar Egg":
                    familiar = new JunimoFamiliar(v, owner);
                    break;

                case "Butterfly Familiar Egg":
                    familiar = new ButterflyFamiliar(v, owner);
                    break;
                }

                if (familiar != null)
                {
                    Game1.showGlobalMessage(string.Format(Helper.Translation.Get("familiar-hatched"), Helper.Translation.Get(familiar.Name)));
                    familiar.setTilePosition((int)__instance.tileLocation.X, (int)__instance.tileLocation.Y + 1);
                    environment.characters.Add(familiar);
                    __instance.heldObject.Value        = null;
                    __instance.ParentSheetIndex        = 156;
                    __instance.minutesUntilReady.Value = -1;
                }
            }
        }
        public static void Object_DayUpdate_Postfix(Object __instance, GameLocation location)
        {
            if (__instance.name.Equals("Slime Incubator") && __instance.minutesUntilReady <= 0 && __instance.heldObject.Value != null)
            {
                Vector2 v    = new Vector2((float)((int)__instance.tileLocation.X), (float)((int)__instance.tileLocation.Y + 1)) * 64f;
                string  name = __instance.heldObject.Value.name;

                if (!name.EndsWith("Familiar Egg"))
                {
                    return;
                }

                Familiar familiar = null;

                switch (name)
                {
                case "Dino Familiar Egg":
                    familiar = new DinoFamiliar(v, __instance.owner);
                    break;

                case "Dust Sprite Familiar Egg":
                    familiar = new DustSpriteFamiliar(v, __instance.owner);
                    break;

                case "Bat Familiar Egg":
                    familiar = new BatFamiliar(v, __instance.owner);
                    break;

                case "Junimo Familiar Egg":
                    familiar = new JunimoFamiliar(v, __instance.owner);
                    break;

                case "Butterfly Familiar Egg":
                    familiar = new ButterflyFamiliar(v, __instance.owner);
                    break;
                }

                if (familiar != null)
                {
                    Game1.showGlobalMessage(string.Format(Helper.Translation.Get("familiar-hatched"), Helper.Translation.Get(familiar.Name)));
                    familiar.setTilePosition((int)__instance.tileLocation.X, (int)__instance.tileLocation.Y + 1);
                    location.characters.Add(familiar);
                    __instance.heldObject.Value        = null;
                    __instance.ParentSheetIndex        = 156;
                    __instance.minutesUntilReady.Value = -1;
                }
            }
        }