mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
Standalone exported
This commit is contained in:
parent
1e2c4fa6bf
commit
7e1680a7fb
605 changed files with 2169 additions and 3312 deletions
|
@ -8,6 +8,7 @@ using UnityEngine;
|
|||
|
||||
namespace RimWorldAnimationStudio
|
||||
{
|
||||
[Serializable]
|
||||
public class AlienRaceDef
|
||||
{
|
||||
public string defName;
|
||||
|
@ -17,10 +18,7 @@ namespace RimWorldAnimationStudio
|
|||
public List<MultiDirectionalGraphic> bodyTypeGraphics = new List<MultiDirectionalGraphic>();
|
||||
public MultiDirectionalGraphic headGraphics = new MultiDirectionalGraphic();
|
||||
|
||||
public AlienRaceDef()
|
||||
{
|
||||
|
||||
}
|
||||
public AlienRaceDef() { }
|
||||
|
||||
public AlienRaceDef(string defName)
|
||||
{
|
||||
|
@ -101,31 +99,17 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
public void SetHeadGraphicPath(string path, CardinalDirection facing)
|
||||
{
|
||||
if (path == null || path.Any() == false || File.Exists(path) == false || Path.GetExtension(path) != ".png")
|
||||
{ path = "Invalid file path"; }
|
||||
|
||||
switch (facing)
|
||||
{
|
||||
case CardinalDirection.North:
|
||||
headGraphics.northGraphic.path = path;
|
||||
headGraphics.northGraphic.sprite = LoadSprite(path); break;
|
||||
case CardinalDirection.East:
|
||||
headGraphics.eastGraphic.path = path;
|
||||
headGraphics.eastGraphic.sprite = LoadSprite(path); break;
|
||||
case CardinalDirection.South:
|
||||
headGraphics.southGraphic.path = path;
|
||||
headGraphics.southGraphic.sprite = LoadSprite(path); break;
|
||||
default:
|
||||
headGraphics.eastGraphic.path = path;
|
||||
headGraphics.eastGraphic.sprite = LoadSprite(path); break;
|
||||
case CardinalDirection.North: headGraphics.northGraphic.SetPath(path); break;
|
||||
case CardinalDirection.East: headGraphics.eastGraphic.SetPath(path); break;
|
||||
case CardinalDirection.South: headGraphics.southGraphic.SetPath(path); break;
|
||||
default: headGraphics.eastGraphic.SetPath(path); break;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetBodyTypeGraphicPath(string path, CardinalDirection facing, string bodyType = "None")
|
||||
{
|
||||
if (path == null || path.Any() == false || File.Exists(path) == false || Path.GetExtension(path) != ".png")
|
||||
{ path = "Invalid file path"; }
|
||||
|
||||
MultiDirectionalGraphic bodyTypeGraphic = bodyTypeGraphics.FirstOrDefault(x => x.bodyType == bodyType);
|
||||
|
||||
if (bodyTypeGraphic == null)
|
||||
|
@ -136,36 +120,16 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
switch (facing)
|
||||
{
|
||||
case CardinalDirection.North:
|
||||
bodyTypeGraphic.northGraphic.path = path;
|
||||
bodyTypeGraphic.northGraphic.sprite = LoadSprite(path); break;
|
||||
case CardinalDirection.East:
|
||||
bodyTypeGraphic.eastGraphic.path = path;
|
||||
bodyTypeGraphic.eastGraphic.sprite = LoadSprite(path); break;
|
||||
case CardinalDirection.South:
|
||||
bodyTypeGraphic.southGraphic.path = path;
|
||||
bodyTypeGraphic.southGraphic.sprite = LoadSprite(path); break;
|
||||
default:
|
||||
bodyTypeGraphic.eastGraphic.path = path;
|
||||
bodyTypeGraphic.eastGraphic.sprite = LoadSprite(path); break;
|
||||
case CardinalDirection.North: bodyTypeGraphic.northGraphic.SetPath(path); break;
|
||||
case CardinalDirection.East: bodyTypeGraphic.eastGraphic.SetPath(path); break;
|
||||
case CardinalDirection.South:bodyTypeGraphic.southGraphic.SetPath(path); break;
|
||||
default: bodyTypeGraphic.eastGraphic.SetPath(path); break;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasValidHeadGraphicPath(CardinalDirection facing)
|
||||
{
|
||||
string path;
|
||||
|
||||
switch (facing)
|
||||
{
|
||||
case CardinalDirection.North: path = headGraphics.northGraphic.path; break;
|
||||
case CardinalDirection.East: path = headGraphics.eastGraphic.path; break;
|
||||
case CardinalDirection.South: path = headGraphics.southGraphic.path; break;
|
||||
default: path = headGraphics.eastGraphic.path; break;
|
||||
}
|
||||
|
||||
if (path == null || path.Any() == false || File.Exists(path) == false || Path.GetExtension(path) != ".png") return false;
|
||||
|
||||
return true;
|
||||
return headGraphics.HasValidPathForDirection(facing);
|
||||
}
|
||||
|
||||
public bool HasValidBodyTypeGraphicPath(CardinalDirection facing, string bodyType = "None")
|
||||
|
@ -178,33 +142,7 @@ namespace RimWorldAnimationStudio
|
|||
bodyTypeGraphics.Add(bodyTypeGraphic);
|
||||
}
|
||||
|
||||
string path;
|
||||
|
||||
switch (facing)
|
||||
{
|
||||
case CardinalDirection.North: path = bodyTypeGraphic.northGraphic.path; break;
|
||||
case CardinalDirection.East: path = bodyTypeGraphic.eastGraphic.path; break;
|
||||
case CardinalDirection.South: path = bodyTypeGraphic.southGraphic.path; break;
|
||||
default: path = bodyTypeGraphic.eastGraphic.path; break;
|
||||
}
|
||||
|
||||
if (path == null || path.Any() == false || File.Exists(path) == false || Path.GetExtension(path) != ".png") return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Sprite LoadSprite(string path)
|
||||
{
|
||||
if (path == null || path.Any() == false || File.Exists(path) == false || Path.GetExtension(path) != ".png") return null;
|
||||
|
||||
byte[] pngBytes = File.ReadAllBytes(path);
|
||||
|
||||
Texture2D tex = new Texture2D(2, 2);
|
||||
tex.LoadImage(pngBytes);
|
||||
|
||||
Sprite sprite = Sprite.Create(tex, new Rect(0.0f, 0.0f, tex.width, tex.height), new Vector2(0.5f, 0.5f), 85.0f);
|
||||
|
||||
return sprite;
|
||||
return bodyTypeGraphic.HasValidPathForDirection(facing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue