mirror of
https://gitgud.io/AbstractConcept/rimworld-animations-patch.git
synced 2024-08-15 00:43:27 +00:00
v2.0.0
This commit is contained in:
parent
38ec4f86c1
commit
ae95e34137
35 changed files with 242 additions and 612 deletions
|
@ -19,7 +19,6 @@ namespace Rimworld_Animations_Patch
|
|||
RenderTexture.active = rt;
|
||||
if (mat != null)
|
||||
{ Graphics.Blit(source, rt, mat); }
|
||||
|
||||
else
|
||||
{ Graphics.Blit(source, rt); }
|
||||
|
||||
|
@ -49,7 +48,7 @@ namespace Rimworld_Animations_Patch
|
|||
DebugMode.Message("mainTex or maskTex is missing!");
|
||||
return mainTex;
|
||||
}
|
||||
|
||||
|
||||
Color[] mainArray = GetReadableTexture2D(mainTex).GetPixels();
|
||||
Color[] maskArray = GetReadableTexture2D(maskTex, mainTex.width, mainTex.height).GetPixels();
|
||||
|
||||
|
@ -64,7 +63,7 @@ namespace Rimworld_Animations_Patch
|
|||
else if (mainArray[j].a > 0 && maskArray[j].a > 0 && writeOverMainTex)
|
||||
{ mainArray[j] = new Color(Mathf.Min(mainArray[j].r, maskArray[j].r), Mathf.Min(mainArray[j].g, maskArray[j].g), Mathf.Min(mainArray[j].b, maskArray[j].b), Mathf.Min(mainArray[j].a, maskArray[j].a)); }
|
||||
}
|
||||
|
||||
|
||||
Texture2D newTex = new Texture2D(mainTex.width, mainTex.height, TextureFormat.RGBA32, mipChain: true);
|
||||
newTex.SetPixels(mainArray);
|
||||
newTex.filterMode = FilterMode.Trilinear;
|
||||
|
@ -74,71 +73,23 @@ namespace Rimworld_Animations_Patch
|
|||
return newTex;
|
||||
}
|
||||
|
||||
public static Graphic ApplyGraphicWithMasks(Graphic graphic, Graphic graphicWithMask, bool writeOverMainTex)
|
||||
public static Graphic ApplyGraphicMasks(Graphic graphic, Graphic graphicWithMask, bool writeOverMainTex)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
Texture2D mainTex = (Texture2D)graphic.MatAt(new Rot4(i)).mainTexture;
|
||||
Texture2D maskTex = graphicWithMask.MatAt(new Rot4(i)).GetMaskTexture();
|
||||
graphic.MatAt(new Rot4(i)).mainTexture = ApplyMaskToTexture2D(mainTex, maskTex, writeOverMainTex);
|
||||
}
|
||||
|
||||
return graphic;
|
||||
}
|
||||
|
||||
public static Graphic ApplyGraphicWithMasks(Graphic graphic, string mask, bool writeOverMainTex)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
Texture2D mainTex = (Texture2D)graphic.MatAt(new Rot4(i)).mainTexture;
|
||||
|
||||
if (mainTex == null)
|
||||
{ DebugMode.Message("Main Texture2D not found for " + graphic.path + ". Rotation: " + i.ToString()); continue; }
|
||||
|
||||
string suffix = string.Empty;
|
||||
switch (i)
|
||||
{
|
||||
case 0: suffix = "_north"; break;
|
||||
case 1: suffix = "_east"; break;
|
||||
case 2: suffix = "_south"; break;
|
||||
case 3: suffix = "_west"; break;
|
||||
}
|
||||
|
||||
Texture2D maskTex = ContentFinder<Texture2D>.Get(mask + suffix, false);
|
||||
|
||||
if (maskTex == null)
|
||||
{ DebugMode.Message("Mask Texture2D not found for " + mask + ". Rotation: " + i.ToString()); continue; }
|
||||
{ DebugMode.Message("Mask Texture2D not found for " + graphic.path + ". Rotation: " + i.ToString()); continue; }
|
||||
|
||||
graphic.MatAt(new Rot4(i)).mainTexture = ApplyMaskToTexture2D(mainTex, maskTex, writeOverMainTex);
|
||||
}
|
||||
|
||||
return graphic;
|
||||
}
|
||||
|
||||
public static void ResetGraphic(Graphic graphic)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
string suffix = string.Empty;
|
||||
switch (i)
|
||||
{
|
||||
case 0: suffix = "_north"; break;
|
||||
case 1: suffix = "_east"; break;
|
||||
case 2: suffix = "_south"; break;
|
||||
case 3: suffix = "_west"; break;
|
||||
}
|
||||
|
||||
Texture2D texture2D = ContentFinder<Texture2D>.Get(graphic.path + suffix, false);
|
||||
|
||||
if (texture2D == null && i == 3)
|
||||
{ texture2D = ContentFinder<Texture2D>.Get(graphic.path + "_east", false); }
|
||||
|
||||
if (texture2D == null)
|
||||
{ texture2D = ContentFinder<Texture2D>.Get(graphic.path + "_north", false); }
|
||||
|
||||
if (texture2D != null)
|
||||
{ graphic.MatAt(new Rot4(i)).mainTexture = texture2D; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -35,7 +35,7 @@ namespace Rimworld_Animations_Patch
|
|||
{
|
||||
IEnumerable<IntVec3> cells = GenRadial.RadialCellsAround(pawn.Position, radius + 0.75f, false).Where(x => x.Standable(pawn.Map) && x.GetRoom(pawn.Map) == pawn.GetRoom());
|
||||
|
||||
if (cells.Any() == true && cells.Count() > 0)
|
||||
if (cells?.Any() == true && cells.Count() > 0)
|
||||
{ return cells.RandomElement(); }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue