Exemplo n.º 1
0
 public int GetProfessionId(string skill, string profession)
 {
     return(Skills.GetSkill(skill).Professions.Single(p => p.Id == profession).GetVanillaId());
 }
Exemplo n.º 2
0
 public string[] GetCustomSkills()
 {
     return(Skills.GetSkillList());
 }
Exemplo n.º 3
0
 public int GetLevelForCustomSkill(Farmer farmer, string skill)
 {
     return(Skills.GetSkillLevel(farmer, skill));
 }
Exemplo n.º 4
0
        /// <summary>The mod entry point, called after the mod is first loaded.</summary>
        /// <param name="helper">Provides simplified APIs for writing mods.</param>
        public override void Entry(IModHelper helper)
        {
            instance    = this;
            Log.Monitor = Monitor;
            Config      = helper.ReadConfig <Configuration>();

            helper.Events.GameLoop.UpdateTicked += onUpdate;
            helper.Events.GameLoop.SaveLoaded   += onSaveLoaded;
            helper.Events.GameLoop.Saving       += onSaving;
            helper.Events.GameLoop.Saved        += onSaved;

            Commands.register();
            Skills.init(helper.Events);
            TileSheetExtensions.init();

            harmony = HarmonyInstance.Create("spacechase0.SpaceCore");

            MethodInfo showNightEndMethod = null;

            try
            {
                Type game1CompilerType = null;
                foreach (var t in typeof(Game1).Assembly.GetTypes())
                {
                    if (t.FullName == "StardewValley.Game1+<>c")
                    {
                        game1CompilerType = t;
                    }
                }
                foreach (var m in game1CompilerType.GetRuntimeMethods())
                {
                    if (m.FullDescription().Contains("showEndOfNightStuff"))
                    {
                        showNightEndMethod = m;
                    }
                }
            }
            catch (ReflectionTypeLoadException e)
            {
                Log.error($"Weird exception doing finding Windows showEndOfNightStuff: {e}");
                foreach (var le in e.LoaderExceptions)
                {
                    Log.error("LE: " + le);
                }
            }
            catch (Exception e1)
            {
                Log.trace("Failed to find Windows showEndOfNightStuff lambda: " + e1);
                try
                {
                    Type game1CompilerType = typeof(Game1);
                    foreach (var m in game1CompilerType.GetRuntimeMethods())
                    {
                        if (m.FullDescription().Contains("<showEndOfNightStuff>m__"))
                        {
                            showNightEndMethod = m;
                        }
                    }
                }
                catch (Exception e2)
                {
                    Log.error("Failed to find Mac/Linux showEndOfNightStuff lambda: " + e2);
                }
            }
            Log.trace("showEndOfNightStuff: " + showNightEndMethod);

            doPrefix(typeof(HoeDirt), nameof(HoeDirt.dayUpdate), typeof(HoeDirtWinterFix));
            doPostfix(typeof(Utility), nameof(Utility.pickFarmEvent), typeof(NightlyFarmEventHook));
            doTranspiler(showNightEndMethod, typeof(ShowEndOfNightStuffHook).GetMethod(nameof(ShowEndOfNightStuffHook.Transpiler)));
            doPostfix(typeof(Farmer), nameof(Farmer.doneEating), typeof(DoneEatingHook));
            doPrefix(typeof(MeleeWeapon).GetMethod(nameof(MeleeWeapon.drawDuringUse), new[] { typeof(int), typeof(int), typeof(SpriteBatch), typeof(Vector2), typeof(Farmer), typeof(Rectangle), typeof(int), typeof(bool) }), typeof(CustomWeaponDrawPatch).GetMethod(nameof(CustomWeaponDrawPatch.Prefix)));
            doPrefix(typeof(Multiplayer), nameof(Multiplayer.processIncomingMessage), typeof(MultiplayerPackets));
            doPrefix(typeof(GameLocation), nameof(GameLocation.performAction), typeof(ActionHook));
            doPrefix(typeof(GameLocation), nameof(GameLocation.performTouchAction), typeof(TouchActionHook));
            doPostfix(typeof(GameLocation), nameof(GameLocation.explode), typeof(ExplodeHook));
            doPostfix(typeof(GameServer), nameof(GameServer.sendServerIntroduction), typeof(ServerGotClickHook));
            doPrefix(typeof(NPC), nameof(NPC.tryToReceiveActiveObject), typeof(BeforeReceiveObjectHook));
            doPostfix(typeof(NPC), nameof(NPC.receiveGift), typeof(AfterGiftGivenHook));
            doPostfix(typeof(Game1), nameof(Game1.loadForNewGame), typeof(BlankSaveHook));
            if (Constants.TargetPlatform != GamePlatform.Android)
            {
                doPrefix(typeof(Game1).GetMethod(nameof(Game1.warpFarmer), new[] { typeof(LocationRequest), typeof(int), typeof(int), typeof(int) }), typeof(WarpFarmerHook).GetMethod(nameof(WarpFarmerHook.Prefix)));
            }
            else
            {
                doPrefix(typeof(Game1).GetMethod(nameof(Game1.warpFarmer), new[] { typeof(LocationRequest), typeof(int), typeof(int), typeof(int), typeof(bool), typeof(bool) }), typeof(WarpFarmerHook).GetMethod(nameof(WarpFarmerHook.Prefix)));
            }
            doPostfix(typeof(GameMenu), nameof(GameMenu.getTabNumberFromName), typeof(GameMenuTabNameHook));
            doPrefix(typeof(SpriteBatch).GetMethod("Draw", new[] { typeof(Texture2D), typeof(Rectangle), typeof(Rectangle? ), typeof(Color), typeof(float), typeof(Vector2), typeof(SpriteEffects), typeof(float) }), typeof(SpriteBatchTileSheetAdjustments).GetMethod(nameof(SpriteBatchTileSheetAdjustments.Prefix1)));
            doPrefix(typeof(SpriteBatch).GetMethod("Draw", new[] { typeof(Texture2D), typeof(Rectangle), typeof(Rectangle? ), typeof(Color), }), typeof(SpriteBatchTileSheetAdjustments).GetMethod(nameof(SpriteBatchTileSheetAdjustments.Prefix2)));
            doPrefix(typeof(SpriteBatch).GetMethod("Draw", new[] { typeof(Texture2D), typeof(Vector2), typeof(Rectangle? ), typeof(Color), typeof(float), typeof(Vector2), typeof(Vector2), typeof(SpriteEffects), typeof(float) }), typeof(SpriteBatchTileSheetAdjustments).GetMethod(nameof(SpriteBatchTileSheetAdjustments.Prefix3)));
            doPrefix(typeof(SpriteBatch).GetMethod("Draw", new[] { typeof(Texture2D), typeof(Vector2), typeof(Rectangle? ), typeof(Color), typeof(float), typeof(Vector2), typeof(float), typeof(SpriteEffects), typeof(float) }), typeof(SpriteBatchTileSheetAdjustments).GetMethod(nameof(SpriteBatchTileSheetAdjustments.Prefix4)));
            doPrefix(typeof(SpriteBatch).GetMethod("Draw", new[] { typeof(Texture2D), typeof(Vector2), typeof(Rectangle? ), typeof(Color) }), typeof(SpriteBatchTileSheetAdjustments).GetMethod(nameof(SpriteBatchTileSheetAdjustments.Prefix5)));
            doPrefix(typeof(Event), nameof(Event.tryEventCommand), typeof(EventTryCommandPatch));
            doPrefix(typeof(Event), nameof(Event.checkAction), typeof(EventActionPatch));
            harmony.PatchAll();
        }
Exemplo n.º 5
0
 public static void AddCustomSkillExperience(this Farmer farmer, string skill, int amt)
 {
     Skills.AddExperience(farmer, skill, amt);
 }
Exemplo n.º 6
0
 public static int GetCustomSkillLevel(this Farmer farmer, string skill)
 {
     return(Skills.GetSkillLevel(farmer, skill));
 }
Exemplo n.º 7
0
 public static int GetCustomSkillLevel(this Farmer farmer, Skills.Skill skill)
 {
     return(Skills.GetSkillLevel(farmer, skill.Id));
 }
Exemplo n.º 8
0
 public static int GetCustomSkillExperience(this Farmer farmer, string skill)
 {
     return(Skills.GetExperienceFor(farmer, skill));
 }