tModLoader v0.11.8.9
A mod to make and play Terraria mods
PlayerHooks.cs
Go to the documentation of this file.
1using Microsoft.Xna.Framework;
2using Microsoft.Xna.Framework.Graphics;
3using System;
4using System.Collections.Generic;
5using System.IO;
6using System.Linq;
7using System.Linq.Expressions;
8using System.Reflection;
9using Terraria.DataStructures;
10using Terraria.GameInput;
11using Terraria.ModLoader.Default;
13
14namespace Terraria.ModLoader
15{
16 //todo: further documentation
20 public static class PlayerHooks
21 {
22 private static readonly IList<ModPlayer> players = new List<ModPlayer>();
23
24 private class HookList
25 {
26 public int[] arr = new int[0];
27 public readonly MethodInfo method;
28
29 public HookList(MethodInfo method) {
30 this.method = method;
31 }
32 }
33
34 private static List<HookList> hooks = new List<HookList>();
35
36 private static HookList AddHook<F>(Expression<Func<ModPlayer, F>> func) {
37 var hook = new HookList(ModLoader.Method(func));
38 hooks.Add(hook);
39 return hook;
40 }
41
42 internal static void Add(ModPlayer player) {
43 player.index = players.Count;
44 players.Add(player);
45 }
46
47 internal static void RebuildHooks() {
48 foreach (var hook in hooks) {
49 hook.arr = ModLoader.BuildGlobalHook(players, hook.method).Select(p => p.index).ToArray();
50 }
51 }
52
53 internal static void Unload() {
54 players.Clear();
55 }
56
57 internal static void SetupPlayer(Player player) {
58 player.modPlayers = players.Select(modPlayer => modPlayer.CreateFor(player)).ToArray();
59 }
60
61 private static HookList HookResetEffects = AddHook<Action>(p => p.ResetEffects);
62
63 public static void ResetEffects(Player player) {
64 foreach (int index in HookResetEffects.arr) {
65 player.modPlayers[index].ResetEffects();
66 }
67 }
68
69 private static HookList HookUpdateDead = AddHook<Action>(p => p.UpdateDead);
70
71 public static void UpdateDead(Player player) {
72 foreach (int index in HookUpdateDead.arr) {
73 player.modPlayers[index].UpdateDead();
74 }
75 }
76
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);
79
80 public static IList<Item> SetupStartInventory(Player player, bool mediumcoreDeath = false) {
81 IList<Item> items = new List<Item>();
82 Item item = new Item();
83 item.SetDefaults(3507);
84 item.Prefix(-1);
85 items.Add(item);
86 item = new Item();
87 item.SetDefaults(3509);
88 item.Prefix(-1);
89 items.Add(item);
90 item = new Item();
91 item.SetDefaults(3506);
92 item.Prefix(-1);
93 items.Add(item);
94 if (Main.cEd && !mediumcoreDeath) {
95 item = new Item();
96 item.SetDefaults(603);
97 items.Add(item);
98 }
99 foreach (int index in HookSetupStartInventory.arr) {
100 player.modPlayers[index].SetupStartInventory(items, mediumcoreDeath);
101 }
102 foreach (int index in HookSetupStartInventoryOld.arr) {
103 player.modPlayers[index].SetupStartInventory(items);
104 }
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;
110 }
111 counts[item0.netID] += item0.stack;
112 }
113 }
114 int k = 0;
115 while (k < items.Count) {
116 bool flag = true;
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;
122 }
123 counts[id] -= items[k].stack;
124 if (items[k].stack <= 0) {
125 items.RemoveAt(k);
126 flag = false;
127 }
128 }
129 if (flag) {
130 k++;
131 }
132 }
133 return items;
134 }
135
136 public static void SetStartInventory(Player player, IList<Item> items) {
137 if (items.Count <= 50) {
138 for (int k = 0; k < items.Count && k < 49; k++)
139 player.inventory[k] = items[k];
140 }
141 else {
142 for (int k = 0; k < 49; k++) {
143 player.inventory[k] = items[k];
144 }
145 Item bag = new Item();
146 bag.SetDefaults(ModContent.ItemType<StartBag>());
147 for (int k = 49; k < items.Count; k++) {
148 ((StartBag)bag.modItem).AddItem(items[k]);
149 }
150 player.inventory[49] = bag;
151 }
152 }
153
154 public static void SetStartInventory(Player player) {
155 SetStartInventory(player, SetupStartInventory(player));
156 }
157
158 private static HookList HookPreSavePlayer = AddHook<Action>(p => p.PreSavePlayer);
159
160 public static void PreSavePlayer(Player player) {
161 foreach (int index in HookPreSavePlayer.arr) {
162 player.modPlayers[index].PreSavePlayer();
163 }
164 }
165
166 private static HookList HookPostSavePlayer = AddHook<Action>(p => p.PostSavePlayer);
167
168 public static void PostSavePlayer(Player player) {
169 foreach (int index in HookPostSavePlayer.arr) {
170 player.modPlayers[index].PostSavePlayer();
171 }
172 }
173
174 private static HookList HookUpdateBiomes = AddHook<Action>(p => p.UpdateBiomes);
175
176 public static void UpdateBiomes(Player player) {
177 foreach (int index in HookUpdateBiomes.arr) {
178 player.modPlayers[index].UpdateBiomes();
179 }
180 }
181
182 private static HookList HookCustomBiomesMatch = AddHook<Func<Player, bool>>(p => p.CustomBiomesMatch);
183
184 public static bool CustomBiomesMatch(Player player, Player other) {
185 foreach (int index in HookCustomBiomesMatch.arr) {
186 if (!player.modPlayers[index].CustomBiomesMatch(other)) {
187 return false;
188 }
189 }
190 return true;
191 }
192
193 private static HookList HookCopyCustomBiomesTo = AddHook<Action<Player>>(p => p.CopyCustomBiomesTo);
194
195 public static void CopyCustomBiomesTo(Player player, Player other) {
196 foreach (int index in HookCopyCustomBiomesTo.arr) {
197 player.modPlayers[index].CopyCustomBiomesTo(other);
198 }
199 }
200
201 private static HookList HookSendCustomBiomes = AddHook<Action<BinaryWriter>>(p => p.SendCustomBiomes);
202
203 public static void SendCustomBiomes(Player player, BinaryWriter writer) {
204 ushort count = 0;
205 byte[] data;
206 using (MemoryStream stream = new MemoryStream()) {
207 using (BinaryWriter customWriter = new BinaryWriter(stream)) {
208 foreach (int index in HookSendCustomBiomes.arr) {
209 if (SendCustomBiomes(player.modPlayers[index], customWriter)) {
210 count++;
211 }
212 }
213 customWriter.Flush();
214 data = stream.ToArray();
215 }
216 }
217 writer.Write(count);
218 writer.Write(data);
219 }
220
221 private static bool SendCustomBiomes(ModPlayer modPlayer, BinaryWriter writer) {
222 byte[] data;
223 using (MemoryStream stream = new MemoryStream()) {
224 using (BinaryWriter customWriter = new BinaryWriter(stream)) {
225 modPlayer.SendCustomBiomes(customWriter);
226 customWriter.Flush();
227 data = stream.ToArray();
228 }
229 }
230 if (data.Length > 0) {
231 writer.Write(modPlayer.mod.Name);
232 writer.Write(modPlayer.Name);
233 writer.Write((byte)data.Length);
234 writer.Write(data);
235 return true;
236 }
237 return false;
238 }
239
240 public static void ReceiveCustomBiomes(Player player, BinaryReader reader) {
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());
246 Mod mod = ModLoader.GetMod(modName);
247 ModPlayer modPlayer = mod == null ? null : player.GetModPlayer(mod, name);
248 if (modPlayer != null) {
249 using (MemoryStream stream = new MemoryStream(data)) {
250 using (BinaryReader customReader = new BinaryReader(stream)) {
251 try {
252 modPlayer.ReceiveCustomBiomes(customReader);
253 }
254 catch {
255 }
256 }
257 }
258 }
259 }
260 }
261
262 private static HookList HookUpdateBiomeVisuals = AddHook<Action>(p => p.UpdateBiomeVisuals);
263
264 public static void UpdateBiomeVisuals(Player player) {
265 foreach (int index in HookUpdateBiomeVisuals.arr) {
266 player.modPlayers[index].UpdateBiomeVisuals();
267 }
268 }
269
270 private static HookList HookClientClone = AddHook<Action<ModPlayer>>(p => p.clientClone);
271
272 public static void clientClone(Player player, Player clientClone) {
273 foreach (int index in HookClientClone.arr) {
274 player.modPlayers[index].clientClone(clientClone.modPlayers[index]);
275 }
276 }
277
278 private static HookList HookSyncPlayer = AddHook<Action<int, int, bool>>(p => p.SyncPlayer);
279
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);
283 }
284 }
285
286 private static HookList HookSendClientChanges = AddHook<Action<ModPlayer>>(p => p.SendClientChanges);
287
288 public static void SendClientChanges(Player player, Player clientPlayer) {
289 foreach (int index in HookSendClientChanges.arr) {
290 player.modPlayers[index].SendClientChanges(clientPlayer.modPlayers[index]);
291 }
292 }
293
294 private static HookList HookGetMapBackgroundImage = AddHook<Func<Texture2D>>(p => p.GetMapBackgroundImage);
295
296 public static Texture2D GetMapBackgroundImage(Player player) {
297 Texture2D texture = null;
298 foreach (int index in HookGetMapBackgroundImage.arr) {
299 texture = player.modPlayers[index].GetMapBackgroundImage();
300 if (texture != null) {
301 return texture;
302 }
303 }
304 return texture;
305 }
306
307 private static HookList HookUpdateBadLifeRegen = AddHook<Action>(p => p.UpdateBadLifeRegen);
308
309 public static void UpdateBadLifeRegen(Player player) {
310 foreach (int index in HookUpdateBadLifeRegen.arr) {
311 player.modPlayers[index].UpdateBadLifeRegen();
312 }
313 }
314
315 private static HookList HookUpdateLifeRegen = AddHook<Action>(p => p.UpdateLifeRegen);
316
317 public static void UpdateLifeRegen(Player player) {
318 foreach (int index in HookUpdateLifeRegen.arr) {
319 player.modPlayers[index].UpdateLifeRegen();
320 }
321 }
322
323 private delegate void DelegateNaturalLifeRegen(ref float regen);
324 private static HookList HookNaturalLifeRegen = AddHook<DelegateNaturalLifeRegen>(p => p.NaturalLifeRegen);
325
326 public static void NaturalLifeRegen(Player player, ref float regen) {
327 foreach (int index in HookNaturalLifeRegen.arr) {
328 player.modPlayers[index].NaturalLifeRegen(ref regen);
329 }
330 }
331
332 private static HookList HookUpdateAutopause = AddHook<Action>(p => p.UpdateAutopause);
333
334 public static void UpdateAutopause(Player player) {
335 foreach (int index in HookUpdateAutopause.arr) {
336 player.modPlayers[index].UpdateAutopause();
337 }
338 }
339
340 private static HookList HookPreUpdate = AddHook<Action>(p => p.PreUpdate);
341
342 public static void PreUpdate(Player player) {
343 foreach (int index in HookPreUpdate.arr) {
344 player.modPlayers[index].PreUpdate();
345 }
346 }
347
348 private static HookList HookSetControls = AddHook<Action>(p => p.SetControls);
349
350 public static void SetControls(Player player) {
351 foreach (int index in HookSetControls.arr) {
352 player.modPlayers[index].SetControls();
353 }
354 }
355
356 private static HookList HookPreUpdateBuffs = AddHook<Action>(p => p.PreUpdateBuffs);
357
358 public static void PreUpdateBuffs(Player player) {
359 foreach (int index in HookPreUpdateBuffs.arr) {
360 player.modPlayers[index].PreUpdateBuffs();
361 }
362 }
363
364 private static HookList HookPostUpdateBuffs = AddHook<Action>(p => p.PostUpdateBuffs);
365
366 public static void PostUpdateBuffs(Player player) {
367 foreach (int index in HookPostUpdateBuffs.arr) {
368 player.modPlayers[index].PostUpdateBuffs();
369 }
370 }
371
372 private delegate void DelegateUpdateEquips(ref bool wallSpeedBuff, ref bool tileSpeedBuff, ref bool tileRangeBuff);
373 private static HookList HookUpdateEquips = AddHook<DelegateUpdateEquips>(p => p.UpdateEquips);
374
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);
378 }
379 }
380
381 private static HookList HookUpdateVanityAccessories = AddHook<Action>(p => p.UpdateVanityAccessories);
382
383 public static void UpdateVanityAccessories(Player player) {
384 foreach (int index in HookUpdateVanityAccessories.arr) {
385 player.modPlayers[index].UpdateVanityAccessories();
386 }
387 }
388
389 private static HookList HookPostUpdateEquips = AddHook<Action>(p => p.PostUpdateEquips);
390
391 public static void PostUpdateEquips(Player player) {
392 foreach (int index in HookPostUpdateEquips.arr) {
393 player.modPlayers[index].PostUpdateEquips();
394 }
395 }
396
397 private static HookList HookPostUpdateMiscEffects = AddHook<Action>(p => p.PostUpdateMiscEffects);
398
399 public static void PostUpdateMiscEffects(Player player) {
400 foreach (int index in HookPostUpdateMiscEffects.arr) {
401 player.modPlayers[index].PostUpdateMiscEffects();
402 }
403 }
404
405 private static HookList HookPostUpdateRunSpeeds = AddHook<Action>(p => p.PostUpdateRunSpeeds);
406
407 public static void PostUpdateRunSpeeds(Player player) {
408 foreach (int index in HookPostUpdateRunSpeeds.arr) {
409 player.modPlayers[index].PostUpdateRunSpeeds();
410 }
411 }
412
413 private static HookList HookPreUpdateMovement = AddHook<Action>(p => p.PreUpdateMovement);
414
415 public static void PreUpdateMovement(Player player) {
416 foreach (int index in HookPreUpdateMovement.arr) {
417 player.modPlayers[index].PreUpdateMovement();
418 }
419 }
420
421 private static HookList HookPostUpdate = AddHook<Action>(p => p.PostUpdate);
422
423 public static void PostUpdate(Player player) {
424 foreach (int index in HookPostUpdate.arr) {
425 player.modPlayers[index].PostUpdate();
426 }
427 }
428
429 private static HookList HookFrameEffects = AddHook<Action>(p => p.FrameEffects);
430
431 public static void FrameEffects(Player player) {
432 foreach (int index in HookFrameEffects.arr) {
433 player.modPlayers[index].FrameEffects();
434 }
435 }
436
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);
440
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) {
443 bool flag = true;
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)) {
447 flag = false;
448 }
449 }
450 return flag;
451 }
452
453 private static HookList HookHurt = AddHook<Action<bool, bool, double, int, bool>>(p => p.Hurt);
454
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);
458 }
459 }
460
461 private static HookList HookPostHurt = AddHook<Action<bool, bool, double, int, bool>>(p => p.PostHurt);
462
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);
466 }
467 }
468
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);
472
473 public static bool PreKill(Player player, double damage, int hitDirection, bool pvp, ref bool playSound,
474 ref bool genGore, ref PlayerDeathReason damageSource) {
475 bool flag = true;
476 foreach (int index in HookPreKill.arr) {
477 if (!player.modPlayers[index].PreKill(damage, hitDirection, pvp, ref playSound, ref genGore, ref damageSource)) {
478 flag = false;
479 }
480 }
481 return flag;
482 }
483
484 private static HookList HookKill = AddHook<Action<double, int, bool, PlayerDeathReason>>(p => p.Kill);
485
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);
489 }
490 }
491
492 private static HookList HookPreItemCheck = AddHook<Func<bool>>(p => p.PreItemCheck);
493
494 public static bool PreItemCheck(Player player) {
495 bool result = true;
496 foreach (int index in HookPreItemCheck.arr) {
497 result &= player.modPlayers[index].PreItemCheck();
498 }
499 return result;
500 }
501
502 private static HookList HookPostItemCheck = AddHook<Action>(p => p.PostItemCheck);
503
504 public static void PostItemCheck(Player player) {
505 foreach (int index in HookPostItemCheck.arr) {
506 player.modPlayers[index].PostItemCheck();
507 }
508 }
509
510 private static HookList HookUseTimeMultiplier = AddHook<Func<Item, float>>(p => p.UseTimeMultiplier);
511
512 public static float UseTimeMultiplier(Player player, Item item) {
513 float multiplier = 1f;
514 if (item.IsAir) return multiplier;
515 foreach (int index in HookUseTimeMultiplier.arr) {
516 multiplier *= player.modPlayers[index].UseTimeMultiplier(item);
517 }
518 return multiplier;
519 }
520
521 public static float TotalUseTimeMultiplier(Player player, Item item) {
522 return UseTimeMultiplier(player, item) * ItemLoader.UseTimeMultiplier(item, player);
523 }
524
525 public static int TotalUseTime(float useTime, Player player, Item item) {
526 return Math.Max(2, (int)(useTime / TotalUseTimeMultiplier(player, item)));
527 }
528
529 private static HookList HookMeleeSpeedMultiplier = AddHook<Func<Item, float>>(p => p.MeleeSpeedMultiplier);
530
531 public static float MeleeSpeedMultiplier(Player player, Item item) {
532 float multiplier = 1f;
533 if (item.IsAir) return multiplier;
534 foreach (int index in HookMeleeSpeedMultiplier.arr) {
535 multiplier *= player.modPlayers[index].MeleeSpeedMultiplier(item);
536 }
537 return multiplier;
538 }
539
540 public static float TotalMeleeSpeedMultiplier(Player player, Item item) {
541 return TotalUseTimeMultiplier(player, item) * MeleeSpeedMultiplier(player, item)
542 * ItemLoader.MeleeSpeedMultiplier(item, player);
543 }
544
545 public static int TotalMeleeTime(float useAnimation, Player player, Item item) {
546 return Math.Max(2, (int)(useAnimation / TotalMeleeSpeedMultiplier(player, item)));
547 }
548
549 private delegate void DelegateGetHealLife(Item item, bool quickHeal, ref int healValue);
550 private static HookList HookGetHealLife = AddHook<DelegateGetHealLife>(p => p.GetHealLife);
551
552 public static void GetHealLife(Player player, Item item, bool quickHeal, ref int healValue) {
553 if (item.IsAir)
554 return;
555
556 foreach (int index in HookGetHealLife.arr) {
557 player.modPlayers[index].GetHealLife(item, quickHeal, ref healValue);
558 }
559 }
560
561 private delegate void DelegateGetHealMana(Item item, bool quickHeal, ref int healValue);
562 private static HookList HookGetHealMana = AddHook<DelegateGetHealMana>(p => p.GetHealMana);
563
564 public static void GetHealMana(Player player, Item item, bool quickHeal, ref int healValue) {
565 if (item.IsAir)
566 return;
567
568 foreach (int index in HookGetHealMana.arr) {
569 player.modPlayers[index].GetHealMana(item, quickHeal, ref healValue);
570 }
571 }
572
573 private delegate void DelegateModifyManaCost(Item item, ref float reduce, ref float mult);
574 private static HookList HookModifyManaCost = AddHook<DelegateModifyManaCost>(p => p.ModifyManaCost);
575
576 public static void ModifyManaCost(Player player, Item item, ref float reduce, ref float mult) {
577 if (item.IsAir)
578 return;
579
580 foreach (int index in HookModifyManaCost.arr) {
581 player.modPlayers[index].ModifyManaCost(item, ref reduce, ref mult);
582 }
583 }
584
585 private static HookList HookOnMissingMana = AddHook<Action<Item, int>>(p => p.OnMissingMana);
586
587 public static void OnMissingMana(Player player, Item item, int manaNeeded) {
588 if (item.IsAir)
589 return;
590
591 foreach (int index in HookOnMissingMana.arr) {
592 player.modPlayers[index].OnMissingMana(item, manaNeeded);
593 }
594 }
595
596 private static HookList HookOnConsumeMana = AddHook<Action<Item, int>>(p => p.OnConsumeMana);
597
598 public static void OnConsumeMana(Player player, Item item, int manaConsumed) {
599 if (item.IsAir)
600 return;
601
602 foreach (int index in HookOnConsumeMana.arr) {
603 player.modPlayers[index].OnConsumeMana(item, manaConsumed);
604 }
605 }
606
607 private delegate void DelegateGetWeaponDamage(Item item, ref int damage);
608 [Obsolete]
609 private static HookList HookGetWeaponDamage = AddHook<DelegateGetWeaponDamage>(p => p.GetWeaponDamage);
610 [Obsolete]
611 public static void GetWeaponDamage(Player player, Item item, ref int damage) {
612 if (item.IsAir)
613 return;
614
615 foreach (int index in HookGetWeaponDamage.arr) {
616 player.modPlayers[index].GetWeaponDamage(item, ref damage);
617 }
618 }
619
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) {
628 if (item.IsAir)
629 return;
630
631 foreach (int index in HookModifyWeaponDamageOld.arr) {
632 player.modPlayers[index].ModifyWeaponDamage(item, ref add, ref mult);
633 }
634 foreach (int index in HookModifyWeaponDamage.arr) {
635 player.modPlayers[index].ModifyWeaponDamage(item, ref add, ref mult, ref flat);
636 }
637 }
638
639 private static HookList HookProcessTriggers = AddHook<Action<TriggersSet>>(p => p.ProcessTriggers);
640
641 public static void ProcessTriggers(Player player, TriggersSet triggersSet) {
642 foreach (int index in HookProcessTriggers.arr) {
643 player.modPlayers[index].ProcessTriggers(triggersSet);
644 }
645 }
646
647 private delegate void DelegateGetWeaponKnockback(Item item, ref float knockback);
648 private static HookList HookGetWeaponKnockback = AddHook<DelegateGetWeaponKnockback>(p => p.GetWeaponKnockback);
649
650 public static void GetWeaponKnockback(Player player, Item item, ref float knockback) {
651 if (item.IsAir)
652 return;
653
654 foreach (int index in HookGetWeaponKnockback.arr) {
655 player.modPlayers[index].GetWeaponKnockback(item, ref knockback);
656 }
657 }
658
659 private delegate void DelegateGetWeaponCrit(Item item, ref int crit);
660 private static HookList HookGetWeaponCrit = AddHook<DelegateGetWeaponCrit>(p => p.GetWeaponCrit);
661
662 public static void GetWeaponCrit(Player player, Item item, ref int crit) {
663 if (item.IsAir) return;
664 foreach (int index in HookGetWeaponCrit.arr) {
665 player.modPlayers[index].GetWeaponCrit(item, ref crit);
666 }
667 }
668
669 private static HookList HookConsumeAmmo = AddHook<Func<Item, Item, bool>>(p => p.ConsumeAmmo);
670
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)) {
674 return false;
675 }
676 }
677 return true;
678 }
679
680 private static HookList HookOnConsumeAmmo = AddHook<Action<Item, Item>>(p => p.OnConsumeAmmo);
681
682 public static void OnConsumeAmmo(Player player, Item weapon, Item ammo) {
683 foreach (int index in HookOnConsumeAmmo.arr)
684 player.modPlayers[index].OnConsumeAmmo(weapon, ammo);
685 }
686
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);
689
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)) {
693 return false;
694 }
695 }
696 return true;
697 }
698
699 private static HookList HookMeleeEffects = AddHook<Action<Item, Rectangle>>(p => p.MeleeEffects);
700
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);
704 }
705 }
706
707 private static HookList HookOnHitAnything = AddHook<Action<float, float, Entity>>(p => p.OnHitAnything);
708
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);
712 }
713 }
714
715 private static HookList HookCanHitNPC = AddHook<Func<Item, NPC, bool?>>(p => p.CanHitNPC);
716
717 public static bool? CanHitNPC(Player player, Item item, NPC target) {
718 bool? flag = null;
719 foreach (int index in HookCanHitNPC.arr) {
720 bool? canHit = player.modPlayers[index].CanHitNPC(item, target);
721 if (canHit.HasValue && !canHit.Value) {
722 return false;
723 }
724 if (canHit.HasValue) {
725 flag = canHit.Value;
726 }
727 }
728 return flag;
729 }
730
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);
733
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);
737 }
738 }
739
740 private static HookList HookOnHitNPC = AddHook<Action<Item, NPC, int, float, bool>>(p => p.OnHitNPC);
741
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);
745 }
746 }
747
748 private static HookList HookCanHitNPCWithProj = AddHook<Func<Projectile, NPC, bool?>>(p => p.CanHitNPCWithProj);
749
750 public static bool? CanHitNPCWithProj(Projectile proj, NPC target) {
751 if (proj.npcProj || proj.trap) {
752 return null;
753 }
754 Player player = Main.player[proj.owner];
755 bool? flag = null;
756 foreach (int index in HookCanHitNPCWithProj.arr) {
757 bool? canHit = player.modPlayers[index].CanHitNPCWithProj(proj, target);
758 if (canHit.HasValue && !canHit.Value) {
759 return false;
760 }
761 if (canHit.HasValue) {
762 flag = canHit.Value;
763 }
764 }
765 return flag;
766 }
767
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);
770
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) {
773 return;
774 }
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);
778 }
779 }
780
781 private static HookList HookOnHitNPCWithProj = AddHook<Action<Projectile, NPC, int, float, bool>>(p => p.OnHitNPCWithProj);
782
783 public static void OnHitNPCWithProj(Projectile proj, NPC target, int damage, float knockback, bool crit) {
784 if (proj.npcProj || proj.trap) {
785 return;
786 }
787 Player player = Main.player[proj.owner];
788 foreach (int index in HookOnHitNPCWithProj.arr) {
789 player.modPlayers[index].OnHitNPCWithProj(proj, target, damage, knockback, crit);
790 }
791 }
792
793 private static HookList HookCanHitPvp = AddHook<Func<Item, Player, bool>>(p => p.CanHitPvp);
794
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)) {
798 return false;
799 }
800 }
801 return true;
802 }
803
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);
806
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);
810 }
811 }
812
813 private static HookList HookOnHitPvp = AddHook<Action<Item, Player, int, bool>>(p => p.OnHitPvp);
814
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);
818 }
819 }
820
821 private static HookList HookCanHitPvpWithProj = AddHook<Func<Projectile, Player, bool>>(p => p.CanHitPvpWithProj);
822
823 public static bool CanHitPvpWithProj(Projectile proj, Player target) {
824 Player player = Main.player[proj.owner];
825 foreach (int index in HookCanHitPvpWithProj.arr) {
826 if (!player.modPlayers[index].CanHitPvpWithProj(proj, target)) {
827 return false;
828 }
829 }
830 return true;
831 }
832
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);
835
836 public static void ModifyHitPvpWithProj(Projectile proj, Player target, ref int damage, ref bool crit) {
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);
840 }
841 }
842
843 private static HookList HookOnHitPvpWithProj = AddHook<Action<Projectile, Player, int, bool>>(p => p.OnHitPvpWithProj);
844
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);
849 }
850 }
851
852 private delegate bool DelegateCanBeHitByNPC(NPC npc, ref int cooldownSlot);
853 private static HookList HookCanBeHitByNPC = AddHook<DelegateCanBeHitByNPC>(p => p.CanBeHitByNPC);
854
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)) {
858 return false;
859 }
860 }
861 return true;
862 }
863
864 private delegate void DelegateModifyHitByNPC(NPC npc, ref int damage, ref bool crit);
865 private static HookList HookModifyHitByNPC = AddHook<DelegateModifyHitByNPC>(p => p.ModifyHitByNPC);
866
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);
870 }
871 }
872
873 private static HookList HookOnHitByNPC = AddHook<Action<NPC, int, bool>>(p => p.OnHitByNPC);
874
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);
878 }
879 }
880
881 private static HookList HookCanBeHitByProjectile = AddHook<Func<Projectile, bool>>(p => p.CanBeHitByProjectile);
882
883 public static bool CanBeHitByProjectile(Player player, Projectile proj) {
884 foreach (int index in HookCanBeHitByProjectile.arr) {
885 if (!player.modPlayers[index].CanBeHitByProjectile(proj)) {
886 return false;
887 }
888 }
889 return true;
890 }
891
892 private delegate void DelegateModifyHitByProjectile(Projectile proj, ref int damage, ref bool crit);
893 private static HookList HookModifyHitByProjectile = AddHook<DelegateModifyHitByProjectile>(p => p.ModifyHitByProjectile);
894
895 public static void ModifyHitByProjectile(Player player, Projectile proj, ref int damage, ref bool crit) {
896 foreach (int index in HookModifyHitByProjectile.arr) {
897 player.modPlayers[index].ModifyHitByProjectile(proj, ref damage, ref crit);
898 }
899 }
900
901 private static HookList HookOnHitByProjectile = AddHook<Action<Projectile, int, bool>>(p => p.OnHitByProjectile);
902
903 public static void OnHitByProjectile(Player player, Projectile proj, int damage, bool crit) {
904 foreach (int index in HookOnHitByProjectile.arr) {
905 player.modPlayers[index].OnHitByProjectile(proj, damage, crit);
906 }
907 }
908
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);
911
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) {
913 int i = 0;
914 while (i < 58) {
915 if (player.inventory[i].stack > 0 && player.inventory[i].bait > 0) {
916 break;
917 }
918 i++;
919 }
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);
922 }
923 }
924
925 private delegate void DelegateGetFishingLevel(Item fishingRod, Item bait, ref int fishingLevel);
926 private static HookList HookGetFishingLevel = AddHook<DelegateGetFishingLevel>(p => p.GetFishingLevel);
927
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);
931 }
932 }
933
934 private static HookList HookAnglerQuestReward = AddHook<Action<float, List<Item>>>(p => p.AnglerQuestReward);
935
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);
939 }
940 }
941
942 private static HookList HookGetDyeTraderReward = AddHook<Action<List<int>>>(p => p.GetDyeTraderReward);
943
944 public static void GetDyeTraderReward(Player player, List<int> rewardPool) {
945 foreach (int index in HookGetDyeTraderReward.arr) {
946 player.modPlayers[index].GetDyeTraderReward(rewardPool);
947 }
948 }
949
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);
952
953 public static void DrawEffects(PlayerDrawInfo drawInfo, ref float r, ref float g, ref float b, ref float a, ref bool fullBright) {
954 ModPlayer[] modPlayers = drawInfo.drawPlayer.modPlayers;
955 foreach (int index in HookDrawEffects.arr) {
956 modPlayers[index].DrawEffects(drawInfo, ref r, ref g, ref b, ref a, ref fullBright);
957 }
958 }
959
960 private delegate void DelegateModifyDrawInfo(ref PlayerDrawInfo drawInfo);
961 private static HookList HookModifyDrawInfo = AddHook<DelegateModifyDrawInfo>(p => p.ModifyDrawInfo);
962
963 public static void ModifyDrawInfo(ref PlayerDrawInfo drawInfo) {
964 ModPlayer[] modPlayers = drawInfo.drawPlayer.modPlayers;
965 foreach (int index in HookModifyDrawInfo.arr) {
966 modPlayers[index].ModifyDrawInfo(ref drawInfo);
967 }
968 }
969
970 private static HookList HookModifyDrawLayers = AddHook<Action<List<PlayerLayer>>>(p => p.ModifyDrawLayers);
971
972 public static List<PlayerLayer> GetDrawLayers(Player drawPlayer) {
973 List<PlayerLayer> layers = new List<PlayerLayer> {
980 PlayerLayer.Skin
981 };
982 if (drawPlayer.wearsRobe) {
983 layers.Add(PlayerLayer.ShoeAcc);
984 layers.Add(PlayerLayer.Legs);
985 }
986 else {
987 layers.Add(PlayerLayer.Legs);
988 layers.Add(PlayerLayer.ShoeAcc);
989 }
990 layers.Add(PlayerLayer.Body);
991 layers.Add(PlayerLayer.HandOffAcc);
992 layers.Add(PlayerLayer.WaistAcc);
993 layers.Add(PlayerLayer.NeckAcc);
994 layers.Add(PlayerLayer.Face);
995 layers.Add(PlayerLayer.Hair);
996 layers.Add(PlayerLayer.Head);
997 layers.Add(PlayerLayer.FaceAcc);
998 if (drawPlayer.mount.Cart) {
999 layers.Add(PlayerLayer.ShieldAcc);
1000 layers.Add(PlayerLayer.MountFront);
1001 }
1002 else {
1003 layers.Add(PlayerLayer.MountFront);
1004 layers.Add(PlayerLayer.ShieldAcc);
1005 }
1006 layers.Add(PlayerLayer.SolarShield);
1007 layers.Add(PlayerLayer.HeldProjBack);
1008 layers.Add(PlayerLayer.HeldItem);
1009 layers.Add(PlayerLayer.Arms);
1010 layers.Add(PlayerLayer.HandOnAcc);
1011 layers.Add(PlayerLayer.HeldProjFront);
1012 layers.Add(PlayerLayer.FrontAcc);
1013 layers.Add(PlayerLayer.MiscEffectsFront);
1014 foreach (PlayerLayer layer in layers) {
1015 layer.visible = true;
1016 }
1017 foreach (int index in HookModifyDrawLayers.arr) {
1018 drawPlayer.modPlayers[index].ModifyDrawLayers(layers);
1019 }
1020 return layers;
1021 }
1022
1023 private static HookList HookModifyDrawHeadLayers = AddHook<Action<List<PlayerHeadLayer>>>(p => p.ModifyDrawHeadLayers);
1024
1025 public static List<PlayerHeadLayer> GetDrawHeadLayers(Player drawPlayer) {
1026 List<PlayerHeadLayer> layers = new List<PlayerHeadLayer> {
1031 PlayerHeadLayer.FaceAcc
1032 };
1033 foreach (PlayerHeadLayer layer in layers) {
1034 layer.visible = true;
1035 }
1036 foreach (int index in HookModifyDrawHeadLayers.arr) {
1037 drawPlayer.modPlayers[index].ModifyDrawHeadLayers(layers);
1038 }
1039 return layers;
1040 }
1041
1042 private static HookList HookModifyScreenPosition = AddHook<Action>(p => p.ModifyScreenPosition);
1043
1044 public static void ModifyScreenPosition(Player player) {
1045 foreach (int index in HookModifyScreenPosition.arr) {
1046 player.modPlayers[index].ModifyScreenPosition();
1047 }
1048 }
1049
1050 private delegate void DelegateModifyZoom(ref float zoom);
1051 private static HookList HookModifyZoom = AddHook<DelegateModifyZoom>(p => p.ModifyZoom);
1052
1053 public static void ModifyZoom(Player player, ref float zoom) {
1054 foreach (int index in HookModifyZoom.arr) {
1055 player.modPlayers[index].ModifyZoom(ref zoom);
1056 }
1057 }
1058
1059 private static HookList HookPlayerConnect = AddHook<Action<Player>>(p => p.PlayerConnect);
1060
1061 public static void PlayerConnect(int playerIndex) {
1062 var player = Main.player[playerIndex];
1063 foreach (int index in HookPlayerConnect.arr) {
1064 player.modPlayers[index].PlayerConnect(player);
1065 }
1066 }
1067
1068 private static HookList HookPlayerDisconnect = AddHook<Action<Player>>(p => p.PlayerDisconnect);
1069
1070 public static void PlayerDisconnect(int playerIndex) {
1071 var player = Main.player[playerIndex];
1072 foreach (int index in HookPlayerDisconnect.arr) {
1073 player.modPlayers[index].PlayerDisconnect(player);
1074 }
1075 }
1076
1077 private static HookList HookOnEnterWorld = AddHook<Action<Player>>(p => p.OnEnterWorld);
1078
1079 // Do NOT hook into the Player.Hooks.OnEnterWorld event
1080 public static void OnEnterWorld(int playerIndex) {
1081 var player = Main.player[playerIndex];
1082 foreach (int index in HookOnEnterWorld.arr) {
1083 player.modPlayers[index].OnEnterWorld(player);
1084 }
1085 }
1086
1087 private static HookList HookOnRespawn = AddHook<Action<Player>>(p => p.OnRespawn);
1088
1089 public static void OnRespawn(Player player) {
1090 foreach (int index in HookOnRespawn.arr) {
1091 player.modPlayers[index].OnRespawn(player);
1092 }
1093 }
1094
1095 private static HookList HookShiftClickSlot = AddHook<Func<Item[], int, int, bool>>(p => p.ShiftClickSlot);
1096
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)) {
1100 return true;
1101 }
1102 }
1103 return false;
1104 }
1105
1106 private static bool HasMethod(Type t, string method, params Type[] args) {
1107 return t.GetMethod(method, args).DeclaringType != typeof(ModPlayer);
1108 }
1109
1110 internal static void VerifyGlobalItem(ModPlayer player) {
1111 var type = player.GetType();
1112
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");
1120
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");
1127
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");
1133
1134 int netMethods = 0;
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");
1139 }
1140
1141 private static HookList HookPostSellItem = AddHook<Action<NPC, Item[], Item>>(p => p.PostSellItem);
1142
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);
1146 }
1147 }
1148
1149 private static HookList HookCanSellItem = AddHook<Func<NPC, Item[], Item, bool>>(p => p.CanSellItem);
1150
1151 // TODO: GlobalNPC and ModNPC hooks for Buy/Sell hooks as well.
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))
1155 return false;
1156 }
1157 return true;
1158 }
1159
1160 private static HookList HookPostBuyItem = AddHook<Action<NPC, Item[], Item>>(p => p.PostBuyItem);
1161
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);
1165 }
1166 }
1167
1168 private static HookList HookCanBuyItem = AddHook<Func<NPC, Item[], Item, bool>>(p => p.CanBuyItem);
1169
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))
1173 return false;
1174 }
1175 return true;
1176 }
1177
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);
1180
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))
1184 return false;
1185 }
1186 return true;
1187 }
1188
1189 private delegate void DelegateModifyNursePrice(NPC npc, int health, bool removeDebuffs, ref int price);
1190 private static HookList HookModifyNursePrice = AddHook<DelegateModifyNursePrice>(p => p.ModifyNursePrice);
1191
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);
1195 }
1196 }
1197
1198 private static HookList HookPostNurseHeal = AddHook<Action<NPC, int, bool, int>>(p => p.PostNurseHeal);
1199
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);
1203 }
1204 }
1205 }
1206}
This serves as the central class from which item-related functions are carried out....
Definition: ItemLoader.cs:22
static float UseTimeMultiplier(Item item, Player player)
Definition: ItemLoader.cs:367
static float MeleeSpeedMultiplier(Item item, Player player)
Definition: ItemLoader.cs:380
Manages content added by mods. Liasons between mod content and Terraria's arrays and oversees the Loa...
Definition: ModContent.cs:27
Mod is an abstract class that you will override. It serves as a central place from which the mod's co...
Definition: Mod.cs:25
virtual string Name
Stores the name of the mod. This name serves as the mod's identification, and also helps with saving ...
Definition: Mod.cs:42
This serves as the central class which loads mods. It contains many static fields and methods related...
Definition: ModLoader.cs:29
static Mod GetMod(string name)
Gets the instance of the Mod with the specified name.
Definition: ModLoader.cs:90
A ModPlayer instance represents an extension of a Player instance. You can store fields in the ModPla...
Definition: ModPlayer.cs:16
string Name
The name of this ModPlayer. Used for distinguishing between multiple ModPlayers added by a single Mod...
Definition: ModPlayer.cs:28
virtual void PostSellItem(NPC vendor, Item[] shopInventory, Item item)
Called whenever the player sells an item to an NPC.
Definition: ModPlayer.cs:873
virtual void ModifyDrawInfo(ref PlayerDrawInfo drawInfo)
Allows you to modify the drawing parameters of the player before drawing begins.
Definition: ModPlayer.cs:798
virtual void PostNurseHeal(NPC nurse, int health, bool removeDebuffs, int price)
Called on the Client after the player heals themselves with the Nurse NPC.
Definition: ModPlayer.cs:936
virtual void ReceiveCustomBiomes(BinaryReader reader)
Allows you to do things with the custom biome information you send between client and server.
Definition: ModPlayer.cs:175
virtual void PostBuyItem(NPC vendor, Item[] shopInventory, Item item)
Called whenever the player buys an item from an NPC.
Definition: ModPlayer.cs:893
virtual void SendCustomBiomes(BinaryWriter writer)
Allows you to send custom biome information between client and server.
Definition: ModPlayer.cs:168
Mod mod
The mod that added this type of ModPlayer.
Definition: ModPlayer.cs:20
virtual bool CanSellItem(NPC vendor, Item[] shopInventory, Item item)
Return false to prevent a transaction. Called before the transaction.
Definition: ModPlayer.cs:883
virtual bool CanBuyItem(NPC vendor, Item[] shopInventory, Item item)
Return false to prevent a transaction. Called before the transaction.
Definition: ModPlayer.cs:903
This class represents a DrawLayer for the player's map icon, and uses PlayerDrawHeadInfo as its InfoT...
Definition: DrawLayer.cs:233
static readonly PlayerHeadLayer AltHair
Draws the player's alternate (hat) hair.
Definition: DrawLayer.cs:245
static readonly PlayerHeadLayer Head
Draws the player's face and eyes.
Definition: DrawLayer.cs:237
static readonly PlayerHeadLayer Armor
Draws the player's head armor.
Definition: DrawLayer.cs:249
static readonly PlayerHeadLayer Hair
Draws the player's hair.
Definition: DrawLayer.cs:241
This is where all ModPlayer hooks are gathered and called.
Definition: PlayerHooks.cs:21
delegate void DelegateModifyNursePrice(NPC npc, int health, bool removeDebuffs, ref int price)
static HookList HookGetHealLife
Definition: PlayerHooks.cs:550
delegate void DelegateGetWeaponKnockback(Item item, ref float knockback)
delegate void DelegateCatchFish(Item fishingRod, Item bait, int power, int liquidType, int poolSize, int worldLayer, int questFish, ref int caughtType, ref bool junk)
static void PostUpdateRunSpeeds(Player player)
Definition: PlayerHooks.cs:407
static HookList HookModifyHitNPC
Definition: PlayerHooks.cs:732
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)
Definition: PlayerHooks.cs:441
delegate void DelegateModifyHitByNPC(NPC npc, ref int damage, ref bool crit)
static HookList HookModifyScreenPosition
static void PreUpdateBuffs(Player player)
Definition: PlayerHooks.cs:358
static HookList HookModifyWeaponDamageOld
Definition: PlayerHooks.cs:621
static HookList HookPostUpdate
Definition: PlayerHooks.cs:421
static HookList HookModifyHitNPCWithProj
Definition: PlayerHooks.cs:769
delegate void DelegateModifyManaCost(Item item, ref float reduce, ref float mult)
static HookList HookSetupStartInventoryOld
Definition: PlayerHooks.cs:78
static bool ShiftClickSlot(Player player, Item[] inventory, int context, int slot)
static bool CanHitPvpWithProj(Projectile proj, Player target)
Definition: PlayerHooks.cs:823
static HookList HookSyncPlayer
Definition: PlayerHooks.cs:278
static void PostHurt(Player player, bool pvp, bool quiet, double damage, int hitDirection, bool crit)
Definition: PlayerHooks.cs:463
static float TotalMeleeSpeedMultiplier(Player player, Item item)
Definition: PlayerHooks.cs:540
static HookList HookSetControls
Definition: PlayerHooks.cs:348
delegate void DelegateGetHealLife(Item item, bool quickHeal, ref int healValue)
static HookList HookUpdateBiomes
Definition: PlayerHooks.cs:174
static void UpdateBadLifeRegen(Player player)
Definition: PlayerHooks.cs:309
static HookList HookPreUpdateMovement
Definition: PlayerHooks.cs:413
static HookList HookOnHitByNPC
Definition: PlayerHooks.cs:873
static HookList HookPostUpdateMiscEffects
Definition: PlayerHooks.cs:397
static HookList HookCanBeHitByNPC
Definition: PlayerHooks.cs:853
static HookList HookNaturalLifeRegen
Definition: PlayerHooks.cs:324
static int TotalUseTime(float useTime, Player player, Item item)
Definition: PlayerHooks.cs:525
static void PostBuyItem(Player player, NPC npc, Item[] shopInventory, Item item)
static void PostNurseHeal(Player player, NPC npc, int health, bool removeDebuffs, int price)
delegate void DelegateGetFishingLevel(Item fishingRod, Item bait, ref int fishingLevel)
static void PostSavePlayer(Player player)
Definition: PlayerHooks.cs:168
delegate bool DelegateModifyNurseHeal(NPC npc, ref int health, ref bool removeDebuffs, ref string chatText)
static void CopyCustomBiomesTo(Player player, Player other)
Definition: PlayerHooks.cs:195
static HookList HookGetWeaponKnockback
Definition: PlayerHooks.cs:648
static void Kill(Player player, double damage, int hitDirection, bool pvp, PlayerDeathReason damageSource)
Definition: PlayerHooks.cs:486
static void GetHealLife(Player player, Item item, bool quickHeal, ref int healValue)
Definition: PlayerHooks.cs:552
static HookList HookModifyHitByProjectile
Definition: PlayerHooks.cs:893
static void SyncPlayer(Player player, int toWho, int fromWho, bool newPlayer)
Definition: PlayerHooks.cs:280
static HookList HookGetDyeTraderReward
Definition: PlayerHooks.cs:942
static HookList HookMeleeSpeedMultiplier
Definition: PlayerHooks.cs:529
static HookList HookPostUpdateRunSpeeds
Definition: PlayerHooks.cs:405
static void PreUpdateMovement(Player player)
Definition: PlayerHooks.cs:415
static void ModifyHitPvpWithProj(Projectile proj, Player target, ref int damage, ref bool crit)
Definition: PlayerHooks.cs:836
static void UpdateBiomes(Player player)
Definition: PlayerHooks.cs:176
static bool HasMethod(Type t, string method, params Type[] args)
static void PostUpdateBuffs(Player player)
Definition: PlayerHooks.cs:366
static void FrameEffects(Player player)
Definition: PlayerHooks.cs:431
static bool ConsumeAmmo(Player player, Item weapon, Item ammo)
Definition: PlayerHooks.cs:671
static HookList HookCanBeHitByProjectile
Definition: PlayerHooks.cs:881
static HookList HookGetWeaponDamage
Definition: PlayerHooks.cs:609
static HookList HookUseTimeMultiplier
Definition: PlayerHooks.cs:510
static HookList HookModifyHitPvpWithProj
Definition: PlayerHooks.cs:834
static void ModifyNursePrice(Player p, NPC npc, int health, bool removeDebuffs, ref int price)
static readonly IList< ModPlayer > players
Definition: PlayerHooks.cs:22
static void Hurt(Player player, bool pvp, bool quiet, double damage, int hitDirection, bool crit)
Definition: PlayerHooks.cs:455
static HookList HookOnHitNPCWithProj
Definition: PlayerHooks.cs:781
static void PostUpdateMiscEffects(Player player)
Definition: PlayerHooks.cs:399
static float MeleeSpeedMultiplier(Player player, Item item)
Definition: PlayerHooks.cs:531
static HookList HookResetEffects
Definition: PlayerHooks.cs:61
static HookList HookPostUpdateEquips
Definition: PlayerHooks.cs:389
static HookList HookModifyNursePrice
delegate void DelegateGetWeaponDamage(Item item, ref int damage)
static HookList HookOnConsumeMana
Definition: PlayerHooks.cs:596
static void OnEnterWorld(int playerIndex)
delegate void DelegateNaturalLifeRegen(ref float regen)
static void OnConsumeAmmo(Player player, Item weapon, Item ammo)
Definition: PlayerHooks.cs:682
static HookList HookCustomBiomesMatch
Definition: PlayerHooks.cs:182
static HookList HookGetFishingLevel
Definition: PlayerHooks.cs:926
static HookList HookClientClone
Definition: PlayerHooks.cs:270
static void GetWeaponKnockback(Player player, Item item, ref float knockback)
Definition: PlayerHooks.cs:650
static ? bool CanHitNPCWithProj(Projectile proj, NPC target)
Definition: PlayerHooks.cs:750
static void PlayerConnect(int playerIndex)
static HookList HookPostSellItem
static void ModifyHitPvp(Player player, Item item, Player target, ref int damage, ref bool crit)
Definition: PlayerHooks.cs:807
static void OnHitPvp(Player player, Item item, Player target, int damage, bool crit)
Definition: PlayerHooks.cs:815
static HookList HookSendCustomBiomes
Definition: PlayerHooks.cs:201
static HookList HookSendClientChanges
Definition: PlayerHooks.cs:286
static void PostSellItem(Player player, NPC npc, Item[] shopInventory, Item item)
static void ModifyHitNPCWithProj(Projectile proj, NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
Definition: PlayerHooks.cs:771
static List< PlayerHeadLayer > GetDrawHeadLayers(Player drawPlayer)
static void SetControls(Player player)
Definition: PlayerHooks.cs:350
delegate void DelegateGetHealMana(Item item, bool quickHeal, ref int healValue)
static void ModifyHitByProjectile(Player player, Projectile proj, ref int damage, ref bool crit)
Definition: PlayerHooks.cs:895
static void SendCustomBiomes(Player player, BinaryWriter writer)
Definition: PlayerHooks.cs:203
static void AnglerQuestReward(Player player, float rareMultiplier, List< Item > rewardItems)
Definition: PlayerHooks.cs:936
static HookList HookOnHitAnything
Definition: PlayerHooks.cs:707
static HookList HookPlayerConnect
static void OnHitByNPC(Player player, NPC npc, int damage, bool crit)
Definition: PlayerHooks.cs:875
static void PreSavePlayer(Player player)
Definition: PlayerHooks.cs:160
static HookList HookPlayerDisconnect
static bool CustomBiomesMatch(Player player, Player other)
Definition: PlayerHooks.cs:184
delegate void DelegateModifyHitNPCWithProj(Projectile proj, NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
static void UpdateAutopause(Player player)
Definition: PlayerHooks.cs:334
static HookList HookShiftClickSlot
static void ModifyZoom(Player player, ref float zoom)
delegate bool DelegatePreKill(double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource)
static void GetFishingLevel(Player player, Item fishingRod, Item bait, ref int fishingLevel)
Definition: PlayerHooks.cs:928
static void DrawEffects(PlayerDrawInfo drawInfo, ref float r, ref float g, ref float b, ref float a, ref bool fullBright)
Definition: PlayerHooks.cs:953
static HookList HookUpdateVanityAccessories
Definition: PlayerHooks.cs:381
delegate void DelegateDrawEffects(PlayerDrawInfo drawInfo, ref float r, ref float g, ref float b, ref float a, ref bool fullBright)
static void ModifyHitByNPC(Player player, NPC npc, ref int damage, ref bool crit)
Definition: PlayerHooks.cs:867
static void ReceiveCustomBiomes(Player player, BinaryReader reader)
Definition: PlayerHooks.cs:240
static HookList HookGetWeaponCrit
Definition: PlayerHooks.cs:660
static HookList HookCopyCustomBiomesTo
Definition: PlayerHooks.cs:193
static HookList HookOnHitPvpWithProj
Definition: PlayerHooks.cs:843
static HookList HookModifyNurseHeal
static HookList HookUpdateBadLifeRegen
Definition: PlayerHooks.cs:307
static HookList AddHook< F >(Expression< Func< ModPlayer, F > > func)
Definition: PlayerHooks.cs:36
static float UseTimeMultiplier(Player player, Item item)
Definition: PlayerHooks.cs:512
static void OnConsumeMana(Player player, Item item, int manaConsumed)
Definition: PlayerHooks.cs:598
static HookList HookOnConsumeAmmo
Definition: PlayerHooks.cs:680
static Texture2D GetMapBackgroundImage(Player player)
Definition: PlayerHooks.cs:296
static float TotalUseTimeMultiplier(Player player, Item item)
Definition: PlayerHooks.cs:521
static void PreUpdate(Player player)
Definition: PlayerHooks.cs:342
static void PostItemCheck(Player player)
Definition: PlayerHooks.cs:504
static HookList HookModifyDrawInfo
Definition: PlayerHooks.cs:961
static void ProcessTriggers(Player player, TriggersSet triggersSet)
Definition: PlayerHooks.cs:641
static HookList HookDrawEffects
Definition: PlayerHooks.cs:951
static int TotalMeleeTime(float useAnimation, Player player, Item item)
Definition: PlayerHooks.cs:545
delegate void DelegateModifyHitPvp(Item item, Player target, ref int damage, ref bool crit)
static bool CanBuyItem(Player player, NPC npc, Item[] shopInventory, Item item)
static bool CanHitPvp(Player player, Item item, Player target)
Definition: PlayerHooks.cs:795
static HookList HookPostNurseHeal
static HookList HookModifyHitByNPC
Definition: PlayerHooks.cs:865
static bool ModifyNurseHeal(Player p, NPC npc, ref int health, ref bool removeDebuffs, ref string chat)
static bool CanSellItem(Player player, NPC npc, Item[] shopInventory, Item item)
static void ModifyDrawInfo(ref PlayerDrawInfo drawInfo)
Definition: PlayerHooks.cs:963
static void ModifyHitNPC(Player player, Item item, NPC target, ref int damage, ref float knockback, ref bool crit)
Definition: PlayerHooks.cs:734
static void clientClone(Player player, Player clientClone)
Definition: PlayerHooks.cs:272
static bool PreItemCheck(Player player)
Definition: PlayerHooks.cs:494
delegate bool DelegateCanBeHitByNPC(NPC npc, ref int cooldownSlot)
static HookList HookPostUpdateBuffs
Definition: PlayerHooks.cs:364
static void OnHitPvpWithProj(Projectile proj, Player target, int damage, bool crit)
Definition: PlayerHooks.cs:845
static void NaturalLifeRegen(Player player, ref float regen)
Definition: PlayerHooks.cs:326
delegate bool DelegateShoot(Item item, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
delegate void DelegateModifyWeaponDamageOld(Item item, ref float add, ref float mult)
static HookList HookSetupStartInventory
Definition: PlayerHooks.cs:77
static HookList HookUpdateEquips
Definition: PlayerHooks.cs:373
static HookList HookCanHitPvpWithProj
Definition: PlayerHooks.cs:821
static HookList HookCanHitNPCWithProj
Definition: PlayerHooks.cs:748
static HookList HookOnHitByProjectile
Definition: PlayerHooks.cs:901
delegate void DelegateModifyZoom(ref float zoom)
static void CatchFish(Player player, Item fishingRod, int power, int liquidType, int poolSize, int worldLayer, int questFish, ref int caughtType, ref bool junk)
Definition: PlayerHooks.cs:912
static void UpdateBiomeVisuals(Player player)
Definition: PlayerHooks.cs:264
static void PostUpdate(Player player)
Definition: PlayerHooks.cs:423
delegate bool DelegatePreHurt(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 HookList HookModifyManaCost
Definition: PlayerHooks.cs:574
static void OnHitByProjectile(Player player, Projectile proj, int damage, bool crit)
Definition: PlayerHooks.cs:903
static HookList HookOnMissingMana
Definition: PlayerHooks.cs:585
static void ModifyManaCost(Player player, Item item, ref float reduce, ref float mult)
Definition: PlayerHooks.cs:576
static void UpdateLifeRegen(Player player)
Definition: PlayerHooks.cs:317
delegate void DelegateUpdateEquips(ref bool wallSpeedBuff, ref bool tileSpeedBuff, ref bool tileRangeBuff)
static void PostUpdateEquips(Player player)
Definition: PlayerHooks.cs:391
static HookList HookModifyDrawLayers
Definition: PlayerHooks.cs:970
static void ResetEffects(Player player)
Definition: PlayerHooks.cs:63
static void UpdateVanityAccessories(Player player)
Definition: PlayerHooks.cs:383
static HookList HookGetMapBackgroundImage
Definition: PlayerHooks.cs:294
static void SendClientChanges(Player player, Player clientPlayer)
Definition: PlayerHooks.cs:288
static void OnHitNPC(Player player, Item item, NPC target, int damage, float knockback, bool crit)
Definition: PlayerHooks.cs:742
static HookList HookUpdateAutopause
Definition: PlayerHooks.cs:332
static ? bool CanHitNPC(Player player, Item item, NPC target)
Definition: PlayerHooks.cs:717
delegate void DelegateModifyHitPvpWithProj(Projectile proj, Player target, ref int damage, ref bool crit)
static List< PlayerLayer > GetDrawLayers(Player drawPlayer)
Definition: PlayerHooks.cs:972
static void MeleeEffects(Player player, Item item, Rectangle hitbox)
Definition: PlayerHooks.cs:701
static HookList HookAnglerQuestReward
Definition: PlayerHooks.cs:934
static void ModifyWeaponDamage(Player player, Item item, ref float add, ref float mult, ref float flat)
Calls ModItem.HookModifyWeaponDamage, then all GlobalItem.HookModifyWeaponDamage hooks.
Definition: PlayerHooks.cs:627
static HookList HookMeleeEffects
Definition: PlayerHooks.cs:699
static void GetDyeTraderReward(Player player, List< int > rewardPool)
Definition: PlayerHooks.cs:944
static void PlayerDisconnect(int playerIndex)
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)
Definition: PlayerHooks.cs:690
static void SetStartInventory(Player player, IList< Item > items)
Definition: PlayerHooks.cs:136
static HookList HookProcessTriggers
Definition: PlayerHooks.cs:639
static HookList HookModifyWeaponDamage
Definition: PlayerHooks.cs:623
delegate void DelegateGetWeaponCrit(Item item, ref int crit)
static void ModifyScreenPosition(Player player)
static IList< Item > SetupStartInventory(Player player, bool mediumcoreDeath=false)
Definition: PlayerHooks.cs:80
static void UpdateDead(Player player)
Definition: PlayerHooks.cs:71
static HookList HookGetHealMana
Definition: PlayerHooks.cs:562
static HookList HookUpdateDead
Definition: PlayerHooks.cs:69
static void OnRespawn(Player player)
static void SetStartInventory(Player player)
Definition: PlayerHooks.cs:154
static bool SendCustomBiomes(ModPlayer modPlayer, BinaryWriter writer)
Definition: PlayerHooks.cs:221
static void GetHealMana(Player player, Item item, bool quickHeal, ref int healValue)
Definition: PlayerHooks.cs:564
static void OnHitAnything(Player player, float x, float y, Entity victim)
Definition: PlayerHooks.cs:709
static HookList HookModifyDrawHeadLayers
static HookList HookConsumeAmmo
Definition: PlayerHooks.cs:669
delegate void DelegateModifyHitByProjectile(Projectile proj, ref int damage, ref bool crit)
static HookList HookPreUpdateBuffs
Definition: PlayerHooks.cs:356
static List< HookList > hooks
Definition: PlayerHooks.cs:34
static bool PreKill(Player player, double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource)
Definition: PlayerHooks.cs:473
static void UpdateEquips(Player player, ref bool wallSpeedBuff, ref bool tileSpeedBuff, ref bool tileRangeBuff)
Definition: PlayerHooks.cs:375
static void OnMissingMana(Player player, Item item, int manaNeeded)
Definition: PlayerHooks.cs:587
static bool CanBeHitByNPC(Player player, NPC npc, ref int cooldownSlot)
Definition: PlayerHooks.cs:855
static HookList HookUpdateBiomeVisuals
Definition: PlayerHooks.cs:262
static void GetWeaponCrit(Player player, Item item, ref int crit)
Definition: PlayerHooks.cs:662
static HookList HookPostSavePlayer
Definition: PlayerHooks.cs:166
static HookList HookPreItemCheck
Definition: PlayerHooks.cs:492
static void OnHitNPCWithProj(Projectile proj, NPC target, int damage, float knockback, bool crit)
Definition: PlayerHooks.cs:783
static HookList HookFrameEffects
Definition: PlayerHooks.cs:429
static HookList HookUpdateLifeRegen
Definition: PlayerHooks.cs:315
delegate void DelegateModifyDrawInfo(ref PlayerDrawInfo drawInfo)
static HookList HookPostItemCheck
Definition: PlayerHooks.cs:502
static HookList HookModifyHitPvp
Definition: PlayerHooks.cs:805
static HookList HookPreSavePlayer
Definition: PlayerHooks.cs:158
static void GetWeaponDamage(Player player, Item item, ref int damage)
Definition: PlayerHooks.cs:611
delegate void DelegateModifyWeaponDamage(Item item, ref float add, ref float mult, ref float flat)
delegate void DelegateModifyHitNPC(Item item, NPC target, ref int damage, ref float knockback, ref bool crit)
static bool CanBeHitByProjectile(Player player, Projectile proj)
Definition: PlayerHooks.cs:883
static HookList HookOnEnterWorld
This class represents a DrawLayer for the player, and uses PlayerDrawInfo as its InfoType....
Definition: DrawLayer.cs:93
static readonly PlayerLayer Legs
Draws the player's leg armor or pants and shoes.
Definition: DrawLayer.cs:125
static readonly PlayerLayer MountBack
Draws the back textures of the player's mount. Also draws the player's magic carpet.
Definition: DrawLayer.cs:101
static readonly PlayerLayer MiscEffectsFront
Draws miscellaneous effects in front of the player.
Definition: DrawLayer.cs:201
static readonly PlayerLayer Face
Draws the player's face and eyes.
Definition: DrawLayer.cs:149
static readonly PlayerLayer SolarShield
Draws the player's solar shield if the player has one.
Definition: DrawLayer.cs:173
static readonly PlayerLayer NeckAcc
Draws the player's neck accessory.
Definition: DrawLayer.cs:145
static readonly PlayerLayer FrontAcc
Draws the player's front accessory.
Definition: DrawLayer.cs:197
static readonly PlayerLayer BackAcc
Draws the player's back accessory and held item's backpack.
Definition: DrawLayer.cs:109
static readonly PlayerLayer FaceAcc
Draws the player's face accessory.
Definition: DrawLayer.cs:161
static readonly PlayerLayer Wings
Draws the layer's wings.
Definition: DrawLayer.cs:113
static readonly PlayerLayer Hair
Draws the player's hair.
Definition: DrawLayer.cs:153
static readonly PlayerLayer HeldProjFront
Draws the player's held projectile if it should be drawn in front of the held item and arms.
Definition: DrawLayer.cs:193
static readonly PlayerLayer HairBack
Draws the player's hair. To be honest this layer seems kind of useless.
Definition: DrawLayer.cs:97
static readonly PlayerLayer Arms
Draws the player's arms (including the armor's arms if applicable).
Definition: DrawLayer.cs:185
static readonly PlayerLayer Head
Draws the player's head armor.
Definition: DrawLayer.cs:157
static readonly PlayerLayer WaistAcc
Draws the player's waist accessory.
Definition: DrawLayer.cs:141
static readonly PlayerLayer BalloonAcc
Draws the player's balloon accessory.
Definition: DrawLayer.cs:117
static readonly PlayerLayer ShieldAcc
Draws the player's shield accessory.
Definition: DrawLayer.cs:169
static readonly PlayerLayer HeldItem
Draws the player's held item.
Definition: DrawLayer.cs:181
static readonly PlayerLayer Body
Draws the player's body armor or shirts.
Definition: DrawLayer.cs:133
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...
Definition: DrawLayer.cs:189
static readonly PlayerLayer ShoeAcc
Draws the player's shoe accessory.
Definition: DrawLayer.cs:129
static readonly PlayerLayer HandOffAcc
Draws the player's hand off accessory.
Definition: DrawLayer.cs:137
static readonly PlayerLayer HeldProjBack
Draws the player's held projectile if it should be drawn behind the held item and arms.
Definition: DrawLayer.cs:177
static readonly PlayerLayer MiscEffectsBack
Draws miscellaneous effects behind the player.
Definition: DrawLayer.cs:105
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...
Definition: DrawLayer.cs:165
A struct that contains information that may help with PlayerLayer drawing.
Definition: DrawInfo.cs:10
Player drawPlayer
The player that is being drawn.
Definition: DrawInfo.cs:14