forked from TheMysticSword/MysticsRisky2Utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOverlays.cs
51 lines (46 loc) · 1.58 KB
/
Overlays.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
using RoR2;
using R2API.Utils;
using UnityEngine;
using System.Collections.Generic;
namespace MysticsRisky2Utils
{
public static class Overlays
{
public struct OverlayInfo
{
public Material material;
public System.Func<CharacterModel, bool> condition;
public OverlayInfo(Material material, System.Func<CharacterModel, bool> condition)
{
this.material = material;
this.condition = condition;
}
}
public static List<OverlayInfo> overlays = new List<OverlayInfo>();
internal static void Init()
{
On.RoR2.CharacterModel.UpdateOverlays += (orig, self) =>
{
orig(self);
if (self.body)
{
foreach (OverlayInfo overlayInfo in overlays)
{
if (self.activeOverlayCount >= CharacterModel.maxOverlays) return;
if (overlayInfo.condition(self))
{
Material[] array = self.currentOverlays;
int num = self.activeOverlayCount;
self.activeOverlayCount = num + 1;
array[num] = overlayInfo.material;
}
}
}
};
}
public static void CreateOverlay(Material material, System.Func<CharacterModel, bool> condition)
{
overlays.Add(new OverlayInfo(material, condition));
}
}
}