Пример #1
0
        private void UpdateAnimations(object sender, UpdateTickedEventArgs e)
        {
            if (contentPatcher == null)
            {
                var modData = Helper.ModRegistry.Get("Pathoschild.ContentPatcher");
                contentPatcher = (StardewModdingAPI.Mod)modData.GetType().GetProperty("Mod", PrivateI | PublicI).GetValue(modData);
                var patchManager = contentPatcher.GetType().GetField("PatchManager", PrivateI).GetValue(contentPatcher);
                cpPatches = (IEnumerable)patchManager.GetType().GetField("Patches", PrivateI).GetValue(patchManager);

                CollectPatches();
            }

            ++frameCounter;
            foreach (var patch in animatedPatches)
            {
                if (!patch.Value.IsActive.Invoke() || patch.Value.Source == null || patch.Value.Target == null)
                {
                    continue;
                }

                if (frameCounter % patch.Key.AnimationFrameTime == 0)
                {
                    if (++patch.Value.CurrentFrame >= patch.Key.AnimationFrameCount)
                    {
                        patch.Value.CurrentFrame = 0;
                    }

                    var sourceRect = patch.Key.FromArea;
                    sourceRect.X += patch.Value.CurrentFrame * sourceRect.Width;
                    var cols = new Color[sourceRect.Width * sourceRect.Height];
                    patch.Value.Source.GetData(0, sourceRect, cols, 0, cols.Length);
                    patch.Value.Target.SetData(0, patch.Key.ToArea, cols, 0, cols.Length);
                }
            }
        }
Пример #2
0
        public override void Entry(IModHelper helper)
        {
            Mod.Instance = this;

            this.GreenhouseExterior = this.Helper.Content.Load <Texture2D>("assets/GreenhouseConstruction_Greenhouse.png");

            helper.Events.GameLoop.GameLaunched += this.onGameLaunched;
            helper.Events.Display.MenuChanged   += this.OnMenuChanged;
            helper.Events.Player.Warped         += this.onWarped;
            helper.Events.GameLoop.SaveLoaded   += this.FixWarps;
        }
Пример #3
0
        public InventoryPage(StardewModdingAPI.Mod mod, int xPositionOnScreen, int yPositionOnScreen, int width, int height) : base(xPositionOnScreen, yPositionOnScreen, width, height)
        {
            this.mod = mod;

            hoverAmountField         = mod.Helper.Reflection.GetField <int>(this, "hoverAmount");
            hoveredItemField         = mod.Helper.Reflection.GetField <Item>(this, "hoveredItem");
            hoverTextField           = mod.Helper.Reflection.GetField <string>(this, "hoverText");
            hoverTitleField          = mod.Helper.Reflection.GetField <string>(this, "hoverTitle");
            trashCanLidRotationField = mod.Helper.Reflection.GetField <float>(this, "trashCanLidRotation");

            drawAction = DrawModInventoryPage;
        }
Пример #4
0
        private void UpdateAnimations(object sender, UpdateTickedEventArgs e)
        {
            if (contentPatcher == null)
            {
                var modData = Helper.ModRegistry.Get("Pathoschild.ContentPatcher");
                contentPatcher = (StardewModdingAPI.Mod)modData.GetType().GetProperty("Mod", PrivateI | PublicI).GetValue(modData);
                var patchManager = contentPatcher.GetType().GetField("PatchManager", PrivateI).GetValue(contentPatcher);
                cpPatches = (IEnumerable)patchManager.GetType().GetField("Patches", PrivateI).GetValue(patchManager);

                CollectPatches();
            }

            if (findTargetsCounter > 0 && --findTargetsCounter == 0)
            {
                UpdateTargetTextures();
            }
            while (findTargetsQueue.Count > 0)
            {
                var patch = findTargetsQueue.Dequeue();
                UpdateTargetTextures(patch);
            }

            ++frameCounter;
            Game1.graphics.GraphicsDevice.Textures[0] = null;
            foreach (var patch in animatedPatches)
            {
                if (!patch.Value.IsActive.Invoke() || patch.Value.Source == null || patch.Value.Target == null)
                {
                    continue;
                }

                if (frameCounter % patch.Key.AnimationFrameTime == 0)
                {
                    if (++patch.Value.CurrentFrame >= patch.Key.AnimationFrameCount)
                    {
                        patch.Value.CurrentFrame = 0;
                    }

                    var sourceRect = patch.Value.FromAreaFunc.Invoke();
                    sourceRect.X += patch.Value.CurrentFrame * sourceRect.Width;
                    var targetRect = patch.Value.ToAreaFunc.Invoke();
                    if (targetRect == Rectangle.Empty)
                    {
                        targetRect = new Rectangle(0, 0, sourceRect.Width, sourceRect.Height);
                    }
                    var cols = new Color[sourceRect.Width * sourceRect.Height];
                    patch.Value.Source.GetData(0, sourceRect, cols, 0, cols.Length);
                    patch.Value.Target.SetData(0, targetRect, cols, 0, cols.Length);
                }
            }
        }
