-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from PrashantMohta/1.5
1.5
- Loading branch information
Showing
35 changed files
with
607 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
|
||
using System.IO; | ||
using UnityEngine; | ||
using Modding; | ||
using static Modding.Logger; | ||
|
||
namespace Satchel{ | ||
public class Satchel : Mod{ | ||
|
||
new public string GetName() => AssemblyUtils.name; | ||
public override string GetVersion() => $"{AssemblyUtils.GetAssemblyVersionHash(AssemblyUtils.ver)}"; | ||
public Satchel Instance; | ||
public override void Initialize() | ||
{ | ||
if (Instance == null) | ||
{ | ||
Instance = this; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using System; | ||
using System.IO; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
|
||
using Modding; | ||
using static Modding.Logger; | ||
using UnityEngine; | ||
|
||
namespace Satchel{ | ||
public class CustomAnimationFrames : MonoBehaviour { | ||
public Dictionary<string,Dictionary<int,Sprite>> customClips = new Dictionary<string,Dictionary<int,Sprite>>(); | ||
public Animator anim; | ||
private SpriteRenderer sr; | ||
public bool dump; | ||
public string dumpPath; | ||
public string dumpingClip = ""; | ||
public List<int> dumpedFrames; | ||
private void Awake() | ||
{ | ||
sr = GetComponent<SpriteRenderer>(); | ||
anim = GetComponent<Animator>(); | ||
} | ||
public void Add(string clip,int frame,Sprite s){ | ||
if(!customClips.TryGetValue(clip, out var data)){ | ||
customClips[clip] = new Dictionary<int,Sprite>(); | ||
} | ||
customClips[clip][frame] = s; | ||
} | ||
private void LateUpdate(){ | ||
var currentClipName = anim.GetClipName(); | ||
var currentFrame = anim.GetCurrentFrame(); | ||
if(dump){ | ||
if(dumpingClip != currentClipName){ | ||
dumpedFrames = new List<int>(); | ||
} | ||
if(!dumpedFrames.Contains(currentFrame)){ | ||
dumpedFrames.Add(currentFrame); | ||
var path = Path.Combine(dumpPath, gameObject.GetName(true)); | ||
var fileName = $"{currentClipName}.{currentFrame}.png"; | ||
if(!Directory.Exists(path)){ | ||
Directory.CreateDirectory(path); | ||
} | ||
var filePath = Path.Combine(path,fileName); | ||
if(!File.Exists(filePath)){ | ||
var texture = SpriteUtils.ExtractTextureFromSprite(sr.sprite); | ||
TextureUtils.WriteTextureToFile(texture,filePath); | ||
} | ||
} | ||
return; | ||
} | ||
if(anim != null){ | ||
if(customClips.TryGetValue(currentClipName,out var frames)){ | ||
try{ | ||
sr.sprite = frames[currentFrame]; | ||
} catch (Exception e){ | ||
Log(e.ToString()); | ||
} | ||
} else { | ||
Log($"Unable to find clip {currentClipName} in Animator for {gameObject.name}"); | ||
} | ||
} | ||
} | ||
private void OnDestroy() | ||
{ | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.