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

◆ CollideWithNPCs()

int Terraria.Player.CollideWithNPCs ( Rectangle myRect,
float Damage,
float Knockback,
int NPCImmuneTime,
int PlayerImmuneTime,
DamageClass? damageType = null )
inline

Definition at line 18859 of file Player.cs.

18860 {
18861 //IL_0052: Unknown result type (might be due to invalid IL or missing references)
18862 //IL_0057: Unknown result type (might be due to invalid IL or missing references)
18863 //IL_005a: Unknown result type (might be due to invalid IL or missing references)
18864 //IL_006e: Unknown result type (might be due to invalid IL or missing references)
18865 //IL_0080: Unknown result type (might be due to invalid IL or missing references)
18866 int num = 0;
18867 for (int i = 0; i < 200; i++)
18868 {
18869 NPC nPC = Main.npc[i];
18870 if (!nPC.active || nPC.dontTakeDamage || nPC.friendly || nPC.immune[whoAmI] != 0 || !CanNPCBeHitByPlayerOrPlayerProjectile(nPC))
18871 {
18872 continue;
18873 }
18874 Rectangle rect = nPC.getRect();
18875 if (((Rectangle)(ref myRect)).Intersects(rect) && (nPC.noTileCollide || Collision.CanHit(position, width, height, nPC.position, nPC.width, nPC.height)))
18876 {
18877 int num2 = direction;
18878 if (velocity.X < 0f)
18879 {
18880 num2 = -1;
18881 }
18882 if (velocity.X > 0f)
18883 {
18884 num2 = 1;
18885 }
18886 if (whoAmI == Main.myPlayer)
18887 {
18888 ApplyDamageToNPC(nPC, (int)Damage, Knockback, num2, crit: false, damageType);
18889 }
18890 nPC.immune[whoAmI] = NPCImmuneTime;
18892 num++;
18893 break;
18894 }
18895 }
18896 return num;
18897 }
int whoAmI
The index of this Entity within its specific array. These arrays track the entities in the world....
Definition Entity.cs:16
Vector2 velocity
The velocity of this Entity in world coordinates per tick.
Definition Entity.cs:33
Vector2 position
The position of this Entity in world coordinates.
Definition Entity.cs:28
int width
The width of this Entity's hitbox, in pixels.
Definition Entity.cs:46
int height
The height of this Entity's hitbox, in pixels.
Definition Entity.cs:51
bool CanNPCBeHitByPlayerOrPlayerProjectile(NPC npc, Projectile projectile=null)
Definition Player.cs:19013
void ApplyDamageToNPC(NPC npc, int damage, float knockback, int direction, bool crit=false, DamageClass? damageType=null, bool damageVariation=false)
Deals damage to an NPC (and syncs the hit in multiplayer). The damage will be affected by modifiers...
Definition Player.cs:18941
void GiveImmuneTimeForCollisionAttack(int time)
Definition Player.cs:18994

References Terraria.Player.ApplyDamageToNPC(), Terraria.Collision.CanHit(), Terraria.Player.CanNPCBeHitByPlayerOrPlayerProjectile(), Terraria.GameContent.Damage, Terraria.Entity.direction, Terraria.Player.GiveImmuneTimeForCollisionAttack(), Terraria.Entity.height, Terraria.Main.myPlayer, Terraria.Main.npc, Terraria.Entity.position, Terraria.Entity.velocity, Terraria.Entity.whoAmI, and Terraria.Entity.width.

Referenced by Terraria.Player.HorizontalMovement(), and Terraria.Player.MowTheLawn().

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