Пример #1
0
        private void ResetMarkers()
        {
            NpcMarkers = new HashSet <NpcMarker>();
            foreach (NPC npc in GetVillagers())
            {
                // Handle case where Kent appears even though he shouldn't
                if ((npc.Name.Equals("Kent") && !SecondaryNpcs["Kent"]))
                {
                    continue;
                }

                NpcMarker npcMarker = new NpcMarker()
                {
                    Npc        = npc,
                    IsBirthday = npc.isBirthday(Game1.currentSeason, Game1.dayOfMonth)
                };
                NpcMarkers.Add(npcMarker);
            }

            if (Context.IsMultiplayer)
            {
                FarmerMarkers = new Dictionary <long, FarmerMarker>();
            }
        }
 public InteractWithNpcEvent(NpcMarker marker)
 {
     Marker = marker ?? throw new ArgumentNullException(nameof(marker));
 }
Пример #3
0
        // Draw event
        // Subtractions within location vectors are to set the origin to the center of the sprite
        public void DrawMarkers(SpriteBatch b)
        {
            if (ModEntry.Globals.ShowFarmBuildings && this.FarmBuildings != null && this.BuildingMarkers != null)
            {
                var sortedBuildings = this.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(
                            this.BuildingMarkers,
                            new Vector2(
                                this.MapX + building.Value.Value.X - buildingRect.Width / 2,
                                this.MapY + building.Value.Value.Y - buildingRect.Height / 2
                                ),
                            buildingRect, Color.White, 0f, Vector2.Zero, 3f, SpriteEffects.None, 1f
                            );
                    }
                }
            }

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

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

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

                    // Skip if no specified location or should be hidden
                    if (marker.Sprite == null ||
                        ModEntry.Globals.NpcExclusions.Contains(name) ||
                        (!ModEntry.Globals.ShowHiddenVillagers && marker.IsHidden) ||
                        (this.ConditionalNpcs.ContainsKey(name) && !this.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 == CharacterType.Horse ? new Rectangle(17, 104, 16, 14) : new Rectangle(0, marker.CropOffset, 16, 15);

                    b.Draw(marker.Sprite,
                           new Rectangle(this.MapX + marker.MapX, this.MapY + marker.MapY,
                                         32, 30),
                           spriteRect, markerColor);

                    // Draw icons for quests/birthday
                    if (ModEntry.Globals.ShowQuests)
                    {
                        if (marker.IsBirthday && (Game1.player.friendshipData.ContainsKey(name) && Game1.player.friendshipData[name].GiftsToday == 0))
                        {
                            // Gift icon
                            b.Draw(Game1.mouseCursors,
                                   new Vector2(this.MapX + marker.MapX + 20, this.MapY + marker.MapY),
                                   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(this.MapX + marker.MapX + 22, this.MapY + marker.MapY - 3),
                                   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 (this.FarmerMarkers.TryGetValue(farmer.UniqueMultiplayerID, out FarmerMarker farMarker))
                    {
                        if (farMarker == null)
                        {
                            continue;
                        }
                    }
                    if (farMarker is { DrawDelay: 0 })
Пример #4
0
 public AnimationService(SkeletonAnimation skeletonAnimation, NpcMarker npc)
 {
     this.skeletonAnimation = skeletonAnimation ?? throw new ArgumentNullException(nameof(skeletonAnimation));
     this.idle = npc.idle ?? throw new ArgumentNullException(nameof(idle));
     this.npc  = npc ?? throw new ArgumentNullException(nameof(npc));
 }