-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtilities.cs
110 lines (103 loc) · 3.72 KB
/
Utilities.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using Nautilus.Assets;
using Nautilus.Utility;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using UnityEngine;
namespace CureBlade
{
internal class Utilities
{
/// <summary>
/// Creates the prefab info from information supplied.
/// </summary>
/// Credit to Ramune for this, check out his github https://github.com/RamuneNeptune
public static PrefabInfo CreatePrefabInfo(string id, string name, string description, Atlas.Sprite sprite, int sizeX, int sizeY)
{
return PrefabInfo
.WithTechType(id, name, description)
.WithIcon(sprite)
.WithSizeInInventory(new Vector2int(sizeX, sizeY));
}
/// <summary>
/// Gets a sprite from the Assets folder by string
/// </summary>
/// <param name="filename"></param>
/// <returns>A <see cref="Texture2D"/></returns>
/// Credit to Ramune for this, check out his github https://github.com/RamuneNeptune
public static Texture2D GetTexture(string filename) => ImageUtils.LoadTextureFromFile(IOUtilities.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Assets", filename + ".png"));
/// <summary>
/// Get a sprite from the game by TechType, or from the Assets folder by string
/// </summary>
/// <param name="FileOrTechType"></param>
/// <returns>An <see cref="Atlas.Sprite"/></returns>
/// <exception cref="ArgumentException"></exception>
/// Credit to Ramune for this, check out his github https://github.com/RamuneNeptune
public static Atlas.Sprite GetSprite(object FileOrTechType)
{
if (FileOrTechType is TechType techType) return SpriteManager.Get(techType);
else if (FileOrTechType is string filename) return ImageUtils.LoadSpriteFromFile(IOUtilities.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Assets", filename + ".png"));
else throw new ArgumentException($"Incorrect type of '{FileOrTechType}' used in Sprite.Get()");
}
public static readonly Dictionary<TechType, TechType> curedCreatureList = new Dictionary<TechType, TechType>(TechTypeExtensions.sTechTypeComparer)
{
{
TechType.Bladderfish,
TechType.CuredBladderfish
},
{
TechType.Boomerang,
TechType.CuredBoomerang
},
{
TechType.LavaBoomerang,
TechType.CuredLavaBoomerang
},
{
TechType.Eyeye,
TechType.CuredEyeye
},
{
TechType.LavaEyeye,
TechType.CuredLavaEyeye
},
{
TechType.GarryFish,
TechType.CuredGarryFish
},
{
TechType.HoleFish,
TechType.CuredHoleFish
},
{
TechType.Hoopfish,
TechType.CuredHoopfish
},
{
TechType.Hoverfish,
TechType.CuredHoverfish
},
{
TechType.Oculus,
TechType.CuredOculus
},
{
TechType.Peeper,
TechType.CuredPeeper
},
{
TechType.Reginald,
TechType.CuredReginald
},
{
TechType.Spadefish,
TechType.CuredSpadefish
},
{
TechType.Spinefish,
TechType.CookedSpinefish
}
};
}
}