protected override void OnEntityAdded(EntityWrapper entity) { if (!Settings.Enable || alertTexts.ContainsKey(entity)) { return; } if (entity.IsAlive && entity.HasComponent <Monster>()) { string text = entity.Path; if (text.Contains('@')) { text = text.Split('@')[0]; } MonsterConfigLine monsterConfigLine = null; if (typeAlerts.ContainsKey(text)) { monsterConfigLine = typeAlerts[text]; AlertHandler(monsterConfigLine, entity); } else { string modAlert = entity.GetComponent <ObjectMagicProperties>().Mods.FirstOrDefault(x => modAlerts.ContainsKey(x)); if (modAlert != null) { monsterConfigLine = modAlerts[modAlert]; AlertHandler(monsterConfigLine, entity); } } MapIcon mapIcon = GetMapIconForMonster(entity, monsterConfigLine); if (mapIcon != null) { CurrentIcons[entity] = mapIcon; } } }
private MapIcon GetMapIconForMonster(EntityWrapper entity, MonsterConfigLine monsterConfigLine) { // If ignored entity found, skip foreach (string _entity in IgnoreEntitiesList) { if (entity.Path.Contains(_entity)) { return(null); } } if (!entity.IsHostile) { return(new CreatureMapIcon(entity, "ms-cyan.png", () => Settings.Minions, Settings.MinionsIcon)); } MonsterRarity monsterRarity = entity.GetComponent <ObjectMagicProperties>().Rarity; Func <EntityWrapper, Func <string, string>, CreatureMapIcon> iconCreator; string overrideIcon = null; var life = entity.GetComponent <Life>(); if (life.HasBuff("hidden_monster")) { overrideIcon = HiddenIcons[(int)monsterRarity]; } return(iconCreators.TryGetValue(monsterRarity, out iconCreator) ? iconCreator(entity, text => monsterConfigLine?.MinimapIcon ?? overrideIcon ?? text) : null); }
private MapIcon GetMapIconForMonster(EntityWrapper entity, MonsterConfigLine monsterConfigLine) { if (!entity.IsHostile) { return(new CreatureMapIcon(entity, "ms-cyan.png", () => Settings.Minions, 4)); } MonsterRarity monsterRarity = entity.GetComponent <ObjectMagicProperties>().Rarity; Func <EntityWrapper, Func <string, string>, CreatureMapIcon> iconCreator; return(iconCreators.TryGetValue(monsterRarity, out iconCreator) ? iconCreator(entity, text => monsterConfigLine?.MinimapIcon ?? text) : null); }
new public Dictionary <string, MonsterConfigLine> LoadConfig(string path) { return(LoadConfigBase(path, 4).ToDictionary(line => line[0], line => { var monsterConfigLine = new MonsterConfigLine { Text = line[1], SoundFile = line.ConfigValueExtractor(2), Color = line.ConfigColorValueExtractor(3) }; if (!String.IsNullOrEmpty(monsterConfigLine.SoundFile)) { Sounds.AddSound(monsterConfigLine.SoundFile); } return monsterConfigLine; })); }
public Dictionary <string, MonsterConfigLine> LoadConfig(string path) { return(LoadConfigBase(path, 5).ToDictionary(line => line[0], line => { var monsterConfigLine = new MonsterConfigLine { Text = line[1], SoundFile = line.ConfigValueExtractor(2), Color = line.ConfigColorValueExtractor(3), MinimapIcon = line.ConfigValueExtractor(4) }; if (monsterConfigLine.SoundFile != null) { Sounds.AddSound(monsterConfigLine.SoundFile); } return monsterConfigLine; })); }
private void AlertHandler(MonsterConfigLine monsterConfigLine, EntityWrapper entity) { alertTexts.Add(entity, monsterConfigLine); PlaySound(entity, monsterConfigLine.SoundFile); }