1 using Microsoft.Xna.Framework;
2 using Microsoft.Xna.Framework.Graphics;
4 using System.Collections.Generic;
7 using System.Linq.Expressions;
22 private static readonly IList<ModPlayer> players =
new List<ModPlayer>();
26 public int[] arr =
new int[0];
34 private static List<HookList> hooks =
new List<HookList>();
36 private static HookList AddHook<F>(Expression<Func<ModPlayer, F>> func) {
42 internal static void Add(
ModPlayer player) {
43 player.index = players.Count;
47 internal static void RebuildHooks() {
48 foreach (var hook
in hooks) {
49 hook.arr =
ModLoader.BuildGlobalHook(players, hook.method).Select(p => p.index).ToArray();
53 internal static void Unload() {
57 internal static void SetupPlayer(Player player) {
58 player.modPlayers = players.Select(modPlayer => modPlayer.CreateFor(player)).ToArray();
61 private static HookList HookResetEffects = AddHook<Action>(p => p.ResetEffects);
64 foreach (
int index
in HookResetEffects.
arr) {
65 player.modPlayers[index].ResetEffects();
69 private static HookList HookUpdateDead = AddHook<Action>(p => p.UpdateDead);
72 foreach (
int index
in HookUpdateDead.
arr) {
73 player.modPlayers[index].UpdateDead();
77 private static HookList HookSetupStartInventory = AddHook<Action<List<Item>,
bool>>(p => p.SetupStartInventory);
78 private static HookList HookSetupStartInventoryOld = AddHook<Action<List<Item>>>(p => p.SetupStartInventory);
81 IList<Item> items =
new List<Item>();
83 item.SetDefaults(3507);
87 item.SetDefaults(3509);
91 item.SetDefaults(3506);
94 if (Main.cEd && !mediumcoreDeath) {
96 item.SetDefaults(603);
99 foreach (
int index
in HookSetupStartInventory.
arr) {
100 player.modPlayers[index].SetupStartInventory(items, mediumcoreDeath);
102 foreach (
int index
in HookSetupStartInventoryOld.
arr) {
103 player.modPlayers[index].SetupStartInventory(items);
105 IDictionary<int, int> counts =
new Dictionary<int, int>();
106 foreach (
Item item0
in items) {
107 if (item0.maxStack > 1) {
108 if (!counts.ContainsKey(item0.netID)) {
109 counts[item0.netID] = 0;
111 counts[item0.netID] += item0.stack;
115 while (k < items.Count) {
117 int id = items[k].netID;
118 if (counts.ContainsKey(
id)) {
119 items[k].stack = counts[id];
120 if (items[k].stack > items[k].maxStack) {
121 items[k].stack = items[k].maxStack;
123 counts[id] -= items[k].stack;
124 if (items[k].stack <= 0) {
137 if (items.Count <= 50) {
138 for (
int k = 0; k < items.Count && k < 49; k++)
139 player.inventory[k] = items[k];
142 for (
int k = 0; k < 49; k++) {
143 player.inventory[k] = items[k];
146 bag.SetDefaults(
ModContent.ItemType<StartBag>());
147 for (
int k = 49; k < items.Count; k++) {
148 ((StartBag)bag.modItem).AddItem(items[k]);
150 player.inventory[49] = bag;
155 SetStartInventory(player, SetupStartInventory(player));
158 private static HookList HookPreSavePlayer = AddHook<Action>(p => p.PreSavePlayer);
161 foreach (
int index
in HookPreSavePlayer.
arr) {
162 player.modPlayers[index].PreSavePlayer();
166 private static HookList HookPostSavePlayer = AddHook<Action>(p => p.PostSavePlayer);
169 foreach (
int index
in HookPostSavePlayer.
arr) {
170 player.modPlayers[index].PostSavePlayer();
174 private static HookList HookUpdateBiomes = AddHook<Action>(p => p.UpdateBiomes);
177 foreach (
int index
in HookUpdateBiomes.
arr) {
178 player.modPlayers[index].UpdateBiomes();
182 private static HookList HookCustomBiomesMatch = AddHook<Func<Player, bool>>(p => p.CustomBiomesMatch);
185 foreach (
int index
in HookCustomBiomesMatch.
arr) {
186 if (!player.modPlayers[index].CustomBiomesMatch(other)) {
193 private static HookList HookCopyCustomBiomesTo = AddHook<Action<Player>>(p => p.CopyCustomBiomesTo);
196 foreach (
int index
in HookCopyCustomBiomesTo.
arr) {
197 player.modPlayers[index].CopyCustomBiomesTo(other);
201 private static HookList HookSendCustomBiomes = AddHook<Action<BinaryWriter>>(p => p.SendCustomBiomes);
206 using (MemoryStream stream =
new MemoryStream()) {
208 foreach (
int index
in HookSendCustomBiomes.
arr) {
209 if (SendCustomBiomes(player.modPlayers[index], customWriter)) {
213 customWriter.Flush();
214 data = stream.ToArray();
223 using (MemoryStream stream =
new MemoryStream()) {
226 customWriter.Flush();
227 data = stream.ToArray();
230 if (data.Length > 0) {
231 writer.Write(modPlayer.
mod.
Name);
232 writer.Write(modPlayer.
Name);
233 writer.Write((byte)data.Length);
241 int count = reader.ReadUInt16();
242 for (
int k = 0; k < count; k++) {
243 string modName = reader.ReadString();
244 string name = reader.ReadString();
245 byte[] data = reader.ReadBytes(reader.ReadByte());
247 ModPlayer modPlayer = mod == null ? null : player.GetModPlayer(mod, name);
248 if (modPlayer != null) {
249 using (MemoryStream stream =
new MemoryStream(data)) {
262 private static HookList HookUpdateBiomeVisuals = AddHook<Action>(p => p.UpdateBiomeVisuals);
265 foreach (
int index
in HookUpdateBiomeVisuals.
arr) {
266 player.modPlayers[index].UpdateBiomeVisuals();
270 private static HookList HookClientClone = AddHook<Action<ModPlayer>>(p => p.clientClone);
272 public static void clientClone(Player player, Player clientClone) {
273 foreach (
int index
in HookClientClone.
arr) {
274 player.modPlayers[index].clientClone(clientClone.modPlayers[index]);
278 private static HookList HookSyncPlayer = AddHook<Action<int, int, bool>>(p => p.SyncPlayer);
280 public static void SyncPlayer(Player player,
int toWho,
int fromWho,
bool newPlayer) {
281 foreach (
int index
in HookSyncPlayer.
arr) {
282 player.modPlayers[index].SyncPlayer(toWho, fromWho, newPlayer);
286 private static HookList HookSendClientChanges = AddHook<Action<ModPlayer>>(p => p.SendClientChanges);
289 foreach (
int index
in HookSendClientChanges.
arr) {
290 player.modPlayers[index].SendClientChanges(clientPlayer.modPlayers[index]);
294 private static HookList HookGetMapBackgroundImage = AddHook<Func<Texture2D>>(p => p.GetMapBackgroundImage);
297 Texture2D texture = null;
298 foreach (
int index
in HookGetMapBackgroundImage.
arr) {
299 texture = player.modPlayers[index].GetMapBackgroundImage();
300 if (texture != null) {
307 private static HookList HookUpdateBadLifeRegen = AddHook<Action>(p => p.UpdateBadLifeRegen);
310 foreach (
int index
in HookUpdateBadLifeRegen.
arr) {
311 player.modPlayers[index].UpdateBadLifeRegen();
315 private static HookList HookUpdateLifeRegen = AddHook<Action>(p => p.UpdateLifeRegen);
318 foreach (
int index
in HookUpdateLifeRegen.
arr) {
319 player.modPlayers[index].UpdateLifeRegen();
323 private delegate
void DelegateNaturalLifeRegen(ref
float regen);
324 private static HookList HookNaturalLifeRegen = AddHook<DelegateNaturalLifeRegen>(p => p.NaturalLifeRegen);
327 foreach (
int index
in HookNaturalLifeRegen.
arr) {
328 player.modPlayers[index].NaturalLifeRegen(ref regen);
332 private static HookList HookUpdateAutopause = AddHook<Action>(p => p.UpdateAutopause);
335 foreach (
int index
in HookUpdateAutopause.
arr) {
336 player.modPlayers[index].UpdateAutopause();
340 private static HookList HookPreUpdate = AddHook<Action>(p => p.PreUpdate);
343 foreach (
int index
in HookPreUpdate.
arr) {
344 player.modPlayers[index].PreUpdate();
348 private static HookList HookSetControls = AddHook<Action>(p => p.SetControls);
351 foreach (
int index
in HookSetControls.
arr) {
352 player.modPlayers[index].SetControls();
356 private static HookList HookPreUpdateBuffs = AddHook<Action>(p => p.PreUpdateBuffs);
359 foreach (
int index
in HookPreUpdateBuffs.
arr) {
360 player.modPlayers[index].PreUpdateBuffs();
364 private static HookList HookPostUpdateBuffs = AddHook<Action>(p => p.PostUpdateBuffs);
367 foreach (
int index
in HookPostUpdateBuffs.
arr) {
368 player.modPlayers[index].PostUpdateBuffs();
372 private delegate
void DelegateUpdateEquips(ref
bool wallSpeedBuff, ref
bool tileSpeedBuff, ref
bool tileRangeBuff);
373 private static HookList HookUpdateEquips = AddHook<DelegateUpdateEquips>(p => p.UpdateEquips);
375 public static void UpdateEquips(Player player, ref
bool wallSpeedBuff, ref
bool tileSpeedBuff, ref
bool tileRangeBuff) {
376 foreach (
int index
in HookUpdateEquips.
arr) {
377 player.modPlayers[index].UpdateEquips(ref wallSpeedBuff, ref tileSpeedBuff, ref tileRangeBuff);
381 private static HookList HookUpdateVanityAccessories = AddHook<Action>(p => p.UpdateVanityAccessories);
384 foreach (
int index
in HookUpdateVanityAccessories.
arr) {
385 player.modPlayers[index].UpdateVanityAccessories();
389 private static HookList HookPostUpdateEquips = AddHook<Action>(p => p.PostUpdateEquips);
392 foreach (
int index
in HookPostUpdateEquips.
arr) {
393 player.modPlayers[index].PostUpdateEquips();
397 private static HookList HookPostUpdateMiscEffects = AddHook<Action>(p => p.PostUpdateMiscEffects);
400 foreach (
int index
in HookPostUpdateMiscEffects.
arr) {
401 player.modPlayers[index].PostUpdateMiscEffects();
405 private static HookList HookPostUpdateRunSpeeds = AddHook<Action>(p => p.PostUpdateRunSpeeds);
408 foreach (
int index
in HookPostUpdateRunSpeeds.
arr) {
409 player.modPlayers[index].PostUpdateRunSpeeds();
413 private static HookList HookPreUpdateMovement = AddHook<Action>(p => p.PreUpdateMovement);
416 foreach (
int index
in HookPreUpdateMovement.
arr) {
417 player.modPlayers[index].PreUpdateMovement();
421 private static HookList HookPostUpdate = AddHook<Action>(p => p.PostUpdate);
424 foreach (
int index
in HookPostUpdate.
arr) {
425 player.modPlayers[index].PostUpdate();
429 private static HookList HookFrameEffects = AddHook<Action>(p => p.FrameEffects);
432 foreach (
int index
in HookFrameEffects.
arr) {
433 player.modPlayers[index].FrameEffects();
437 private delegate
bool DelegatePreHurt(
bool pvp,
bool quiet, ref
int damage, ref
int hitDirection,
438 ref
bool crit, ref
bool customDamage, ref
bool playSound, ref
bool genGore, ref PlayerDeathReason damageSource);
439 private static HookList HookPreHurt = AddHook<DelegatePreHurt>(p => p.PreHurt);
441 public static bool PreHurt(Player player,
bool pvp,
bool quiet, ref
int damage, ref
int hitDirection,
442 ref
bool crit, ref
bool customDamage, ref
bool playSound, ref
bool genGore, ref PlayerDeathReason damageSource) {
444 foreach (
int index
in HookPreHurt.
arr) {
445 if (!player.modPlayers[index].PreHurt(pvp, quiet, ref damage, ref hitDirection, ref crit, ref customDamage,
446 ref playSound, ref genGore, ref damageSource)) {
453 private static HookList HookHurt = AddHook<Action<bool, bool, double, int, bool>>(p => p.Hurt);
455 public static void Hurt(Player player,
bool pvp,
bool quiet,
double damage,
int hitDirection,
bool crit) {
456 foreach (
int index
in HookHurt.
arr) {
457 player.modPlayers[index].Hurt(pvp, quiet, damage, hitDirection, crit);
461 private static HookList HookPostHurt = AddHook<Action<bool, bool, double, int, bool>>(p => p.PostHurt);
463 public static void PostHurt(Player player,
bool pvp,
bool quiet,
double damage,
int hitDirection,
bool crit) {
464 foreach (
int index
in HookPostHurt.
arr) {
465 player.modPlayers[index].PostHurt(pvp, quiet, damage, hitDirection, crit);
469 private delegate
bool DelegatePreKill(
double damage,
int hitDirection,
bool pvp, ref
bool playSound,
470 ref
bool genGore, ref PlayerDeathReason damageSource);
471 private static HookList HookPreKill = AddHook<DelegatePreKill>(p => p.PreKill);
473 public static bool PreKill(Player player,
double damage,
int hitDirection,
bool pvp, ref
bool playSound,
474 ref
bool genGore, ref PlayerDeathReason damageSource) {
476 foreach (
int index
in HookPreKill.
arr) {
477 if (!player.modPlayers[index].PreKill(damage, hitDirection, pvp, ref playSound, ref genGore, ref damageSource)) {
484 private static HookList HookKill = AddHook<Action<double, int, bool, PlayerDeathReason>>(p => p.Kill);
486 public static void Kill(Player player,
double damage,
int hitDirection,
bool pvp, PlayerDeathReason damageSource) {
487 foreach (
int index
in HookKill.
arr) {
488 player.modPlayers[index].Kill(damage, hitDirection, pvp, damageSource);
492 private static HookList HookPreItemCheck = AddHook<Func<bool>>(p => p.PreItemCheck);
496 foreach (
int index
in HookPreItemCheck.
arr) {
497 result &= player.modPlayers[index].PreItemCheck();
502 private static HookList HookPostItemCheck = AddHook<Action>(p => p.PostItemCheck);
505 foreach (
int index
in HookPostItemCheck.
arr) {
506 player.modPlayers[index].PostItemCheck();
510 private static HookList HookUseTimeMultiplier = AddHook<Func<Item, float>>(p => p.UseTimeMultiplier);
513 float multiplier = 1f;
514 if (item.IsAir)
return multiplier;
515 foreach (
int index
in HookUseTimeMultiplier.
arr) {
516 multiplier *= player.modPlayers[index].UseTimeMultiplier(item);
525 public static int TotalUseTime(
float useTime, Player player, Item item) {
526 return Math.Max(2, (
int)(useTime / TotalUseTimeMultiplier(player, item)));
529 private static HookList HookMeleeSpeedMultiplier = AddHook<Func<Item, float>>(p => p.MeleeSpeedMultiplier);
532 float multiplier = 1f;
533 if (item.IsAir)
return multiplier;
534 foreach (
int index
in HookMeleeSpeedMultiplier.
arr) {
535 multiplier *= player.modPlayers[index].MeleeSpeedMultiplier(item);
541 return TotalUseTimeMultiplier(player, item) * MeleeSpeedMultiplier(player, item)
546 return Math.Max(2, (
int)(useAnimation / TotalMeleeSpeedMultiplier(player, item)));
549 private delegate
void DelegateGetHealLife(
Item item,
bool quickHeal, ref
int healValue);
550 private static HookList HookGetHealLife = AddHook<DelegateGetHealLife>(p => p.GetHealLife);
552 public static void GetHealLife(Player player, Item item,
bool quickHeal, ref
int healValue) {
556 foreach (
int index
in HookGetHealLife.
arr) {
557 player.modPlayers[index].GetHealLife(item, quickHeal, ref healValue);
561 private delegate
void DelegateGetHealMana(
Item item,
bool quickHeal, ref
int healValue);
562 private static HookList HookGetHealMana = AddHook<DelegateGetHealMana>(p => p.GetHealMana);
564 public static void GetHealMana(Player player, Item item,
bool quickHeal, ref
int healValue) {
568 foreach (
int index
in HookGetHealMana.
arr) {
569 player.modPlayers[index].GetHealMana(item, quickHeal, ref healValue);
573 private delegate
void DelegateModifyManaCost(
Item item, ref
float reduce, ref
float mult);
574 private static HookList HookModifyManaCost = AddHook<DelegateModifyManaCost>(p => p.ModifyManaCost);
576 public static void ModifyManaCost(Player player, Item item, ref
float reduce, ref
float mult) {
580 foreach (
int index
in HookModifyManaCost.
arr) {
581 player.modPlayers[index].ModifyManaCost(item, ref reduce, ref mult);
585 private static HookList HookOnMissingMana = AddHook<Action<Item, int>>(p => p.OnMissingMana);
587 public static void OnMissingMana(Player player, Item item,
int manaNeeded) {
591 foreach (
int index
in HookOnMissingMana.
arr) {
592 player.modPlayers[index].OnMissingMana(item, manaNeeded);
596 private static HookList HookOnConsumeMana = AddHook<Action<Item, int>>(p => p.OnConsumeMana);
598 public static void OnConsumeMana(Player player, Item item,
int manaConsumed) {
602 foreach (
int index
in HookOnConsumeMana.
arr) {
603 player.modPlayers[index].OnConsumeMana(item, manaConsumed);
607 private delegate
void DelegateGetWeaponDamage(
Item item, ref
int damage);
609 private static HookList HookGetWeaponDamage = AddHook<DelegateGetWeaponDamage>(p => p.GetWeaponDamage);
615 foreach (
int index
in HookGetWeaponDamage.
arr) {
616 player.modPlayers[index].GetWeaponDamage(item, ref damage);
620 private delegate
void DelegateModifyWeaponDamageOld(
Item item, ref
float add, ref
float mult);
621 private static HookList HookModifyWeaponDamageOld = AddHook<DelegateModifyWeaponDamage>(p => p.ModifyWeaponDamage);
622 private delegate
void DelegateModifyWeaponDamage(Item item, ref
float add, ref
float mult, ref
float flat);
623 private static HookList HookModifyWeaponDamage = AddHook<DelegateModifyWeaponDamage>(p => p.ModifyWeaponDamage);
627 public static void ModifyWeaponDamage(Player player, Item item, ref
float add, ref
float mult, ref
float flat) {
631 foreach (
int index
in HookModifyWeaponDamageOld.
arr) {
632 player.modPlayers[index].ModifyWeaponDamage(item, ref add, ref mult);
634 foreach (
int index
in HookModifyWeaponDamage.
arr) {
635 player.modPlayers[index].ModifyWeaponDamage(item, ref add, ref mult, ref flat);
639 private static HookList HookProcessTriggers = AddHook<Action<TriggersSet>>(p => p.ProcessTriggers);
642 foreach (
int index
in HookProcessTriggers.
arr) {
643 player.modPlayers[index].ProcessTriggers(triggersSet);
647 private delegate
void DelegateGetWeaponKnockback(
Item item, ref
float knockback);
648 private static HookList HookGetWeaponKnockback = AddHook<DelegateGetWeaponKnockback>(p => p.GetWeaponKnockback);
654 foreach (
int index
in HookGetWeaponKnockback.
arr) {
655 player.modPlayers[index].GetWeaponKnockback(item, ref knockback);
659 private delegate
void DelegateGetWeaponCrit(
Item item, ref
int crit);
660 private static HookList HookGetWeaponCrit = AddHook<DelegateGetWeaponCrit>(p => p.GetWeaponCrit);
663 if (item.IsAir)
return;
664 foreach (
int index
in HookGetWeaponCrit.
arr) {
665 player.modPlayers[index].GetWeaponCrit(item, ref crit);
669 private static HookList HookConsumeAmmo = AddHook<Func<Item, Item, bool>>(p => p.ConsumeAmmo);
671 public static bool ConsumeAmmo(Player player, Item weapon, Item ammo) {
672 foreach (
int index
in HookConsumeAmmo.
arr) {
673 if (!player.modPlayers[index].ConsumeAmmo(weapon, ammo)) {
680 private static HookList HookOnConsumeAmmo = AddHook<Action<Item, Item>>(p => p.OnConsumeAmmo);
683 foreach (
int index
in HookOnConsumeAmmo.
arr)
684 player.modPlayers[index].OnConsumeAmmo(weapon, ammo);
687 private delegate
bool DelegateShoot(
Item item, ref Vector2 position, ref
float speedX, ref
float speedY, ref
int type, ref
int damage, ref
float knockBack);
688 private static HookList HookShoot = AddHook<DelegateShoot>(p => p.Shoot);
690 public static bool Shoot(Player player, Item item, ref Vector2 position, ref
float speedX, ref
float speedY, ref
int type, ref
int damage, ref
float knockBack) {
691 foreach (
int index
in HookShoot.
arr) {
692 if (!player.modPlayers[index].Shoot(item, ref position, ref speedX, ref speedY, ref type, ref damage, ref knockBack)) {
699 private static HookList HookMeleeEffects = AddHook<Action<Item, Rectangle>>(p => p.MeleeEffects);
701 public static void MeleeEffects(Player player, Item item, Rectangle hitbox) {
702 foreach (
int index
in HookMeleeEffects.
arr) {
703 player.modPlayers[index].MeleeEffects(item, hitbox);
707 private static HookList HookOnHitAnything = AddHook<Action<float, float, Entity>>(p => p.OnHitAnything);
709 public static void OnHitAnything(Player player,
float x,
float y, Entity victim) {
710 foreach (
int index
in HookOnHitAnything.
arr) {
711 player.modPlayers[index].OnHitAnything(x, y, victim);
715 private static HookList HookCanHitNPC = AddHook<Func<Item, NPC, bool?>>(p => p.CanHitNPC);
717 public static bool?
CanHitNPC(Player player, Item item, NPC target) {
719 foreach (
int index
in HookCanHitNPC.
arr) {
720 bool? canHit = player.modPlayers[index].CanHitNPC(item, target);
721 if (canHit.HasValue && !canHit.Value) {
724 if (canHit.HasValue) {
731 private delegate
void DelegateModifyHitNPC(
Item item, NPC target, ref
int damage, ref
float knockback, ref
bool crit);
732 private static HookList HookModifyHitNPC = AddHook<DelegateModifyHitNPC>(p => p.ModifyHitNPC);
734 public static void ModifyHitNPC(Player player, Item item, NPC target, ref
int damage, ref
float knockback, ref
bool crit) {
735 foreach (
int index
in HookModifyHitNPC.
arr) {
736 player.modPlayers[index].ModifyHitNPC(item, target, ref damage, ref knockback, ref crit);
740 private static HookList HookOnHitNPC = AddHook<Action<Item, NPC, int, float, bool>>(p => p.OnHitNPC);
742 public static void OnHitNPC(Player player, Item item, NPC target,
int damage,
float knockback,
bool crit) {
743 foreach (
int index
in HookOnHitNPC.
arr) {
744 player.modPlayers[index].OnHitNPC(item, target, damage, knockback, crit);
748 private static HookList HookCanHitNPCWithProj = AddHook<Func<Projectile, NPC, bool?>>(p => p.CanHitNPCWithProj);
751 if (proj.npcProj || proj.trap) {
754 Player player = Main.player[proj.owner];
756 foreach (
int index
in HookCanHitNPCWithProj.
arr) {
757 bool? canHit = player.modPlayers[index].CanHitNPCWithProj(proj, target);
758 if (canHit.HasValue && !canHit.Value) {
761 if (canHit.HasValue) {
768 private delegate
void DelegateModifyHitNPCWithProj(Projectile proj, NPC target, ref
int damage, ref
float knockback, ref
bool crit, ref
int hitDirection);
769 private static HookList HookModifyHitNPCWithProj = AddHook<DelegateModifyHitNPCWithProj>(p => p.ModifyHitNPCWithProj);
771 public static void ModifyHitNPCWithProj(Projectile proj, NPC target, ref
int damage, ref
float knockback, ref
bool crit, ref
int hitDirection) {
772 if (proj.npcProj || proj.trap) {
775 Player player = Main.player[proj.owner];
776 foreach (
int index
in HookModifyHitNPCWithProj.
arr) {
777 player.modPlayers[index].ModifyHitNPCWithProj(proj, target, ref damage, ref knockback, ref crit, ref hitDirection);
781 private static HookList HookOnHitNPCWithProj = AddHook<Action<Projectile, NPC, int, float, bool>>(p => p.OnHitNPCWithProj);
783 public static void OnHitNPCWithProj(Projectile proj, NPC target,
int damage,
float knockback,
bool crit) {
784 if (proj.npcProj || proj.trap) {
787 Player player = Main.player[proj.owner];
788 foreach (
int index
in HookOnHitNPCWithProj.
arr) {
789 player.modPlayers[index].OnHitNPCWithProj(proj, target, damage, knockback, crit);
793 private static HookList HookCanHitPvp = AddHook<Func<Item, Player, bool>>(p => p.CanHitPvp);
795 public static bool CanHitPvp(Player player, Item item, Player target) {
796 foreach (
int index
in HookCanHitPvp.
arr) {
797 if (!player.modPlayers[index].CanHitPvp(item, target)) {
804 private delegate
void DelegateModifyHitPvp(
Item item, Player target, ref
int damage, ref
bool crit);
805 private static HookList HookModifyHitPvp = AddHook<DelegateModifyHitPvp>(p => p.ModifyHitPvp);
807 public static void ModifyHitPvp(Player player, Item item, Player target, ref
int damage, ref
bool crit) {
808 foreach (
int index
in HookModifyHitPvp.
arr) {
809 player.modPlayers[index].ModifyHitPvp(item, target, ref damage, ref crit);
813 private static HookList HookOnHitPvp = AddHook<Action<Item, Player, int, bool>>(p => p.OnHitPvp);
815 public static void OnHitPvp(Player player, Item item, Player target,
int damage,
bool crit) {
816 foreach (
int index
in HookOnHitPvp.
arr) {
817 player.modPlayers[index].OnHitPvp(item, target, damage, crit);
821 private static HookList HookCanHitPvpWithProj = AddHook<Func<Projectile, Player, bool>>(p => p.CanHitPvpWithProj);
824 Player player = Main.player[proj.owner];
825 foreach (
int index
in HookCanHitPvpWithProj.
arr) {
826 if (!player.modPlayers[index].CanHitPvpWithProj(proj, target)) {
833 private delegate
void DelegateModifyHitPvpWithProj(Projectile proj, Player target, ref
int damage, ref
bool crit);
834 private static HookList HookModifyHitPvpWithProj = AddHook<DelegateModifyHitPvpWithProj>(p => p.ModifyHitPvpWithProj);
837 Player player = Main.player[proj.owner];
838 foreach (
int index
in HookModifyHitPvpWithProj.
arr) {
839 player.modPlayers[index].ModifyHitPvpWithProj(proj, target, ref damage, ref crit);
843 private static HookList HookOnHitPvpWithProj = AddHook<Action<Projectile, Player, int, bool>>(p => p.OnHitPvpWithProj);
845 public static void OnHitPvpWithProj(Projectile proj, Player target,
int damage,
bool crit) {
846 Player player = Main.player[proj.owner];
847 foreach (
int index
in HookOnHitPvpWithProj.
arr) {
848 player.modPlayers[index].OnHitPvpWithProj(proj, target, damage, crit);
852 private delegate
bool DelegateCanBeHitByNPC(NPC npc, ref
int cooldownSlot);
853 private static HookList HookCanBeHitByNPC = AddHook<DelegateCanBeHitByNPC>(p => p.CanBeHitByNPC);
855 public static bool CanBeHitByNPC(Player player, NPC npc, ref
int cooldownSlot) {
856 foreach (
int index
in HookCanBeHitByNPC.
arr) {
857 if (!player.modPlayers[index].CanBeHitByNPC(npc, ref cooldownSlot)) {
864 private delegate
void DelegateModifyHitByNPC(NPC npc, ref
int damage, ref
bool crit);
865 private static HookList HookModifyHitByNPC = AddHook<DelegateModifyHitByNPC>(p => p.ModifyHitByNPC);
867 public static void ModifyHitByNPC(Player player, NPC npc, ref
int damage, ref
bool crit) {
868 foreach (
int index
in HookModifyHitByNPC.
arr) {
869 player.modPlayers[index].ModifyHitByNPC(npc, ref damage, ref crit);
873 private static HookList HookOnHitByNPC = AddHook<Action<NPC, int, bool>>(p => p.OnHitByNPC);
875 public static void OnHitByNPC(Player player, NPC npc,
int damage,
bool crit) {
876 foreach (
int index
in HookOnHitByNPC.
arr) {
877 player.modPlayers[index].OnHitByNPC(npc, damage, crit);
881 private static HookList HookCanBeHitByProjectile = AddHook<Func<Projectile, bool>>(p => p.CanBeHitByProjectile);
884 foreach (
int index
in HookCanBeHitByProjectile.
arr) {
885 if (!player.modPlayers[index].CanBeHitByProjectile(proj)) {
892 private delegate
void DelegateModifyHitByProjectile(Projectile proj, ref
int damage, ref
bool crit);
893 private static HookList HookModifyHitByProjectile = AddHook<DelegateModifyHitByProjectile>(p => p.ModifyHitByProjectile);
896 foreach (
int index
in HookModifyHitByProjectile.
arr) {
897 player.modPlayers[index].ModifyHitByProjectile(proj, ref damage, ref crit);
901 private static HookList HookOnHitByProjectile = AddHook<Action<Projectile, int, bool>>(p => p.OnHitByProjectile);
904 foreach (
int index
in HookOnHitByProjectile.
arr) {
905 player.modPlayers[index].OnHitByProjectile(proj, damage, crit);
909 private delegate
void DelegateCatchFish(
Item fishingRod,
Item bait,
int power,
int liquidType,
int poolSize,
int worldLayer,
int questFish, ref
int caughtType, ref
bool junk);
910 private static HookList HookCatchFish = AddHook<DelegateCatchFish>(p => p.CatchFish);
912 public static void CatchFish(Player player, Item fishingRod,
int power,
int liquidType,
int poolSize,
int worldLayer,
int questFish, ref
int caughtType, ref
bool junk) {
915 if (player.inventory[i].stack > 0 && player.inventory[i].bait > 0) {
920 foreach (
int index
in HookCatchFish.
arr) {
921 player.modPlayers[index].CatchFish(fishingRod, player.inventory[i], power, liquidType, poolSize, worldLayer, questFish, ref caughtType, ref junk);
925 private delegate
void DelegateGetFishingLevel(
Item fishingRod,
Item bait, ref
int fishingLevel);
926 private static HookList HookGetFishingLevel = AddHook<DelegateGetFishingLevel>(p => p.GetFishingLevel);
928 public static void GetFishingLevel(Player player, Item fishingRod, Item bait, ref
int fishingLevel) {
929 foreach (
int index
in HookGetFishingLevel.
arr) {
930 player.modPlayers[index].GetFishingLevel(fishingRod, bait, ref fishingLevel);
934 private static HookList HookAnglerQuestReward = AddHook<Action<float, List<Item>>>(p => p.AnglerQuestReward);
936 public static void AnglerQuestReward(Player player,
float rareMultiplier, List<Item> rewardItems) {
937 foreach (
int index
in HookAnglerQuestReward.
arr) {
938 player.modPlayers[index].AnglerQuestReward(rareMultiplier, rewardItems);
942 private static HookList HookGetDyeTraderReward = AddHook<Action<List<int>>>(p => p.GetDyeTraderReward);
945 foreach (
int index
in HookGetDyeTraderReward.
arr) {
946 player.modPlayers[index].GetDyeTraderReward(rewardPool);
950 private delegate
void DelegateDrawEffects(
PlayerDrawInfo drawInfo, ref
float r, ref
float g, ref
float b, ref
float a, ref
bool fullBright);
951 private static HookList HookDrawEffects = AddHook<DelegateDrawEffects>(p => p.DrawEffects);
955 foreach (
int index
in HookDrawEffects.
arr) {
956 modPlayers[index].DrawEffects(drawInfo, ref r, ref g, ref b, ref a, ref fullBright);
960 private delegate
void DelegateModifyDrawInfo(ref
PlayerDrawInfo drawInfo);
961 private static HookList HookModifyDrawInfo = AddHook<DelegateModifyDrawInfo>(p => p.ModifyDrawInfo);
964 ModPlayer[] modPlayers = drawInfo.drawPlayer.modPlayers;
965 foreach (
int index
in HookModifyDrawInfo.
arr) {
970 private static HookList HookModifyDrawLayers = AddHook<Action<List<PlayerLayer>>>(p => p.ModifyDrawLayers);
973 List<PlayerLayer> layers =
new List<PlayerLayer> {
982 if (drawPlayer.wearsRobe) {
998 if (drawPlayer.mount.Cart) {
1017 foreach (
int index
in HookModifyDrawLayers.
arr) {
1018 drawPlayer.modPlayers[index].ModifyDrawLayers(layers);
1023 private static HookList HookModifyDrawHeadLayers = AddHook<Action<List<PlayerHeadLayer>>>(p => p.ModifyDrawHeadLayers);
1026 List<PlayerHeadLayer> layers =
new List<PlayerHeadLayer> {
1036 foreach (
int index
in HookModifyDrawHeadLayers.
arr) {
1037 drawPlayer.modPlayers[index].ModifyDrawHeadLayers(layers);
1042 private static HookList HookModifyScreenPosition = AddHook<Action>(p => p.ModifyScreenPosition);
1045 foreach (
int index
in HookModifyScreenPosition.
arr) {
1046 player.modPlayers[index].ModifyScreenPosition();
1050 private delegate
void DelegateModifyZoom(ref
float zoom);
1051 private static HookList HookModifyZoom = AddHook<DelegateModifyZoom>(p => p.ModifyZoom);
1054 foreach (
int index
in HookModifyZoom.
arr) {
1055 player.modPlayers[index].ModifyZoom(ref zoom);
1059 private static HookList HookPlayerConnect = AddHook<Action<Player>>(p => p.PlayerConnect);
1062 var player = Main.player[playerIndex];
1063 foreach (
int index
in HookPlayerConnect.
arr) {
1064 player.modPlayers[index].PlayerConnect(player);
1068 private static HookList HookPlayerDisconnect = AddHook<Action<Player>>(p => p.PlayerDisconnect);
1071 var player = Main.player[playerIndex];
1072 foreach (
int index
in HookPlayerDisconnect.
arr) {
1073 player.modPlayers[index].PlayerDisconnect(player);
1077 private static HookList HookOnEnterWorld = AddHook<Action<Player>>(p => p.OnEnterWorld);
1081 var player = Main.player[playerIndex];
1082 foreach (
int index
in HookOnEnterWorld.
arr) {
1083 player.modPlayers[index].OnEnterWorld(player);
1087 private static HookList HookOnRespawn = AddHook<Action<Player>>(p => p.OnRespawn);
1090 foreach (
int index
in HookOnRespawn.
arr) {
1091 player.modPlayers[index].OnRespawn(player);
1095 private static HookList HookShiftClickSlot = AddHook<Func<Item[], int, int, bool>>(p => p.ShiftClickSlot);
1097 public static bool ShiftClickSlot(Player player, Item[] inventory,
int context,
int slot) {
1098 foreach (
int index
in HookShiftClickSlot.
arr) {
1099 if (player.modPlayers[index].ShiftClickSlot(inventory, context, slot)) {
1106 private static bool HasMethod(Type t,
string method, params Type[] args) {
1107 return t.GetMethod(method, args).DeclaringType != typeof(
ModPlayer);
1110 internal static void VerifyGlobalItem(
ModPlayer player) {
1111 var type = player.GetType();
1113 int netCustomBiomeMethods = 0;
1114 if (HasMethod(type,
"CustomBiomesMatch", typeof(Player))) netCustomBiomeMethods++;
1115 if (HasMethod(type,
"CopyCustomBiomesTo", typeof(Player))) netCustomBiomeMethods++;
1116 if (HasMethod(type,
"SendCustomBiomes", typeof(
BinaryWriter))) netCustomBiomeMethods++;
1117 if (HasMethod(type,
"ReceiveCustomBiomes", typeof(
BinaryReader))) netCustomBiomeMethods++;
1118 if (netCustomBiomeMethods > 0 && netCustomBiomeMethods < 4)
1119 throw new Exception(type +
" must override all of (CustomBiomesMatch/CopyCustomBiomesTo/SendCustomBiomes/ReceiveCustomBiomes) or none");
1121 int netClientMethods = 0;
1122 if (HasMethod(type,
"clientClone", typeof(
ModPlayer))) netClientMethods++;
1123 if (HasMethod(type,
"SyncPlayer", typeof(
int), typeof(
int), typeof(
bool))) netClientMethods++;
1124 if (HasMethod(type,
"SendClientChanges", typeof(
ModPlayer))) netClientMethods++;
1125 if (netClientMethods > 0 && netClientMethods < 3)
1126 throw new Exception(type +
" must override all of (clientClone/SyncPlayer/SendClientChanges) or none");
1128 int saveMethods = 0;
1129 if (HasMethod(type,
"Save")) saveMethods++;
1130 if (HasMethod(type,
"Load", typeof(
TagCompound))) saveMethods++;
1131 if (saveMethods == 1)
1132 throw new Exception(type +
" must override all of (Save/Load) or none");
1135 if (HasMethod(type,
"NetSend", typeof(
BinaryWriter))) netMethods++;
1136 if (HasMethod(type,
"NetReceive", typeof(
BinaryReader))) netMethods++;
1137 if (netMethods == 1)
1138 throw new Exception(type +
" must override both of (NetSend/NetReceive) or none");
1141 private static HookList HookPostSellItem = AddHook<Action<NPC, Item[], Item>>(p => p.PostSellItem);
1143 public static void PostSellItem(Player player, NPC npc, Item[] shopInventory, Item item) {
1144 foreach (
int index
in HookPostSellItem.
arr) {
1145 player.modPlayers[index].
PostSellItem(npc, shopInventory, item);
1149 private static HookList HookCanSellItem = AddHook<Func<NPC, Item[], Item, bool>>(p => p.CanSellItem);
1152 public static bool CanSellItem(Player player, NPC npc, Item[] shopInventory, Item item) {
1153 foreach (
int index
in HookCanSellItem.
arr) {
1154 if (!player.modPlayers[index].
CanSellItem(npc, shopInventory, item))
1160 private static HookList HookPostBuyItem = AddHook<Action<NPC, Item[], Item>>(p => p.PostBuyItem);
1162 public static void PostBuyItem(Player player, NPC npc, Item[] shopInventory, Item item) {
1163 foreach (
int index
in HookPostBuyItem.
arr) {
1164 player.modPlayers[index].
PostBuyItem(npc, shopInventory, item);
1168 private static HookList HookCanBuyItem = AddHook<Func<NPC, Item[], Item, bool>>(p => p.CanBuyItem);
1170 public static bool CanBuyItem(Player player, NPC npc, Item[] shopInventory, Item item) {
1171 foreach (
int index
in HookCanBuyItem.
arr) {
1172 if (!player.modPlayers[index].
CanBuyItem(npc, shopInventory, item))
1178 private delegate
bool DelegateModifyNurseHeal(NPC npc, ref
int health, ref
bool removeDebuffs, ref
string chatText);
1179 private static HookList HookModifyNurseHeal = AddHook<DelegateModifyNurseHeal>(p => p.ModifyNurseHeal);
1181 public static bool ModifyNurseHeal(Player p, NPC npc, ref
int health, ref
bool removeDebuffs, ref
string chat) {
1182 foreach (
int index
in HookModifyNurseHeal.
arr) {
1183 if (!p.modPlayers[index].ModifyNurseHeal(npc, ref health, ref removeDebuffs, ref chat))
1189 private delegate
void DelegateModifyNursePrice(NPC npc,
int health,
bool removeDebuffs, ref
int price);
1190 private static HookList HookModifyNursePrice = AddHook<DelegateModifyNursePrice>(p => p.ModifyNursePrice);
1192 public static void ModifyNursePrice(Player p, NPC npc,
int health,
bool removeDebuffs, ref
int price) {
1193 foreach (
int index
in HookModifyNursePrice.
arr) {
1194 p.modPlayers[index].ModifyNursePrice(npc, health, removeDebuffs, ref price);
1198 private static HookList HookPostNurseHeal = AddHook<Action<NPC, int, bool, int>>(p => p.PostNurseHeal);
1200 public static void PostNurseHeal(Player player, NPC npc,
int health,
bool removeDebuffs,
int price) {
1201 foreach (
int index
in HookPostNurseHeal.
arr) {
1202 player.modPlayers[index].
PostNurseHeal(npc, health, removeDebuffs, price);
static void PostUpdateRunSpeeds(Player player)
static readonly PlayerLayer Legs
Draws the player's leg armor or pants and shoes.
static int TotalUseTime(float useTime, Player player, Item item)
string Name
The name of this ModPlayer. Used for distinguishing between multiple ModPlayers added by a single Mod...
static bool PreHurt(Player player, bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource)
static void SetStartInventory(Player player, IList< Item > items)
static bool CanHitPvp(Player player, Item item, Player target)
static readonly PlayerLayer HeldProjBack
Draws the player's held projectile if it should be drawn behind the held item and arms...
static void UpdateBadLifeRegen(Player player)
A ModPlayer instance represents an extension of a Player instance. You can store fields in the ModPla...
static void OnConsumeAmmo(Player player, Item weapon, Item ammo)
static readonly PlayerLayer HeldProjFront
Draws the player's held projectile if it should be drawn in front of the held item and arms...
virtual void ModifyDrawInfo(ref PlayerDrawInfo drawInfo)
Allows you to modify the drawing parameters of the player before drawing begins.
static void PostUpdateEquips(Player player)
static bool Shoot(Player player, Item item, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
static void OnHitPvp(Player player, Item item, Player target, int damage, bool crit)
static void PostUpdate(Player player)
static void UpdateVanityAccessories(Player player)
static void OnConsumeMana(Player player, Item item, int manaConsumed)
This is where all ModPlayer hooks are gathered and called.
static void ResetEffects(Player player)
static void UpdateLifeRegen(Player player)
static readonly PlayerLayer MountFront
Draws the front textures of the player's mount. Also draws the pulley if the player is hanging on a r...
static void ModifyWeaponDamage(Player player, Item item, ref float add, ref float mult, ref float flat)
Calls ModItem.HookModifyWeaponDamage, then all GlobalItem.HookModifyWeaponDamage hooks.
static float TotalMeleeSpeedMultiplier(Player player, Item item)
static void SetStartInventory(Player player)
static readonly PlayerLayer MiscEffectsFront
Draws miscellaneous effects in front of the player.
static void PreSavePlayer(Player player)
static readonly PlayerLayer Wings
Draws the layer's wings.
static bool PreKill(Player player, double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource)
static void DrawEffects(PlayerDrawInfo drawInfo, ref float r, ref float g, ref float b, ref float a, ref bool fullBright)
static void ModifyHitByProjectile(Player player, Projectile proj, ref int damage, ref bool crit)
static void SendClientChanges(Player player, Player clientPlayer)
A struct that contains information that may help with PlayerLayer drawing.
static void ModifyHitNPCWithProj(Projectile proj, NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
static bool CanBeHitByProjectile(Player player, Projectile proj)
static void ReceiveCustomBiomes(Player player, BinaryReader reader)
static int TotalMeleeTime(float useAnimation, Player player, Item item)
static float MeleeSpeedMultiplier(Player player, Item item)
static void GetFishingLevel(Player player, Item fishingRod, Item bait, ref int fishingLevel)
static void GetHealLife(Player player, Item item, bool quickHeal, ref int healValue)
static void Kill(Player player, double damage, int hitDirection, bool pvp, PlayerDeathReason damageSource)
static void ModifyZoom(Player player, ref float zoom)
static void MeleeEffects(Player player, Item item, Rectangle hitbox)
static readonly PlayerHeadLayer FaceAcc
Draws the player's face accessory.
static void OnHitByProjectile(Player player, Projectile proj, int damage, bool crit)
static bool SendCustomBiomes(ModPlayer modPlayer, BinaryWriter writer)
static bool CustomBiomesMatch(Player player, Player other)
static readonly PlayerLayer WaistAcc
Draws the player's waist accessory.
static readonly PlayerLayer SolarShield
Draws the player's solar shield if the player has one.
static readonly PlayerLayer MountBack
Draws the back textures of the player's mount. Also draws the player's magic carpet.
static float UseTimeMultiplier(Item item, Player player)
static readonly PlayerLayer FaceAcc
Draws the player's face accessory.
virtual void PostSellItem(NPC vendor, Item[] shopInventory, Item item)
Called whenever the player sells an item to an NPC.
static void OnHitNPC(Player player, Item item, NPC target, int damage, float knockback, bool crit)
This serves as the central class which loads mods. It contains many static fields and methods related...
static bool ShiftClickSlot(Player player, Item[] inventory, int context, int slot)
static void ModifyHitPvpWithProj(Projectile proj, Player target, ref int damage, ref bool crit)
static void OnHitNPCWithProj(Projectile proj, NPC target, int damage, float knockback, bool crit)
static readonly PlayerLayer Face
Draws the player's face and eyes.
static void PostSavePlayer(Player player)
static void OnMissingMana(Player player, Item item, int manaNeeded)
static void ModifyDrawInfo(ref PlayerDrawInfo drawInfo)
static void ModifyScreenPosition(Player player)
static void PostSellItem(Player player, NPC npc, Item[] shopInventory, Item item)
static void PostNurseHeal(Player player, NPC npc, int health, bool removeDebuffs, int price)
static List< PlayerLayer > GetDrawLayers(Player drawPlayer)
static void OnRespawn(Player player)
static bool ModifyNurseHeal(Player p, NPC npc, ref int health, ref bool removeDebuffs, ref string chat)
static void OnEnterWorld(int playerIndex)
virtual void SendCustomBiomes(BinaryWriter writer)
Allows you to send custom biome information between client and server.
static void CatchFish(Player player, Item fishingRod, int power, int liquidType, int poolSize, int worldLayer, int questFish, ref int caughtType, ref bool junk)
virtual bool CanBuyItem(NPC vendor, Item[] shopInventory, Item item)
Return false to prevent a transaction. Called before the transaction.
static readonly PlayerHeadLayer Armor
Draws the player's head armor.
Mod mod
The mod that added this type of ModPlayer.
static void PlayerDisconnect(int playerIndex)
static float UseTimeMultiplier(Player player, Item item)
static readonly PlayerLayer ShieldAcc
Draws the player's shield accessory.
static float TotalUseTimeMultiplier(Player player, Item item)
static bool CanHitNPCWithProj(Projectile proj, NPC target)
static readonly PlayerLayer NeckAcc
Draws the player's neck accessory.
Manages content added by mods. Liasons between mod content and Terraria's arrays and oversees the Loa...
static readonly PlayerLayer HandOffAcc
Draws the player's hand off accessory.
static void OnHitAnything(Player player, float x, float y, Entity victim)
static bool CanHitNPC(Player player, Item item, NPC target)
Player drawPlayer
The player that is being drawn.
static void PostBuyItem(Player player, NPC npc, Item[] shopInventory, Item item)
static void SyncPlayer(Player player, int toWho, int fromWho, bool newPlayer)
static readonly PlayerLayer Body
Draws the player's body armor or shirts.
static bool CanBuyItem(Player player, NPC npc, Item[] shopInventory, Item item)
static void CopyCustomBiomesTo(Player player, Player other)
static void ModifyHitByNPC(Player player, NPC npc, ref int damage, ref bool crit)
static readonly PlayerLayer HairBack
Draws the player's hair. To be honest this layer seems kind of useless.
static void NaturalLifeRegen(Player player, ref float regen)
static void GetDyeTraderReward(Player player, List< int > rewardPool)
virtual void PostNurseHeal(NPC nurse, int health, bool removeDebuffs, int price)
Called on the Client after the player heals themselves with the Nurse NPC.
static void ProcessTriggers(Player player, TriggersSet triggersSet)
static void GetWeaponCrit(Player player, Item item, ref int crit)
static void PostUpdateBuffs(Player player)
This serves as the central class from which item-related functions are carried out. It also stores a list of mod items by ID.
static void GetWeaponDamage(Player player, Item item, ref int damage)
static void UpdateBiomeVisuals(Player player)
static void PlayerConnect(int playerIndex)
static void ModifyNursePrice(Player p, NPC npc, int health, bool removeDebuffs, ref int price)
bool visible
Whether or not this DrawLayer should be drawn. For vanilla layers, this will be set to true before al...
static readonly PlayerLayer HandOnAcc
Draws the player's hand on accessory. Also draws the player's held item if the player is in the middl...
static readonly PlayerLayer MiscEffectsBack
Draws miscellaneous effects behind the player.
static void GetHealMana(Player player, Item item, bool quickHeal, ref int healValue)
static readonly PlayerLayer HeldItem
Draws the player's held item.
static readonly PlayerLayer ShoeAcc
Draws the player's shoe accessory.
virtual void ReceiveCustomBiomes(BinaryReader reader)
Allows you to do things with the custom biome information you send between client and server...
static void FrameEffects(Player player)
static bool CanBeHitByNPC(Player player, NPC npc, ref int cooldownSlot)
static readonly PlayerHeadLayer Head
Draws the player's face and eyes.
This class represents a DrawLayer for the player's map icon, and uses PlayerDrawHeadInfo as its InfoT...
static void PostHurt(Player player, bool pvp, bool quiet, double damage, int hitDirection, bool crit)
readonly MethodInfo method
static Texture2D GetMapBackgroundImage(Player player)
static void OnHitByNPC(Player player, NPC npc, int damage, bool crit)
static void Hurt(Player player, bool pvp, bool quiet, double damage, int hitDirection, bool crit)
static bool HasMethod(Type t, string method, params Type[] args)
static readonly PlayerLayer Skin
Draws the player's body and leg skin.
static List< PlayerHeadLayer > GetDrawHeadLayers(Player drawPlayer)
static void PreUpdateMovement(Player player)
static readonly PlayerHeadLayer Hair
Draws the player's hair.
static void AnglerQuestReward(Player player, float rareMultiplier, List< Item > rewardItems)
HookList(MethodInfo method)
static bool CanSellItem(Player player, NPC npc, Item[] shopInventory, Item item)
static void PostUpdateMiscEffects(Player player)
virtual string Name
Stores the name of the mod. This name serves as the mod's identification, and also helps with saving ...
static void ModifyHitPvp(Player player, Item item, Player target, ref int damage, ref bool crit)
static void clientClone(Player player, Player clientClone)
static float MeleeSpeedMultiplier(Item item, Player player)
static void PreUpdate(Player player)
static bool CanHitPvpWithProj(Projectile proj, Player target)
Mod is an abstract class that you will override. It serves as a central place from which the mod's co...
static IList< Item > SetupStartInventory(Player player, bool mediumcoreDeath=false)
static void ModifyHitNPC(Player player, Item item, NPC target, ref int damage, ref float knockback, ref bool crit)
static void UpdateDead(Player player)
static Mod GetMod(string name)
Gets the instance of the Mod with the specified name.
virtual bool CanSellItem(NPC vendor, Item[] shopInventory, Item item)
Return false to prevent a transaction. Called before the transaction.
static readonly PlayerLayer Arms
Draws the player's arms (including the armor's arms if applicable).
static void SetControls(Player player)
static bool PreItemCheck(Player player)
static void UpdateEquips(Player player, ref bool wallSpeedBuff, ref bool tileSpeedBuff, ref bool tileRangeBuff)
static void SendCustomBiomes(Player player, BinaryWriter writer)
static readonly PlayerLayer Hair
Draws the player's hair.
static void GetWeaponKnockback(Player player, Item item, ref float knockback)
static void UpdateBiomes(Player player)
virtual void PostBuyItem(NPC vendor, Item[] shopInventory, Item item)
Called whenever the player buys an item from an NPC.
This class represents a DrawLayer for the player, and uses PlayerDrawInfo as its InfoType. Drawing should be done by adding Terraria.DataStructures.DrawData objects to Main.playerDrawData.
static readonly PlayerLayer Head
Draws the player's head armor.
static void UpdateAutopause(Player player)
static readonly PlayerHeadLayer AltHair
Draws the player's alternate (hat) hair.
static void ModifyManaCost(Player player, Item item, ref float reduce, ref float mult)
static void PreUpdateBuffs(Player player)
static void PostItemCheck(Player player)
static readonly PlayerLayer FrontAcc
Draws the player's front accessory.
static void OnHitPvpWithProj(Projectile proj, Player target, int damage, bool crit)
static readonly PlayerLayer BackAcc
Draws the player's back accessory and held item's backpack.
static bool ConsumeAmmo(Player player, Item weapon, Item ammo)
static readonly PlayerLayer BalloonAcc
Draws the player's balloon accessory.