Пример #5
0
        public override void Entry(IModHelper helper)
        {
            instance = this;

            var modData = helper.ModRegistry.Get("Pathoschild.ContentPatcher");

            contentPatcher = (StardewModdingAPI.Mod)modData.GetType().GetProperty("Mod", PrivateI | PublicI).GetValue(modData);
            var patchManager = contentPatcher.GetType().GetField("PatchManager", PrivateI).GetValue(contentPatcher);

            cpPatches = (IEnumerable)patchManager.GetType().GetField("Patches", PrivateI).GetValue(patchManager);

            CollectPatches();

            Helper.Events.GameLoop.UpdateTicked += UpdateAnimations;
            Helper.Events.GameLoop.SaveCreated  += UpdateTargetTextures;
            Helper.Events.GameLoop.SaveLoaded   += UpdateTargetTextures;
            Helper.Events.GameLoop.DayStarted   += UpdateTargetTextures;
        }
Пример #6
0
        public JsonAssets(StardewModdingAPI.Mod mod)
        {
            Mod = mod;
            JA  = GetAssemblyByName("JsonAssets");
            if (JA == null)
            {
                Mod.Monitor.Log("Could not locate the JsonAssets assembly, mod will not be functional.", LogLevel.Warn);
                return;
            }
            JaMod = JA.GetType("JsonAssets.Mod");
            if (JaMod == null)
            {
                Mod.Monitor.Log("Could not locate the JsonAssets mod class, mod will not be functional.", LogLevel.Warn);
                return;
            }
            var i = JaMod.GetField("instance", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);

            if (i == null)
            {
                Mod.Monitor.Log("Could not locate the JsonAssets mod instance field, mod will not be functional.", LogLevel.Warn);
                return;
            }
            JaModInstance = i.GetValue(null);
            if (JaModInstance == null)
            {
                Mod.Monitor.Log("Could not locate the JsonAssets mod instance, mod will not be functional.", LogLevel.Warn);
                return;
            }
            RegisterObjectMethod = JaMod.GetMethod("RegisterObject", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
            if (RegisterObjectMethod == null)
            {
                Mod.Monitor.Log("Could not locate the JsonAssets RegisterObject function, mod will not be functional.", LogLevel.Warn);
                return;
            }
            ObjectDataType = JA.GetType("JsonAssets.Data.ObjectData");
            if (ObjectDataType == null)
            {
                Mod.Monitor.Log("Could not locate the JsonAssets ObjectData class, mod will not be functional.", LogLevel.Warn);
                return;
            }
            IsHappy = true;
        }
Пример #7
0
    public static bool FixSchedules(StardewModdingAPI.Mod __instance)
    {
        if (!Config.IsEnabled || !Config.Extras.ModPatches.PatchCustomNPCFixes)
        {
            return(true);
        }

        List <NPC?> allCharacters = Utility.getAllCharacters(new()) !;
        var         processedSet  = new ConcurrentDictionary <NPC, byte>();

        Parallel.ForEach(allCharacters, npc => {
            if (npc is null)
            {
                return;
            }
            if (npc.Schedule is not null)
            {
                return;
            }

            if (!processedSet.TryAdd(npc, 0))
            {
                return;
            }

            try {
                var schedule = npc.getSchedule(Game1.dayOfMonth);
                npc.Schedule = schedule;
                npc.checkSchedule(Game1.timeOfDay);
            }
            catch (Exception ex) {
                Debug.Warning($"CustomNPCFixes Override: Exception processing schedule for NPC '{npc.Name}'", ex);
            }
        });

        return(false);
    }