Skip to content

Commit

Permalink
Merge pull request #655 from microlith57/microlith57/decalregistry_an…
Browse files Browse the repository at this point in the history
…imation
  • Loading branch information
DemoJameson authored Aug 6, 2023
2 parents 1786f60 + 2c272ab commit 865c2f5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Celeste.Mod.mm/Mod/Registry/DecalRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ public static class DecalRegistry {

((patch_Decal)decal).MakeStaticMover(x, y, width, height);
}},
{ "animation", delegate(Decal decal, XmlAttributeCollection attrs) {
int[] frames = Calc.ReadCSVIntWithTricks(attrs["frames"]?.Value ?? "0");

((patch_Decal)decal).MakeAnimation(frames);
}},
{ "scared", delegate(Decal decal, XmlAttributeCollection attrs) {
int hideRange = 32;
int showRange = 48;
Expand Down Expand Up @@ -259,7 +264,7 @@ internal static void LoadModDecalRegistry(ModAsset decalRegistry) {
registeredPath = registeredPath.TrimEnd('*');
foreach (string decalPath in localDecals) {
// Wildcard matches must be longer than the subpath, and don't match on decals in subfolders
if (decalPath.StartsWith(registeredPath) && decalPath.Length > registeredPath.Length
if (decalPath.StartsWith(registeredPath) && decalPath.Length > registeredPath.Length
&& decalPath.LastIndexOf('/') <= registeredPath.Length - 1) {
RegisterDecal(decalPath, info);
found = true;
Expand All @@ -268,8 +273,8 @@ internal static void LoadModDecalRegistry(ModAsset decalRegistry) {
} else if (localDecals.Contains(registeredPath)) {
RegisterDecal(registeredPath, info);
found = true;
}
}

if (!found) {
Logger.Log(LogLevel.Warn, "Decal Registry", $"Could not find any decals in {decalRegistry.Source.Name} under path {decalRegistration.Key}");
}
Expand Down Expand Up @@ -299,8 +304,8 @@ private static List<KeyValuePair<string, DecalInfo>> ReadDecalRegistryXml(ModAss
continue;
}

DecalInfo info = new DecalInfo {
CustomProperties = new List<KeyValuePair<string, XmlAttributeCollection>>()
DecalInfo info = new DecalInfo {
CustomProperties = new List<KeyValuePair<string, XmlAttributeCollection>>()
};

foreach (XmlNode node2 in decal.ChildNodes) {
Expand Down
4 changes: 4 additions & 0 deletions Celeste.Mod.mm/Patches/Decal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ public void MakeStaticMover(int x, int y, int w, int h, bool jumpThrus = false)
Add(staticMover);
}

public void MakeAnimation(int[] frames) {
textures = frames.Select(i => textures[i]).ToList();
}

public void MakeScaredAnimation(int hideRange, int showRange, int[] idleFrames, int[] hiddenFrames, int[] showFrames, int[] hideFrames) {
Sprite sprite = (Sprite) (image = new Sprite(null, null));
sprite.AddLoop("hidden", 0.1f, hiddenFrames.Select(i => textures[i]).ToArray());
Expand Down

0 comments on commit 865c2f5

Please sign in to comment.