Skip to content

Commit 63b8510

Browse files
authored
Merge pull request #76 from MaxtorCoder/npc-appearance
feat: Implement custom/existing NPC appearance system
2 parents be5cbee + 794457f commit 63b8510

35 files changed

Lines changed: 1080 additions & 4 deletions
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using S1API.Entities.Appearances.Base;
2+
using System.Reflection;
3+
4+
namespace S1API.Entities.Appearances.AccessoryFields
5+
{
6+
/// <summary>
7+
/// The Bottom index in AvatarSettings::AccessorySettings
8+
/// </summary>
9+
public class Bottom : BaseAccessoryAppearance
10+
{
11+
public const string LongSkirt = "Avatar/Accessories/Bottom/LongSkirt/LongSkirt";
12+
public const string MediumSkirt = "Avatar/Accessories/Bottom/MediumSkirt/MediumSkirt";
13+
}
14+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using S1API.Entities.Appearances.Base;
2+
3+
namespace S1API.Entities.Appearances.AccessoryFields
4+
{
5+
/// <summary>
6+
/// The Chest index in AvatarSettings::AccessorySettings
7+
/// </summary>
8+
public class Chest : BaseAccessoryAppearance
9+
{
10+
public const string Blazer = "Avatar/Accessories/Chest/Blazer/Blazer";
11+
public const string BulletProofVest = "Avatar/Accessories/Chest/BulletProofVest/BulletProofVest";
12+
public const string BulletProofVestPolice = "Avatar/Accessories/Chest/BulletProofVest/BulletProofVest_Police";
13+
public const string CollarJacket = "Avatar/Accessories/Chest/CollarJacket/CollarJacket";
14+
public const string OpenVest = "Avatar/Accessories/Chest/OpenVest/OpenVest";
15+
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using S1API.Entities.Appearances.Base;
2+
3+
namespace S1API.Entities.Appearances.AccessoryFields
4+
{
5+
/// <summary>
6+
/// The Feet index in AvatarSettings::AccessorySettings
7+
/// </summary>
8+
public class Feet : BaseAccessoryAppearance
9+
{
10+
public const string CombatShoes = "Avatar/Accessories/Feet/CombatShoes/CombatShoes";
11+
public const string DressShoes = "Avatar/Accessories/Feet/DressShoes/DressShoes";
12+
public const string Flats = "Avatar/Accessories/Feet/Flats/Flats";
13+
public const string Sandals = "Avatar/Accessories/Feet/Sandals/Sandals";
14+
public const string Sneakers = "Avatar/Accessories/Feet/Sneakers/Sneakers";
15+
}
16+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using S1API.Entities.Appearances.Base;
2+
3+
namespace S1API.Entities.Appearances.AccessoryFields
4+
{
5+
/// <summary>
6+
/// The Hands index in AvatarSettings::AccessorySettings
7+
/// </summary>
8+
public class Hands : BaseAccessoryAppearance
9+
{
10+
public const string Polex = "Avatar/Accessories/Hands/Polex/Polex";
11+
}
12+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using S1API.Entities.Appearances.Base;
2+
3+
namespace S1API.Entities.Appearances.AccessoryFields
4+
{
5+
/// <summary>
6+
/// The Head index in AvatarSettings::AccessorySettings
7+
/// </summary>
8+
public class Head : BaseAccessoryAppearance
9+
{
10+
public const string BucketHat = "Avatar/Accessories/Head/BucketHat/BucketHat";
11+
public const string Cap = "Avatar/Accessories/Head/Cap/Cap";
12+
public const string CapFastFood = "Avatar/Accessories/Head/Cap/Cap_FastFood";
13+
public const string ChefHat = "Avatar/Accessories/Head/ChefHat/ChefHat";
14+
public const string CowboyHat = "Avatar/Accessories/Head/Cowboy/CowboyHat";
15+
public const string FlatCap = "Avatar/Accessories/Head/FlatCap/FlatCap";
16+
public const string LegendSunglasses = "Avatar/Accessories/Head/LegendSunglasses/LegendSunglasses";
17+
public const string Oakleys = "Avatar/Accessories/Head/Oakleys/Oakleys";
18+
public const string PoliceCap = "Avatar/Accessories/Head/PoliceCap/PoliceCap";
19+
public const string PorkpieHat = "Avatar/Accessories/Head/PorkpieHat/PorkpieHat";
20+
public const string RectangleFrameGlasses = "Avatar/Accessories/Head/RectangleFrameGlasses/RectangleFrameGlasses";
21+
public const string Respirator = "Avatar/Accessories/Head/Respirator/Respirator";
22+
public const string SaucePan = "Avatar/Accessories/Head/SaucePan/SaucePan";
23+
public const string SmallRoundGlasses = "Avatar/Accessories/Head/SmallRoundGlasses/SmallRoundGlasses";
24+
}
25+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using S1API.Entities.Appearances.Base;
2+
3+
namespace S1API.Entities.Appearances.AccessoryFields
4+
{
5+
/// <summary>
6+
/// The Neck index in AvatarSettings::AccessorySettings
7+
/// </summary>
8+
public class Neck : BaseAccessoryAppearance
9+
{
10+
public const string GoldChain = "Avatar/Accessories/Neck/GoldChain/GoldChain";
11+
}
12+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using S1API.Entities.Appearances.Base;
2+
3+
namespace S1API.Entities.Appearances.AccessoryFields
4+
{
5+
/// <summary>
6+
/// The Waist index in AvatarSettings::AccessorySettings
7+
/// </summary>
8+
public class Waist : BaseAccessoryAppearance
9+
{
10+
public const string Apron = "Avatar/Accessories/Waist/Apron/Apron";
11+
public const string Belt = "Avatar/Accessories/Waist/Belt/Belt";
12+
public const string HazmatSuit = "Avatar/Accessories/Waist/HazmatSuit/HazmatSuit";
13+
public const string PoliceBelt = "Avatar/Accessories/Waist/PoliceBelt/PoliceBelt";
14+
public const string PriestGown = "Avatar/Accessories/Neck/PriestGown/PriestGown";
15+
}
16+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Reflection;
4+
5+
namespace S1API.Entities.Appearances.Base
6+
{
7+
/// <summary>
8+
/// The base accessory appearance class
9+
/// </summary>
10+
/// <remarks>This is used to track the properties within the AvatarSettings</remarks>
11+
public class BaseAccessoryAppearance
12+
{
13+
private static readonly Dictionary<Type, List<string>> _constCache = new Dictionary<Type, List<string>>();
14+
15+
/// <summary>
16+
/// Retrieves and caches all public <c>const string</c> fields defined in the specified type <typeparamref name="T"/>.
17+
/// </summary>
18+
/// <typeparam name="T">
19+
/// The type from which to retrieve constant string fields. Must inherit from <see cref="BaseAccessoryAppearance"/>.
20+
/// </typeparam>
21+
/// <returns>
22+
/// A list of constant string values defined in the type <typeparamref name="T"/>.
23+
/// </returns>
24+
/// <remarks>
25+
/// Uses reflection to gather constants and caches them for future calls to improve performance.
26+
/// </remarks>
27+
internal static List<string> GetConstPaths<T>() where T : BaseAccessoryAppearance
28+
{
29+
var type = typeof(T);
30+
if (_constCache.TryGetValue(type, out var cached))
31+
return cached;
32+
33+
var consts = new List<string>();
34+
var fields = type.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy);
35+
foreach (var field in fields)
36+
{
37+
if (field is { IsLiteral: true, IsInitOnly: false } && field.FieldType == typeof(string))
38+
consts.Add((string)field.GetRawConstantValue());
39+
}
40+
41+
_constCache[type] = consts;
42+
return consts;
43+
}
44+
}
45+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Reflection;
4+
5+
namespace S1API.Entities.Appearances.Base
6+
{
7+
/// <summary>
8+
/// The base appearance class
9+
/// </summary>
10+
/// <remarks>This is used to track the properties within the AvatarSettings</remarks>
11+
public class BaseAppearance
12+
{
13+
private static readonly Dictionary<Type, List<string>> _constCache = new Dictionary<Type, List<string>>();
14+
15+
/// <summary>
16+
/// Retrieves and caches all public <c>const string</c> fields defined in the specified type <typeparamref name="T"/>.
17+
/// </summary>
18+
/// <typeparam name="T">
19+
/// The type from which to retrieve constant string fields. Must inherit from <see cref="BaseAppearance"/>.
20+
/// </typeparam>
21+
/// <returns>
22+
/// A list of constant string values defined in the type <typeparamref name="T"/>.
23+
/// </returns>
24+
/// <remarks>
25+
/// Uses reflection to gather constants and caches them for future calls to improve performance.
26+
/// </remarks>
27+
internal static List<string> GetConstPaths<T>() where T : BaseAppearance
28+
{
29+
var type = typeof(T);
30+
if (_constCache.TryGetValue(type, out var cached))
31+
return cached;
32+
33+
var consts = new List<string>();
34+
var fields = type.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy);
35+
foreach (var field in fields)
36+
{
37+
if (field is { IsLiteral: true, IsInitOnly: false } && field.FieldType == typeof(string))
38+
consts.Add((string)field.GetRawConstantValue());
39+
}
40+
41+
_constCache[type] = consts;
42+
return consts;
43+
}
44+
}
45+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Reflection;
4+
5+
namespace S1API.Entities.Appearances.Base
6+
{
7+
/// <summary>
8+
/// The base body appearance class
9+
/// </summary>
10+
/// <remarks>This is used to track the properties within the AvatarSettings</remarks>
11+
public class BaseBodyAppearance
12+
{
13+
private static readonly Dictionary<Type, List<string>> _constCache = new Dictionary<Type, List<string>>();
14+
15+
/// <summary>
16+
/// Retrieves and caches all public <c>const string</c> fields defined in the specified type <typeparamref name="T"/>.
17+
/// </summary>
18+
/// <typeparam name="T">
19+
/// The type from which to retrieve constant string fields. Must inherit from <see cref="BaseBodyAppearance"/>.
20+
/// </typeparam>
21+
/// <returns>
22+
/// A list of constant string values defined in the type <typeparamref name="T"/>.
23+
/// </returns>
24+
/// <remarks>
25+
/// Uses reflection to gather constants and caches them for future calls to improve performance.
26+
/// </remarks>
27+
internal static List<string> GetConstPaths<T>() where T : BaseBodyAppearance
28+
{
29+
var type = typeof(T);
30+
if (_constCache.TryGetValue(type, out var cached))
31+
return cached;
32+
33+
var consts = new List<string>();
34+
var fields = type.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy);
35+
foreach (var field in fields)
36+
{
37+
if (field is { IsLiteral: true, IsInitOnly: false } && field.FieldType == typeof(string))
38+
consts.Add((string)field.GetRawConstantValue());
39+
}
40+
41+
_constCache[type] = consts;
42+
return consts;
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)