-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStatManager.cs
More file actions
104 lines (89 loc) · 3.03 KB
/
Copy pathStatManager.cs
File metadata and controls
104 lines (89 loc) · 3.03 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using ModdingUtils.MonoBehaviours;
namespace ModsPlus
{
public class StatManager
{
public static StatChangeTracker Apply(Player player, StatChanges stats)
{
var effect = player.gameObject.AddComponent<TemporaryEffect>();
return effect.Initialize(stats);
}
public static void Remove(StatChangeTracker status)
{
if (!status.active) return;
UnityEngine.Object.Destroy(status.effect);
}
}
public class StatChangeTracker
{
public bool active;
internal TemporaryEffect effect;
internal StatChangeTracker(TemporaryEffect effect)
{
this.effect = effect;
}
}
[Serializable]
public class StatChanges
{
/// <summary>
/// Additive
/// </summary>
public int
Bullets = 0,
Jumps = 0,
MaxAmmo = 0;
/// <summary>
/// Multiplicative
/// </summary>
public float
AttackSpeed = 1,
PlayerGravity = 1,
MovementSpeed = 1,
ProjectileGravity = 1,
Damage = 1,
PlayerSize = 1,
MaxHealth = 1,
BulletSpread = 1,
BulletSpeed = 1,
JumpHeight = 1;
}
internal class TemporaryEffect : ReversibleEffect
{
private StatChanges statChanges;
private StatChangeTracker status;
public StatChangeTracker Initialize(StatChanges stats)
{
this.statChanges = stats;
this.status = new StatChangeTracker(this);
return status;
}
public override void OnStart()
{
characterStatModifiersModifier.sizeMultiplier_mult = statChanges.PlayerSize;
characterStatModifiersModifier.movementSpeed_mult = statChanges.MovementSpeed;
characterStatModifiersModifier.jump_mult = statChanges.JumpHeight;
characterDataModifier.numberOfJumps_add = statChanges.Jumps;
characterDataModifier.maxHealth_mult = statChanges.MaxHealth;
gravityModifier.gravityForce_mult = statChanges.PlayerGravity;
gunStatModifier.numberOfProjectiles_add = statChanges.Bullets;
gunStatModifier.spread_mult = statChanges.BulletSpread;
gunStatModifier.attackSpeed_mult = statChanges.AttackSpeed;
gunStatModifier.gravity_mult = statChanges.ProjectileGravity;
gunStatModifier.damage_mult = statChanges.Damage;
gunStatModifier.projectileSpeed_mult = statChanges.BulletSpeed;
gunAmmoStatModifier.maxAmmo_add = statChanges.MaxAmmo;
status.active = true;
}
public override void OnOnDestroy()
{
status.active = false;
}
}
}