private void ResetMarkers(List <NPC> villagers) { NpcMarkers = new HashSet <CharacterMarker>(); foreach (var npc in villagers) { // Handle case where Kent appears even though he shouldn't if (npc.Name.Equals("Kent") && !SecondaryNpcs["Kent"]) { continue; } if (!CustomNames.TryGetValue(npc.Name, out var npcName)) { npcName = npc.displayName ?? npc.Name; this.CustomNames.Add(npc.Name, npcName); } var npcMarker = new CharacterMarker { Npc = npc, Name = npcName, Marker = npc.Sprite.Texture, IsBirthday = npc.isBirthday(Game1.currentSeason, Game1.dayOfMonth) }; NpcMarkers.Add(npcMarker); } if (Context.IsMultiplayer) { FarmerMarkers = new Dictionary <long, CharacterMarker>(); } }
private void UpdateFarmers() { foreach (var farmer in Game1.getOnlineFarmers()) { if (farmer?.currentLocation == null) { continue; } var locationName = farmer.currentLocation.uniqueName.Value ?? farmer.currentLocation.Name; if (locationName.Contains("UndergroundMine")) { locationName = getMinesLocationName(locationName); } if ((!locationName.Contains("Cabin") && !locationName.Contains("UndergroundMine")) && !MapVectors.TryGetValue(locationName, out var loc)) { if (!alertFlags.Contains("UnknownLocation:" + locationName)) { Monitor.Log($"Unknown location: {locationName}.", LogLevel.Debug); alertFlags.Add("UnknownLocation:" + locationName); } } var farmerId = farmer.UniqueMultiplayerID; var farmerLoc = LocationToMap(farmer.currentLocation.uniqueName.Value ?? farmer.currentLocation.Name, farmer.getTileX(), farmer.getTileY(), CustomMapLocations); if (FarmerMarkers.TryGetValue(farmer.UniqueMultiplayerID, out var farMarker)) { var deltaX = farmerLoc.X - farMarker.PrevMapLocation.X; var deltaY = farmerLoc.Y - farMarker.PrevMapLocation.Y; // Location changes before tile position, causing farmhands to blink // to the wrong position upon entering new location. Handle this in draw. if (farmer.currentLocation.Name == farMarker.PrevLocationName && MathHelper.Distance(deltaX, deltaY) > 15) { FarmerMarkers[farmerId].DrawDelay = DRAW_DELAY; } else if (farMarker.DrawDelay > 0) { FarmerMarkers[farmerId].DrawDelay--; } } else { var newMarker = new CharacterMarker { Name = farmer.Name, DrawDelay = 0 }; FarmerMarkers.Add(farmerId, newMarker); } FarmerMarkers[farmerId].MapLocation = farmerLoc; FarmerMarkers[farmerId].PrevMapLocation = farmerLoc; FarmerMarkers[farmerId].PrevLocationName = farmer.currentLocation.Name; FarmerMarkers[farmerId].IsOutdoors = farmer.currentLocation.IsOutdoors; } }