예제 #1
0
        // Draw event
        // Subtractions within location vectors are to set the origin to the center of the sprite
        public void DrawMarkers(SpriteBatch b)
        {
            if (ModMain.Config.ShowFarmBuildings && FarmBuildings != null && BuildingMarkers != null)
            {
                var sortedBuildings = FarmBuildings.ToList();
                sortedBuildings.Sort((x, y) => x.Value.Value.Y.CompareTo(y.Value.Value.Y));

                foreach (KeyValuePair <string, KeyValuePair <string, Vector2> > building in sortedBuildings)
                {
                    if (ModConstants.FarmBuildingRects.TryGetValue(building.Value.Key, out Rectangle buildingRect))
                    {
                        if (Customizations.MapName == "starblue_map")
                        {
                            buildingRect.Y = 7;
                        }
                        else if (Customizations.MapName == "eemie_recolour_map")
                        {
                            buildingRect.Y = 14;
                        }
                    }

                    b.Draw(
                        BuildingMarkers,
                        new Vector2(
                            mapX + building.Value.Value.X - buildingRect.Width / 2,
                            mapY + building.Value.Value.Y - buildingRect.Height / 2
                            ),
                        new Rectangle?(buildingRect), Color.White, 0f, Vector2.Zero, 3f, SpriteEffects.None, 1f
                        );
                }
            }

            // ===== Custom locations =====
            foreach (var location in Customizations.Locations)
            {
                b.Draw(Customizations.LocationTextures, new Vector2(mapX + location.Value.LocVector.X, mapY + location.Value.LocVector.Y),
                       location.Value.SrcRect, Color.White,
                       0f,
                       Vector2.Zero, 4f, SpriteEffects.None, 0.861f);
            }

            // Traveling Merchant
            if (ModMain.Config.ShowTravelingMerchant && ConditionalNpcs["Merchant"])
            {
                Vector2 merchantLoc = new Vector2(ModConstants.MapVectors["Merchant"][0].MapX, ModConstants.MapVectors["Merchant"][0].MapY);
                b.Draw(Game1.mouseCursors, new Vector2(mapX + merchantLoc.X - 16, mapY + merchantLoc.Y - 15),
                       new Rectangle?(new Rectangle(191, 1410, 22, 21)), Color.White, 0f, Vector2.Zero, 1.3f, SpriteEffects.None,
                       1f);
            }

            // Farmers
            if (Context.IsMultiplayer)
            {
                foreach (Farmer farmer in Game1.getOnlineFarmers())
                {
                    // Temporary solution to handle desync of farmhand location/tile position when changing location
                    if (FarmerMarkers.TryGetValue(farmer.UniqueMultiplayerID, out CharacterMarker farMarker))
                    {
                        if (farMarker == null || farMarker.MapLocation.Equals(Vector2.Zero))
                        {
                            continue;
                        }
                    }
                    if (farMarker != null && farMarker.DrawDelay == 0)
                    {
                        farmer.FarmerRenderer.drawMiniPortrat(b,
                                                              new Vector2(mapX + farMarker.MapLocation.X - 16, mapY + farMarker.MapLocation.Y - 15),
                                                              0.00011f, 2f, 1, farmer);
                    }
                }
            }
            else
            {
                Vector2 playerLoc = ModMain.LocationToMap(Game1.player.currentLocation.uniqueName.Value ?? Game1.player.currentLocation.Name, Game1.player.getTileX(),
                                                          Game1.player.getTileY(), Customizations.MapVectors, true);
                if (playerLoc.X >= 0)
                {
                    Game1.player.FarmerRenderer.drawMiniPortrat(b,
                                                                new Vector2(mapX + playerLoc.X - 16, mapY + playerLoc.Y - 15), 0.00011f, 2f, 1,
                                                                Game1.player);
                }
            }

            // NPCs
            // Sort by drawing order
            if (NpcMarkers != null)
            {
                var sortedMarkers = NpcMarkers.ToList();
                sortedMarkers.Sort((x, y) => x.Layer.CompareTo(y.Layer));

                foreach (CharacterMarker npcMarker in sortedMarkers)
                {
                    // Skip if no specified location
                    if (npcMarker.MapLocation.Equals(Vector2.Zero) || npcMarker.Marker == null ||
                        !Customizations.NpcMarkerOffsets.ContainsKey(npcMarker.Npc.Name))
                    {
                        continue;
                    }

                    // Dim marker for hidden markers
                    var markerColor = npcMarker.IsHidden ? Color.DimGray * 0.7f : Color.White;

                    // Draw NPC marker
                    b.Draw(npcMarker.Marker,
                           new Rectangle((int)(mapX + npcMarker.MapLocation.X), (int)(mapY + npcMarker.MapLocation.Y),
                                         32, 30),
                           new Rectangle?(new Rectangle(0, Customizations.NpcMarkerOffsets[npcMarker.Npc.Name], 16, 15)), markerColor);

                    // Draw icons for quests/birthday
                    if (ModMain.Config.MarkQuests)
                    {
                        if (npcMarker.IsBirthday)
                        {
                            // Gift icon
                            b.Draw(Game1.mouseCursors,
                                   new Vector2(mapX + npcMarker.MapLocation.X + 20, mapY + npcMarker.MapLocation.Y),
                                   new Rectangle?(new Rectangle(147, 412, 10, 11)), markerColor, 0f, Vector2.Zero, 1.8f,
                                   SpriteEffects.None, 0f);
                        }

                        if (npcMarker.HasQuest)
                        {
                            // Quest icon
                            b.Draw(Game1.mouseCursors,
                                   new Vector2(mapX + npcMarker.MapLocation.X + 22, mapY + npcMarker.MapLocation.Y - 3),
                                   new Rectangle?(new Rectangle(403, 496, 5, 14)), markerColor, 0f, Vector2.Zero, 1.8f,
                                   SpriteEffects.None, 0f);
                        }
                    }
                }
            }
        }
