This repository was archived by the owner on Nov 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMovingPlatform.cs
More file actions
53 lines (49 loc) · 1.7 KB
/
MovingPlatform.cs
File metadata and controls
53 lines (49 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using Microsoft.Xna.Framework;
using System.Linq;
using Terraria;
using Terraria.ModLoader;
namespace IceKracken
{
abstract class MovingPlatform : ModNPC
{
public virtual void SafeSetDefaults() { }
public override void SetStaticDefaults()
{
DisplayName.SetDefault("");
}
public sealed override void SetDefaults()
{
SafeSetDefaults();
npc.lifeMax = 1;
npc.immortal = true;
npc.dontTakeDamage = true;
npc.noGravity = true;
npc.knockBackResist = 0; //very very important!!
npc.aiStyle = -1;
}
public override bool CheckActive()
{
return false;
}
public virtual void SafeAI() { }
public sealed override void AI()
{
SafeAI();
foreach (Player player in Main.player)
{
if (new Rectangle((int)player.position.X, (int)player.position.Y + (player.height - 2), player.width, 4).Intersects
(new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, 4)) && player.position.Y <= npc.position.Y)
{
player.position += npc.velocity;
}
}
foreach(Projectile proj in Main.projectile.Where(n => n.active && n.aiStyle == 7 && n.ai[0] != 1 && n.timeLeft <36000 - 3 && n.Hitbox.Intersects(npc.Hitbox)))
{
proj.ai[0] = 2;
proj.netUpdate = true;
}
}
public override bool? CanBeHitByProjectile(Projectile projectile) => false;
public override bool? CanBeHitByItem(Player player, Item item) => false;
}
}