-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModEnergyProjectile.cs
More file actions
66 lines (56 loc) · 2.47 KB
/
Copy pathModEnergyProjectile.cs
File metadata and controls
66 lines (56 loc) · 2.47 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
54
55
56
57
58
59
60
61
62
63
64
65
66
using System;
using CoreLib;
using CoreLib.Components;
using Il2CppInterop.Runtime.InteropTypes.Fields;
using UnityEngine;
namespace PainMod
{
public class ModEnergyProjectile : ModProjectile
{
public Il2CppReferenceField<Transform> directionTransform;
public Il2CppReferenceField<ParticleSystem> projectileFx;
public Il2CppReferenceField<ParticleSystem> fireballSmoke;
public Il2CppReferenceField<ParticleSystem> fireballFireTrail;
public Il2CppReferenceField<ParticleSystem> hit;
public Il2CppReferenceField<PugLight> fireLight;
public ModEnergyProjectile(IntPtr ptr) : base(ptr) { }
public override void OnOccupied()
{
Plugin.logger.LogInfo("Projectile is On Occupied, check for crashes please!");
//this.CallBase<Projectile>(nameof(OnOccupied));
int health = currentHealth;
directionTransform.Value.gameObject.SetActive(health > 0);
if (health <= 0) return;
AudioManager.Sfx(SfxID.fireball, transform.position, 0.8f, 1, 0.1f);
AudioManager.Sfx(SfxID.anicentDevicePowerUp, transform.position, 0.6f, 0.7f, 0.1f);
ProjectileCD projectileCd = EntityUtility.GetComponentData<ProjectileCD>(entity, world);
Vector3 dir = projectileCd.direction * 0.3f;
Vector3 renderPos = ToRenderFromWorld(WorldPosition);
Vector3 puffPos = renderPos + directionTransform.Value.localPosition + dir;
Manager.effects.PlayPuff(PuffID.SmallEnergyExplosion, puffPos);
dir = directionTransform.Value.position + (Vector3)projectileCd.direction;
directionTransform.Value.transform.LookAt(dir, Vector3.up);
projectileFx.Value.Play();
if (fireballSmoke.Value != null)
fireballSmoke.Value.Play();
if (fireballFireTrail.Value != null)
fireballFireTrail.Value.Play();
fireLight.Value.gameObject.SetActive(true);
}
public override void OnDeath()
{
this.CallBase<Projectile>(nameof(OnDeath));
if (projectileFx.Value != null && hit.Value != null)
{
projectileFx.Value.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear);
if (fireballSmoke.Value != null)
fireballSmoke.Value.Stop();
if (fireballFireTrail.Value != null)
fireballFireTrail.Value.Stop();
hit.Value.Play();
}
fireLight.Value.gameObject.SetActive(false);
SpawnFadeOutLight(fireLight.Value.lightToOptimize);
}
}
}