예제 #2
0
        // Draw event
        // Subtractions within location vectors are to set the origin to the center of the sprite
        public void DrawMarkers(SpriteBatch b)
        {
            if (ModMain.Globals.ShowFarmBuildings && FarmBuildings != null && BuildingMarkers != null)
            {
                var sortedBuildings = FarmBuildings.ToList();
                sortedBuildings.Sort((x, y) => x.Value.Value.Y.CompareTo(y.Value.Value.Y));

                foreach (KeyValuePair <string, KeyValuePair <string, Vector2> > building in sortedBuildings)
                {
                    if (ModConstants.FarmBuildingRects.TryGetValue(building.Value.Key, out Rectangle buildingRect))
                    {
                        b.Draw(
                            BuildingMarkers,
                            new Vector2(
                                mapX + building.Value.Value.X - buildingRect.Width / 2,
                                mapY + building.Value.Value.Y - buildingRect.Height / 2
                                ),
                            new Rectangle?(buildingRect), Color.White, 0f, Vector2.Zero, 3f, SpriteEffects.None, 1f
                            );
                    }
                }
            }

            // Traveling Merchant
            if (ModMain.Config.ShowTravelingMerchant && ConditionalNpcs["Merchant"])
            {
                Vector2 merchantLoc = new Vector2(ModConstants.MapVectors["Merchant"][0].MapX, ModConstants.MapVectors["Merchant"][0].MapY);
                b.Draw(Game1.mouseCursors, new Vector2(mapX + merchantLoc.X - 16, mapY + merchantLoc.Y - 15),
                       new Rectangle?(new Rectangle(191, 1410, 22, 21)), Color.White, 0f, Vector2.Zero, 1.3f, SpriteEffects.None,
                       1f);
            }

            // NPCs
            // Sort by drawing order
            if (NpcMarkers != null)
            {
                var sortedMarkers = NpcMarkers.ToList();
                sortedMarkers.Sort((x, y) => x.Value.Layer.CompareTo(y.Value.Layer));

                foreach (var npcMarker in sortedMarkers)
                {
                    var name   = npcMarker.Key;
                    var marker = npcMarker.Value;

                    // Skip if no specified location or should be hidden
                    if (marker.Sprite == null ||
                        ModMain.Globals.NpcBlacklist.Contains(name) ||
                        (!ModMain.Config.ShowHiddenVillagers && marker.IsHidden) ||
                        (ConditionalNpcs.ContainsKey(name) && !ConditionalNpcs[name])
                        )
                    {
                        continue;
                    }

                    // Dim marker for hidden markers
                    var markerColor = marker.IsHidden ? Color.DarkGray * 0.7f : Color.White;

                    // Draw NPC marker
                    var spriteRect = marker.Type == Character.Horse ? new Rectangle(17, 104, 16, 14) : new Rectangle(0, marker.CropOffset, 16, 15);

                    b.Draw(marker.Sprite,
                           new Rectangle((int)(mapX + marker.MapX), (int)(mapY + marker.MapY),
                                         32, 30),
                           new Rectangle?(spriteRect), markerColor);

                    // Draw icons for quests/birthday
                    if (ModMain.Config.MarkQuests)
                    {
                        if (marker.IsBirthday && (Game1.player.friendshipData.ContainsKey(name) && Game1.player.friendshipData[name].GiftsToday == 0))
                        {
                            // Gift icon
                            b.Draw(Game1.mouseCursors,
                                   new Vector2(mapX + marker.MapX + 20, mapY + marker.MapY),
                                   new Rectangle?(new Rectangle(147, 412, 10, 11)), markerColor, 0f, Vector2.Zero, 1.8f,
                                   SpriteEffects.None, 0f);
                        }

                        if (marker.HasQuest)
                        {
                            // Quest icon
                            b.Draw(Game1.mouseCursors,
                                   new Vector2(mapX + marker.MapX + 22, mapY + marker.MapY - 3),
                                   new Rectangle?(new Rectangle(403, 496, 5, 14)), markerColor, 0f, Vector2.Zero, 1.8f,
                                   SpriteEffects.None, 0f);
                        }
                    }
                }
            }

            // Farmers
            if (Context.IsMultiplayer)
            {
                foreach (Farmer farmer in Game1.getOnlineFarmers())
                {
                    // Temporary solution to handle desync of farmhand location/tile position when changing location
                    if (FarmerMarkers.TryGetValue(farmer.UniqueMultiplayerID, out FarmerMarker farMarker))
                    {
                        if (farMarker == null)
                        {
                            continue;
                        }
                    }
                    if (farMarker != null && farMarker.DrawDelay == 0)
                    {
                        farmer.FarmerRenderer.drawMiniPortrat(b,
                                                              new Vector2(mapX + farMarker.MapX - 16, mapY + farMarker.MapY - 15),
                                                              0.00011f, 2f, 1, farmer);
                    }
                }
            }
            else
            {
                Vector2 playerLoc = ModMain.LocationToMap(Game1.player.currentLocation.uniqueName.Value ?? Game1.player.currentLocation.Name, Game1.player.getTileX(),
                                                          Game1.player.getTileY(), Customizations.MapVectors, Customizations.LocationBlacklist, true);

                Game1.player.FarmerRenderer.drawMiniPortrat(b,
                                                            new Vector2(mapX + playerLoc.X - 16, mapY + playerLoc.Y - 15), 0.00011f, 2f, 1,
                                                            Game1.player);
            }
        }