/
MyProjectile.cs
53 lines (40 loc) · 1.41 KB
/
MyProjectile.cs
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 System;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;
using Terraria.ModLoader.Config;
using HamstarHelpers.Helpers.Debug;
namespace DestructibleTiles {
partial class DestructibleTilesProjectile : GlobalProjectile {
public override void AI( Projectile projectile ) {
if( projectile.aiStyle == 84 ) { // <- Beam weapons!
this.BehaviorAsBeam( projectile );
}
}
////////////////
public override void Kill( Projectile projectile, int timeLeft ) {
if( timeLeft > 3 ) { return; }
var config = DestructibleTilesConfig.Instance;
var projDef = new ProjectileDefinition( projectile.type );
bool isExplosive = config.ProjectilesAsAoE.ContainsKey( projDef );
if( isExplosive ) {
this.BehaviorAsAoE( projectile );
}
}
////////////////
public override bool OnTileCollide( Projectile projectile, Vector2 oldVelocity ) {
var config = DestructibleTilesConfig.Instance;
var projDef = new ProjectileDefinition( projectile.type );
// Explosives are handled elsewhere
if( config.ProjectilesAsAoE.ContainsKey( projDef ) ) {
return base.OnTileCollide( projectile, oldVelocity );
}
bool _;
if( !DestructibleTilesProjectile.CanHitTiles(projectile, out _) ) {
return base.OnTileCollide( projectile, oldVelocity );
}
this.BehaviorAsKinetic( projectile, oldVelocity );
return base.OnTileCollide( projectile, oldVelocity );
}
}
}