2 using Microsoft.Xna.Framework;
4 using System.Collections.Generic;
10 [RequiredByCorePackage]
18 XDocument doc = XMLExtensions.TryLoadXml(Path);
21 DebugConsole.ThrowError($
"Loading character file failed: {Path}", contentPackage:
ContentPackage);
26 DebugConsole.ThrowError($
"Duplicate path: {Path}", contentPackage:
ContentPackage);
30 bool isOverride = mainElement.IsOverride();
31 if (isOverride) { mainElement = mainElement.FirstElement(); }
43 private static void ClearCaches()
51 public override void Sort()
56 public override void Preload(Action<Sprite> addPreloadedSprite)
60 if (characterPrefab?.ConfigElement ==
null)
62 throw new Exception($
"Failed to load the character config file from {Path}!");
67 bool humanoid = mainElement.GetAttributeBool(
"humanoid",
false);
82 DebugConsole.ThrowError($
"Failed to preload a ragdoll file for the character \"{characterPrefab.Name}\"", e,
87 if (ragdollParams !=
null)
89 HashSet<ContentPath> texturePaths =
new HashSet<ContentPath>();
90 AddTexturePath(ragdollParams.
Texture);
93 AddTexturePath(limb.normalSpriteParams?.Texture);
94 AddTexturePath(limb.deformSpriteParams?.Texture);
95 AddTexturePath(limb.damagedSpriteParams?.Texture);
96 foreach (var decorativeSprite
in limb.decorativeSpriteParams)
98 AddTexturePath(decorativeSprite.Texture);
103 addPreloadedSprite(
new Sprite(texturePath.
Value, Vector2.Zero));
106 void AddTexturePath(
string path)
108 if (
string.IsNullOrEmpty(path)) {
return; }
override void UnloadFile()
override void Preload(Action< Sprite > addPreloadedSprite)
CharacterFile(ContentPackage contentPackage, ContentPath path)
static bool CheckSpeciesName(XElement mainElement, CharacterFile file, out Identifier name)
static CharacterPrefab FindByFilePath(string filePath)
ContentXElement ConfigElement
static readonly PrefabCollection< CharacterPrefab > Prefabs
Base class for content file types, which are loaded from filelist.xml via reflection....
readonly ContentPackage ContentPackage
static ContentPath FromRaw(string? rawValue)
IEnumerable< ContentXElement > GetChildElements(string name)
ContentPackage? ContentPackage
static ? RoundSound Load(ContentXElement element, bool stream=false)