2 using System.Collections.Generic;
7 using Microsoft.Xna.Framework;
13 namespace Loot.Api.Delegators
22 public bool HasEffect(Type type) => _modifierEffects.Any(x => x.GetType() == type);
23 public bool HasEffect<T>() where T :
ModifierEffect => _modifierEffects.Any(x => x.GetType() == typeof(T));
27 return _modifierEffects.FirstOrDefault(x => x.GetType() == type);
32 return (T)_modifierEffects.FirstOrDefault(x => x.GetType() == typeof(T));
56 OnRespawnEvent?.Invoke(player);
62 return ShiftClickSlotEvent?.Invoke(inventory, context, slot) ?? base.ShiftClickSlot(inventory, context, slot);
65 public delegate
bool ModifyNurseHealEventRaiser(NPC nurse, ref
int health, ref
bool removeDebuffs, ref
string chatText);
67 public override bool ModifyNurseHeal(NPC nurse, ref
int health, ref
bool removeDebuffs, ref
string chatText)
69 return ModifyNurseHealEvent?.Invoke(nurse, ref health, ref removeDebuffs, ref chatText) ?? base.ModifyNurseHeal(nurse, ref health, ref removeDebuffs, ref chatText);
72 public delegate
void ModifyNursePriceEventRaiser(NPC nurse,
int health,
bool removeDebuffs, ref
int price);
74 public override void ModifyNursePrice(NPC nurse,
int health,
bool removeDebuffs, ref
int price)
76 ModifyNursePriceEvent?.Invoke(nurse, health, removeDebuffs, ref price);
80 public override void PostNurseHeal(NPC nurse,
int health,
bool removeDebuffs,
int price)
82 PostNurseHealEvent?.Invoke(nurse, health, removeDebuffs, price);
89 _modifierEffects =
new List<ModifierEffect>();
95 clone.DelegatorPlayer =
this;
97 _modifierEffects.Add(clone);
100 InitializeEvent?.Invoke();
106 UpdateAutopauseEvent?.Invoke();
112 PreUpdateEvent?.Invoke();
118 ProcessTriggersEvent?.Invoke(triggersSet);
124 SetControlsEvent?.Invoke();
130 PreUpdateBuffsEvent?.Invoke();
136 PostUpdateBuffsEvent?.Invoke();
139 public delegate
void UpdateEquipsEventRaiser(ref
bool wallSpeedBuff, ref
bool tileSpeedBuff, ref
bool tileRangeBuff);
141 public override void UpdateEquips(ref
bool wallSpeedBuff, ref
bool tileSpeedBuff, ref
bool tileRangeBuff)
143 UpdateEquipsEvent?.Invoke(ref wallSpeedBuff, ref tileSpeedBuff, ref tileRangeBuff);
151 ResetEffectsEvent?.Invoke();
158 UpdateDeadEvent?.Invoke();
164 UpdateLifeRegenEvent?.Invoke();
167 public delegate
void NaturalLifeRegenEventRaiser(ref
float regen);
171 NaturalLifeRegenEvent?.Invoke(ref regen);
175 public override void SyncPlayer(
int toWho,
int fromWho,
bool newPlayer)
177 SyncPlayerEvent?.Invoke(toWho, fromWho, newPlayer);
183 SendClientChangesEvent?.Invoke(clientPlayer);
189 UpdateBadLifeRegenEvent?.Invoke();
195 PostUpdateEquipsEvent?.Invoke();
201 PostUpdateMiscEffectsEvent?.Invoke();
207 PostUpdateRunSpeedsEvent?.Invoke();
213 PreUpdateMovementEvent?.Invoke();
219 PostUpdateEvent?.Invoke();
225 UpdateVanityAccessoriesEvent?.Invoke();
231 FrameEffectsEvent?.Invoke();
234 public delegate
bool PreHurtEventRaiser(
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);
236 public override bool PreHurt(
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)
238 return PreHurtEvent?.Invoke(pvp, quiet, ref damage, ref hitDirection, ref crit, ref customDamage, ref playSound, ref genGore, ref damageSource)
239 ?? base.PreHurt(pvp, quiet, ref damage, ref hitDirection, ref crit, ref customDamage, ref playSound, ref genGore, ref damageSource);
242 public event Action<bool, bool, double, int, bool>
HurtEvent;
243 public override void Hurt(
bool pvp,
bool quiet,
double damage,
int hitDirection,
bool crit)
245 HurtEvent?.Invoke(pvp, quiet, damage, hitDirection, crit);
249 public override void PostHurt(
bool pvp,
bool quiet,
double damage,
int hitDirection,
bool crit)
251 PostHurtEvent?.Invoke(pvp, quiet, damage, hitDirection, crit);
257 return CanHitNPCEvent?.Invoke(item, target) ?? base.CanHitNPC(item, target);
260 public delegate
void ModifyHitNPCEventRaiser(Item item, NPC target, ref
int damage, ref
float knockback, ref
bool crit);
262 public override void ModifyHitNPC(Item item, NPC target, ref
int damage, ref
float knockback, ref
bool crit)
264 ModifyHitNPCEvent?.Invoke(item, target, ref damage, ref knockback, ref crit);
268 public override bool CanHitPvp(Item item, Player target)
270 return CanHitPvpEvent?.Invoke(item, target) ?? base.CanHitPvp(item, target);
273 public delegate
void ModifyHitPvpEventRaiser(Item item, Player target, ref
int damage, ref
bool crit);
275 public override void ModifyHitPvp(Item item, Player target, ref
int damage, ref
bool crit)
277 ModifyHitPvpEvent?.Invoke(item, target, ref damage, ref crit);
281 public override void OnHitNPC(Item item, NPC target,
int damage,
float knockback,
bool crit)
283 OnHitNPCEvent?.Invoke(item, target, damage, knockback, crit);
289 return CanHitNPCWithProjEvent?.Invoke(proj, target) ?? base.CanHitNPCWithProj(proj, target);
292 public delegate
void ModifyHitNPCWithProjEventRaiser(Projectile proj, NPC target, ref
int damage, ref
float knockback, ref
bool crit, ref
int hitDirection);
294 public override void ModifyHitNPCWithProj(Projectile proj, NPC target, ref
int damage, ref
float knockback, ref
bool crit, ref
int hitDirection)
296 ModifyHitNPCWithProjEvent?.Invoke(proj, target, ref damage, ref knockback, ref crit, ref hitDirection);
300 public override void OnHitNPCWithProj(Projectile proj, NPC target,
int damage,
float knockback,
bool crit)
302 OnHitNPCWithProjEvent?.Invoke(proj, target, damage, knockback, crit);
306 public override void OnHitPvp(Item item, Player target,
int damage,
bool crit)
308 OnHitPvpEvent?.Invoke(item, target, damage, crit);
314 return CanHitPvpWithProjEvent?.Invoke(proj, target) ?? base.CanHitPvpWithProj(proj, target);
317 public delegate
void ModifyHitPvpWithProjEventRaiser(Projectile proj, Player target, ref
int damage, ref
bool crit);
321 ModifyHitPvpWithProjEvent?.Invoke(proj, target, ref damage, ref crit);
325 public override void OnHitPvpWithProj(Projectile proj, Player target,
int damage,
bool crit)
327 OnHitPvpWithProjEvent?.Invoke(proj, target, damage, crit);
330 public delegate
bool CanBeHitByNPCEventRaiser(NPC npc, ref
int cooldownSlot);
334 return CanBeHitByNPCEvent?.Invoke(npc, ref cooldownSlot) ?? base.CanBeHitByNPC(npc, ref cooldownSlot);
337 public delegate
void ModifyHitByNPCEventRaiser(NPC npc, ref
int damage, ref
bool crit);
341 ModifyHitByNPCEvent?.Invoke(npc, ref damage, ref crit);
344 public delegate
void ModifyWeaponDamageEventRaiser(Item item, ref
float add, ref
float mult, ref
float flat);
348 ModifyWeaponDamageEvent?.Invoke(item, ref add, ref mult, ref flat);
351 public delegate
void ModifyManaCostEventRaiser(Item item, ref
float reduce, ref
float mult);
355 ModifyManaCostEvent?.Invoke(item, ref reduce, ref mult);
359 public override void OnHitByNPC(NPC npc,
int damage,
bool crit)
361 OnHitByNPCEvent?.Invoke(npc, damage, crit);
367 return CanBeHitByProjectileEvent?.Invoke(proj) ?? base.CanBeHitByProjectile(proj);
370 public delegate
void ModifyHitByProjectileEventRaiser(Projectile projectile, ref
int damage, ref
bool crit);
374 ModifyHitByProjectileEvent?.Invoke(proj, ref damage, ref crit);
380 OnHitByProjectileEvent?.Invoke(proj, damage, crit);
383 public delegate
void CatchFishEventRaiser(Item fishingRod, Item bait,
int power,
int liquidType,
int poolSize,
int worldLayer,
int questFish, ref
int caughtType, ref
bool junk);
385 public override void CatchFish(Item fishingRod, Item bait,
int power,
int liquidType,
int poolSize,
int worldLayer,
int questFish, ref
int caughtType, ref
bool junk)
387 CatchFishEvent?.Invoke(fishingRod, bait, power, liquidType, poolSize, worldLayer, questFish, ref caughtType, ref junk);
390 public delegate
void GetFishingLevelEventRaiser(Item fishingRod, Item bait, ref
int fishingLevel);
392 public override void GetFishingLevel(Item fishingRod, Item bait, ref
int fishingLevel)
394 GetFishingLevelEvent?.Invoke(fishingRod, bait, ref fishingLevel);
400 AnglerQuestRewardEvent?.Invoke(rareMultiplier, rewardItems);
406 GetDyeTraderRewardEvent?.Invoke(rewardPool);
409 public delegate
void DrawEffectsEventRaiser(PlayerDrawInfo drawInfo, ref
float r, ref
float g, ref
float b, ref
float a, ref
bool fullBright);
411 public override void DrawEffects(PlayerDrawInfo drawInfo, ref
float r, ref
float g, ref
float b, ref
float a, ref
bool fullBright)
413 DrawEffectsEvent?.Invoke(drawInfo, ref r, ref g, ref b, ref a, ref fullBright);
416 public delegate
void ModifyDrawInfoEventRaiser(ref PlayerDrawInfo drawInfo);
420 ModifyDrawInfoEvent?.Invoke(ref drawInfo);
426 ModifyDrawLayersEvent?.Invoke(layers);
432 ModifyDrawHeadLayersEvent?.Invoke(layers);
438 ModifyScreenPositionEvent?.Invoke();
441 public delegate
void ModifyZoomEventRaiser(ref
float zoom);
445 ModifyZoomEvent?.Invoke(ref zoom);
448 public delegate
bool PreKillEventRaiser(
double damage,
int hitDirection,
bool pvp, ref
bool playSound, ref
bool genGore, ref PlayerDeathReason damageSource);
450 public override bool PreKill(
double damage,
int hitDirection,
bool pvp, ref
bool playSound, ref
bool genGore, ref PlayerDeathReason damageSource)
452 return PreKillEvent?.Invoke(damage, hitDirection, pvp, ref playSound, ref genGore, ref damageSource)
453 ?? base.PreKill(damage, hitDirection, pvp, ref playSound, ref genGore, ref damageSource);
456 public event Action<double, int, bool, PlayerDeathReason>
KillEvent;
457 public override void Kill(
double damage,
int hitDirection,
bool pvp, PlayerDeathReason damageSource)
459 KillEvent?.Invoke(damage, hitDirection, pvp, damageSource);
465 return PreItemCheckEvent?.Invoke() ?? base.PreItemCheck();
471 PostItemCheckEvent?.Invoke();
477 return UseTimeMultiplierEvent?.Invoke(item) ?? base.UseTimeMultiplier(item);
483 return MeleeSpeedMultiplierEvent?.Invoke(item) ?? base.MeleeSpeedMultiplier(item);
486 public delegate
void GetHealLifeEventRaiser(Item item,
bool quickHeal, ref
int healValue);
488 public override void GetHealLife(Item item,
bool quickHeal, ref
int healValue)
490 GetHealLifeEvent?.Invoke(item, quickHeal, ref healValue);
493 public delegate
void GetHealManaEventRaiser(Item item,
bool quickHeal, ref
int healValue);
495 public override void GetHealMana(Item item,
bool quickHeal, ref
int healValue)
497 GetHealManaEvent?.Invoke(item, quickHeal, ref healValue);
500 public delegate
void GetWeaponKnockbackEventRaiser(Item item, ref
float knockback);
504 GetWeaponKnockbackEvent?.Invoke(item, ref knockback);
507 public delegate
void GetWeaponCritEventRaiser(Item item, ref
int crit);
511 GetWeaponCritEvent?.Invoke(item, ref crit);
517 return ConsumeAmmoEvent?.Invoke(weapon, ammo) ?? base.ConsumeAmmo(weapon, ammo);
523 OnConsumeAmmoEvent?.Invoke(weapon, ammo);
526 public delegate
bool ShootEventRaiser(Item item, ref Vector2 position, ref
float speedX, ref
float speedY, ref
int type, ref
int damage, ref
float knockBack);
528 public override bool Shoot(Item item, ref Vector2 position, ref
float speedX, ref
float speedY, ref
int type, ref
int damage, ref
float knockBack)
530 return ShootEvent?.Invoke(item, ref position, ref speedX, ref speedY, ref type, ref damage, ref knockBack)
531 ?? base.Shoot(item, ref position, ref speedX, ref speedY, ref type, ref damage, ref knockBack);
537 MeleeEffectsEvent?.Invoke(item, hitbox);
543 OnHitAnythingEvent?.Invoke(x, y, victim);
ModifyNurseHealEventRaiser ModifyNurseHealEvent
UpdateEquipsEventRaiser UpdateEquipsEvent
Action< TriggersSet > ProcessTriggersEvent
ModifyHitNPCWithProjEventRaiser ModifyHitNPCWithProjEvent
override void UpdateEquips(ref bool wallSpeedBuff, ref bool tileSpeedBuff, ref bool tileRangeBuff)
Action UpdateVanityAccessoriesEvent
override void UpdateLifeRegen()
override void NaturalLifeRegen(ref float regen)
override void ModifyHitNPC(Item item, NPC target, ref int damage, ref float knockback, ref bool crit)
Action< float, float, Entity > OnHitAnythingEvent
DrawEffectsEventRaiser DrawEffectsEvent
Action ModifyScreenPositionEvent
override void DrawEffects(PlayerDrawInfo drawInfo, ref float r, ref float g, ref float b, ref float a, ref bool fullBright)
override bool CanBeHitByNPC(NPC npc, ref int cooldownSlot)
override void ModifyDrawHeadLayers(List< PlayerHeadLayer > layers)
override void GetFishingLevel(Item fishingRod, Item bait, ref int fishingLevel)
override void Initialize()
ModifyHitNPCEventRaiser ModifyHitNPCEvent
override void OnHitPvp(Item item, Player target, int damage, bool crit)
override void OnHitPvpWithProj(Projectile proj, Player target, int damage, bool crit)
Action< float, List< Item > > AnglerQuestRewardEvent
override void ModifyManaCost(Item item, ref float reduce, ref float mult)
GetHealManaEventRaiser GetHealManaEvent
override bool ConsumeAmmo(Item weapon, Item ammo)
Action UpdateAutopauseEvent
Func< Projectile, Player, bool > CanHitPvpWithProjEvent
Action< double, int, bool, PlayerDeathReason > KillEvent
ModifierEffect GetEffect(Type type)
override void GetHealMana(Item item, bool quickHeal, ref int healValue)
override void CatchFish(Item fishingRod, Item bait, int power, int liquidType, int poolSize, int worldLayer, int questFish, ref int caughtType, ref bool junk)
override void ModifyDrawInfo(ref PlayerDrawInfo drawInfo)
override void PostUpdateBuffs()
Action< Item, Rectangle > MeleeEffectsEvent
Action< List< int > > GetDyeTraderRewardEvent
ModifyNursePriceEventRaiser ModifyNursePriceEvent
override bool PreHurt(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)
Func< Item, float > MeleeSpeedMultiplierEvent
Action PostUpdateMiscEffectsEvent
override void PreUpdateBuffs()
override bool PreItemCheck()
override void OnRespawn(Player player)
override void GetDyeTraderReward(List< int > rewardPool)
override float MeleeSpeedMultiplier(Item item)
A ModifierEffect signifies the effect of a modifier on a player It should house the implementation...
override void ModifyWeaponDamage(Item item, ref float add, ref float mult, ref float flat)
Action< List< PlayerLayer > > ModifyDrawLayersEvent
override void PostUpdateRunSpeeds()
GetWeaponKnockbackEventRaiser GetWeaponKnockbackEvent
override void PreUpdate()
override void ModifyHitPvpWithProj(Projectile proj, Player target, ref int damage, ref bool crit)
override void SyncPlayer(int toWho, int fromWho, bool newPlayer)
ModifyHitByNPCEventRaiser ModifyHitByNPCEvent
override void PostUpdate()
override void UpdateBadLifeRegen()
override void UpdateAutopause()
override void PostItemCheck()
override void OnHitNPC(Item item, NPC target, int damage, float knockback, bool crit)
Action< bool, bool, double, int, bool > PostHurtEvent
IList< ModifierEffect > _modifierEffects
override bool Shoot(Item item, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
Func< Projectile, bool > CanBeHitByProjectileEvent
ModifyWeaponDamageEventRaiser ModifyWeaponDamageEvent
Action PreUpdateBuffsEvent
override void UpdateDead()
ShootEventRaiser ShootEvent
GetHealLifeEventRaiser GetHealLifeEvent
ModifyZoomEventRaiser ModifyZoomEvent
Func< Item, NPC, bool?> CanHitNPCEvent
ModifyHitByProjectileEventRaiser ModifyHitByProjectileEvent
override bool CanHitNPCWithProj(Projectile proj, NPC target)
override void Hurt(bool pvp, bool quiet, double damage, int hitDirection, bool crit)
override void PostUpdateMiscEffects()
Action< Projectile, Player, int, bool > OnHitPvpWithProjEvent
override void AnglerQuestReward(float rareMultiplier, List< Item > rewardItems)
override void ResetEffects()
override bool CanHitNPC(Item item, NPC target)
override void SendClientChanges(ModPlayer clientPlayer)
override void OnHitByProjectile(Projectile proj, int damage, bool crit)
override void ModifyHitByProjectile(Projectile proj, ref int damage, ref bool crit)
override void ModifyHitNPCWithProj(Projectile proj, NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection)
override void Kill(double damage, int hitDirection, bool pvp, PlayerDeathReason damageSource)
Func< bool > PreItemCheckEvent
override bool ModifyNurseHeal(NPC nurse, ref int health, ref bool removeDebuffs, ref string chatText)
Action< bool, bool, double, int, bool > HurtEvent
override void OnHitNPCWithProj(Projectile proj, NPC target, int damage, float knockback, bool crit)
CanBeHitByNPCEventRaiser CanBeHitByNPCEvent
Action PostItemCheckEvent
override void MeleeEffects(Item item, Rectangle hitbox)
override void GetWeaponKnockback(Item item, ref float knockback)
GetFishingLevelEventRaiser GetFishingLevelEvent
GetWeaponCritEventRaiser GetWeaponCritEvent
PreKillEventRaiser PreKillEvent
override void ProcessTriggers(TriggersSet triggersSet)
Caches the item held and items equipped by players. When equips and held items change, their respective modifiers' effects are automatically called to detach and attach their delegations.
override void ModifyScreenPosition()
Action< Projectile, NPC, int, float, bool > OnHitNPCWithProjEvent
Func< Projectile, NPC, bool?> CanHitNPCWithProjEvent
override void OnConsumeAmmo(Item weapon, Item ammo)
Action< NPC, int, bool > OnHitByNPCEvent
override bool CanHitPvp(Item item, Player target)
override void PreUpdateMovement()
override bool ShiftClickSlot(Item[] inventory, int context, int slot)
Action< Player > OnRespawnEvent
override void OnHitByNPC(NPC npc, int damage, bool crit)
Action< Projectile, int, bool > OnHitByProjectileEvent
static ModifierEffectContent ModifierEffect
override bool CanHitPvpWithProj(Projectile proj, Player target)
override void PostNurseHeal(NPC nurse, int health, bool removeDebuffs, int price)
override void FrameEffects()
override void ModifyDrawLayers(List< PlayerLayer > layers)
Action< Item, NPC, int, float, bool > OnHitNPCEvent
override float UseTimeMultiplier(Item item)
override bool PreKill(double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource)
Action PostUpdateEquipsEvent
ModifyHitPvpEventRaiser ModifyHitPvpEvent
Action< NPC, int, bool, int > PostNurseHealEvent
override void OnHitAnything(float x, float y, Entity victim)
override void SetControls()
NaturalLifeRegenEventRaiser NaturalLifeRegenEvent
override void GetWeaponCrit(Item item, ref int crit)
Action PostUpdateRunSpeedsEvent
override void ModifyHitByNPC(NPC npc, ref int damage, ref bool crit)
ModifyHitPvpWithProjEventRaiser ModifyHitPvpWithProjEvent
override void ModifyZoom(ref float zoom)
CatchFishEventRaiser CatchFishEvent
Func< Item[], int, int, bool > ShiftClickSlotEvent
Action UpdateBadLifeRegenEvent
override void UpdateVanityAccessories()
This class holds all Content holders of this mod You can use this to access content loaded into the m...
PreHurtEventRaiser PreHurtEvent
Action< List< PlayerHeadLayer > > ModifyDrawHeadLayersEvent
ModifyDrawInfoEventRaiser ModifyDrawInfoEvent
override void ModifyHitPvp(Item item, Player target, ref int damage, ref bool crit)
override bool CanBeHitByProjectile(Projectile proj)
Func< Item, Item, bool > ConsumeAmmoEvent
Holds player-entity data and handles it
override void PostHurt(bool pvp, bool quiet, double damage, int hitDirection, bool crit)
Action PreUpdateMovementEvent
Action< Item, Item > OnConsumeAmmoEvent
Func< Item, float > UseTimeMultiplierEvent
Action< ModPlayer > SendClientChangesEvent
override void ModifyNursePrice(NPC nurse, int health, bool removeDebuffs, ref int price)
Func< Item, Player, bool > CanHitPvpEvent
Action PostUpdateBuffsEvent
Action< int, int, bool > SyncPlayerEvent
Action UpdateLifeRegenEvent
override void GetHealLife(Item item, bool quickHeal, ref int healValue)
ModifyManaCostEventRaiser ModifyManaCostEvent
Action< Item, Player, int, bool > OnHitPvpEvent
override void PostUpdateEquips()