-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
ModAssets.cs
82 lines (69 loc) · 1.9 KB
/
ModAssets.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
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
using FUtility;
using FUtility.FUI;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
namespace SpookyPumpkinSO
{
public class ModAssets
{
public static readonly Tag buildingPumpkinTag = TagManager.Create("SP_BuildPumpkin", STRINGS.ITEMS.FOOD.SP_PUMPKIN.NAME);
public static HashSet<Tag> pipTreats;
public class Prefabs
{
public static GameObject sideScreenPrefab;
}
public static class Colors
{
public static Color
pumpkinOrange = Util.ColorFromHex("ffa63b"),
ghostlyColor = new Color(0, 0.8f, 1.0f),
transparentTint = new Color(1f, 1f, 1f, 0.4f);
}
public static class Sounds
{
public const string
CHEER = "SpookyPumpkin_Cheers",
EVILLAUGH = "SpookyPumpkin_EvilLaugh";
}
public static string ModPath { get; internal set; }
public static void LateLoadAssets()
{
var bundle = FAssets.LoadAssetBundle("sp_uiasset");
Prefabs.sideScreenPrefab = bundle.LoadAsset<GameObject>("GhostPipSideScreen");
TMPConverter.ReplaceAllText(Prefabs.sideScreenPrefab, false);
var path = Path.Combine(Utils.ModPath, "assets");
AudioUtil.LoadSound(Sounds.CHEER, Path.Combine(path, "333404__jayfrosting__cheer-2.wav"));
AudioUtil.LoadSound(Sounds.EVILLAUGH, Path.Combine(path, "236982__devengarber__jacob-allen-evil-laugh.wav"));
}
public static List<string> ReadPipTreats()
{
return ReadJSON("piptreats", out var json)
? JsonConvert.DeserializeObject<List<string>>(json) :
([]);
}
private static bool ReadJSON(string filename, out string json, bool log = true)
{
json = null;
try
{
using (var r = new StreamReader(Path.Combine(ModPath, filename + ".json")))
{
json = r.ReadToEnd();
}
}
catch (Exception e)
{
if (log)
{
Log.Warning($"Couldn't read {filename}.json, {e.Message}. Using defaults.");
}
return false;
}
return true;
}
}
}