TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches

◆ RegisterTownNPCMoodLocalizations()

static void Terraria.ModLoader.NPCLoader.RegisterTownNPCMoodLocalizations ( ModNPC npc)
inlinestaticpackage

Definition at line 361 of file NPCLoader.cs.

362 {
363 if (!npc.NPC.townNPC || NPCID.Sets.IsTownPet[npc.NPC.type] || NPCID.Sets.NoTownNPCHappiness[npc.NPC.type])
364 {
365 return;
366 }
367 string prefix = npc.GetLocalizationKey("TownNPCMood");
368 List<string> keys = new List<string> { "Content", "NoHome", "FarFromHome", "LoveSpace", "DislikeCrowded", "HateCrowded" };
369 if (Main.ShopHelper._database.TryGetProfileByNPCID(npc.NPC.type, out var personalityProfile))
370 {
373 if (biomePreferenceList != null)
374 {
375 if (biomePreferenceList.Preferences.Any((BiomePreferenceListTrait.BiomePreference x) => x.Affection == AffectionLevel.Love))
376 {
377 keys.Add("LoveBiome");
378 }
379 if (biomePreferenceList.Preferences.Any((BiomePreferenceListTrait.BiomePreference x) => x.Affection == AffectionLevel.Like))
380 {
381 keys.Add("LikeBiome");
382 }
383 if (biomePreferenceList.Preferences.Any((BiomePreferenceListTrait.BiomePreference x) => x.Affection == AffectionLevel.Dislike))
384 {
385 keys.Add("DislikeBiome");
386 }
387 if (biomePreferenceList.Preferences.Any((BiomePreferenceListTrait.BiomePreference x) => x.Affection == AffectionLevel.Hate))
388 {
389 keys.Add("HateBiome");
390 }
391 }
393 {
394 keys.Add("LoveNPC");
395 }
397 {
398 keys.Add("LikeNPC");
399 }
401 {
402 keys.Add("DislikeNPC");
403 }
405 {
406 keys.Add("HateNPC");
407 }
408 }
409 keys.Add("LikeNPC_Princess");
410 keys.Add("Princess_LovesNPC");
411 foreach (string key in keys)
412 {
413 string oldKey = npc.Mod.GetLocalizationKey("TownNPCMood." + npc.Name + "." + key);
414 if (key == "Princess_LovesNPC")
415 {
416 oldKey = "TownNPCMood_Princess.LoveNPC_" + npc.FullName;
417 }
418 string key2 = prefix + "." + key;
419 string defaultValueKey = "TownNPCMood." + key;
421 }
422 }
static bool[] NoTownNPCHappiness
If true, the given NPC will not count towards town NPC happiness and won't have a happiness button....
Definition NPCID.cs:633
static bool[] IsTownPet
If true for a given NPC type (F:Terraria.NPC.type), then that NPC is categorized as a town pet....
Definition NPCID.cs:224
static LocalizedText GetOrRegister(string key, Func< string > makeDefaultValue=null)
Returns a T:Terraria.Localization.LocalizedText for a given key. If no existing localization exists ...
Definition Language.cs:124
static bool Exists(string key)
Checks if a LocalizedText with the provided key has been registered or not. This can be used to avoid...
Definition Language.cs:76
static string GetTextValue(string key)
Retrieves the text value for a specified localization key. The text returned will be for the currentl...
Definition Language.cs:35
Contains methods to access or retrieve localization values. The Localization Guideteaches more about ...
Definition Language.cs:12

References Terraria.Localization.Language.Exists(), Terraria.ModLoader.ModType< TEntity, TModType >.FullName, Terraria.ModLoader.Mod.GetLocalizationKey(), Terraria.Localization.Language.GetOrRegister(), Terraria.Localization.Language.GetTextValue(), Terraria.ID.NPCID.Sets.IsTownPet, Terraria.ModLoader.ModType< TEntity, TModType >.Mod, Terraria.ModLoader.ModType< TEntity, TModType >.Name, Terraria.ID.NPCID.Sets.NoTownNPCHappiness, Terraria.ModLoader.ModNPC.NPC, Terraria.Main.ShopHelper, Terraria.NPC.townNPC, and Terraria.NPC.type.

Referenced by Terraria.ModLoader.NPCLoader.FinishSetup().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: