A GameResource asset type for wearable skins. Stores the model, faction, stat multipliers and tool list a lizard gets when wearing it, plus a helper that reloads the asset from disk if a hot reload left it blank.
using System.Collections.Generic;
/// <summary>
/// The data for one wearable skin: what the lizard looks like in it, what it can do and which
/// side it appears to be on. Make a new ".skin" asset for each kind of person that can be worn.
/// </summary>
[AssetType( Name = "Skin Definition", Extension = "skin", Category = "Skins" )]
public class SkinDefinition : GameResource
{
/// <summary>Name shown to the player ("Owner Envoy").</summary>
[Property] public string Title { get; set; } = "Skin";
/// <summary>The humanoid model shown instead of the lizard's body.</summary>
[Property] public Model Model { get; set; }
/// <summary>Faction the lizard appears to belong to while wearing this (see FactionTag).</summary>
[Property] public string Faction { get; set; } = FactionTag.Owners;
/// <summary>Walking speed, as a multiple of the lizard's own.</summary>
[Property, Group( "Stats" )] public float SpeedMultiplier { get; set; } = 1f;
/// <summary>Sprinting speed, as a multiple of the lizard's own.</summary>
[Property, Group( "Stats" )] public float SprintMultiplier { get; set; } = 1f;
/// <summary>Jump strength, as a multiple of the lizard's own.</summary>
[Property, Group( "Stats" )] public float JumpMultiplier { get; set; } = 1f;
/// <summary>Whether it can still cling to walls and ceilings. Off means floors only, like a person.</summary>
[Property, Group( "Stats" )] public bool CanCling { get; set; } = false;
/// <summary>Camera height above the feet while worn. 0 keeps the lizard's own.</summary>
[Property, Group( "Stats" )] public float CameraHeight { get; set; } = 0f;
/// <summary>Named abilities and tools this skin grants ("speak", "open_doors"). Checked with SkinWearer.HasTool.</summary>
[Property] public List<string> Tools { get; set; } = new();
/// <summary>
/// Code reloads in the editor can leave a loaded skin with blank default values. If this one
/// has lost its model, read it again from its own file.
/// </summary>
public void EnsureLoaded()
{
if ( Model is not null || string.IsNullOrEmpty( ResourcePath ) ) return;
if ( !FileSystem.Mounted.FileExists( ResourcePath ) ) return;
LoadFromJson( FileSystem.Mounted.ReadAllText( ResourcePath ) );
}
}