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

◆ LoadModBuffs()

static void Terraria.ModLoader.IO.PlayerIO.LoadModBuffs ( Player player,
IList< TagCompound > list )
inlinestaticpackage

Definition at line 307 of file PlayerIO.cs.

308 {
309 int buffCount = Player.MaxBuffs;
310 while (buffCount > 0 && player.buffType[buffCount - 1] == 0)
311 {
312 buffCount--;
313 }
314 if (buffCount == 0)
315 {
316 foreach (TagCompound tag in list)
317 {
318 if (buffCount == Player.MaxBuffs)
319 {
320 break;
321 }
322 string modName = tag.GetString("mod");
323 ModBuff buff;
324 int type = ((modName == "Terraria") ? tag.GetInt("id") : (ModContent.TryFind<ModBuff>(modName, tag.GetString("name"), out buff) ? buff.Type : 0));
325 if (type > 0)
326 {
327 player.buffType[buffCount] = type;
328 player.buffTime[buffCount] = tag.GetInt("time");
329 buffCount++;
330 }
331 }
332 return;
333 }
334 foreach (TagCompound tag2 in list.Reverse())
335 {
336 if (ModContent.TryFind<ModBuff>(tag2.GetString("mod"), tag2.GetString("name"), out var buff2))
337 {
338 int index = Math.Min(tag2.GetByte("index"), buffCount);
339 Array.Copy(player.buffType, index, player.buffType, index + 1, Player.MaxBuffs - index - 1);
340 Array.Copy(player.buffTime, index, player.buffTime, index + 1, Player.MaxBuffs - index - 1);
341 player.buffType[index] = buff2.Type;
342 player.buffTime[index] = tag2.GetInt("time");
343 }
344 }
345 }

References Terraria.Player.buffTime, Terraria.Player.buffType, Terraria.Player.MaxBuffs, and Terraria.ModLoader.ModBuff.Type.

Referenced by Terraria.ModLoader.IO.PlayerIO.Load().

+ Here is the caller graph for this function: