Skip to content

Commit

Permalink
V1.12
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottWilson0903 committed Nov 21, 2021
1 parent 45fb15e commit b5a69de
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 32 deletions.
2 changes: 1 addition & 1 deletion API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>API</AssemblyName>
<Description>An API for inscryption</Description>
<Version>1.11.0.0</Version>
<Version>1.12.0.0</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>9.0</LangVersion>
</PropertyGroup>
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Changelog
## v1.12
- Fixes params
- Adds feature for special abilities and special stat icons
- Added support for emissions

## v1.11
- Added support for more identifiers

Expand Down
34 changes: 22 additions & 12 deletions Models/CustomCard.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using CardLoaderPlugin.lib;
using DiskCardGame;
using UnityEngine;

Expand All @@ -9,12 +8,14 @@ namespace APIPlugin
public class CustomCard
{
public static List<CustomCard> cards = new();

public static Dictionary<int,List<AbilityIdentifier>> abilityIds = new();
public static Dictionary<int, List<SpecialAbilityIdentifier>> specialAbilityIds = new();
public static Dictionary<int,EvolveIdentifier> evolveIds = new();
public static Dictionary<int,IceCubeIdentifier> iceCubeIds = new();
public static Dictionary<int,TailIdentifier> tailIds = new();

public static Dictionary<string, Sprite> emissions = new();
public string name;
public List<CardMetaCategory> metaCategories;
public CardComplexity? cardComplexity;
Expand Down Expand Up @@ -44,6 +45,7 @@ public class CustomCard
[IgnoreMapping] public Texture2D altTex;
public Texture titleGraphic;
[IgnoreMapping] public Texture2D pixelTex;
[IgnoreMapping] public Texture2D emissionTex;
public GameObject animatedPortrait;
public List<Texture> decals;
public List<AbilityIdentifier> abilityIdList = new();
Expand All @@ -52,11 +54,11 @@ public class CustomCard
public TailIdentifier tailId;

public CustomCard(
string name,
List<AbilityIdentifier> abilityIdParam=null,
List<SpecialAbilityIdentifier> specialAbilityIdParam=null,
EvolveIdentifier evolveId=null,
IceCubeIdentifier iceCubeId=null,
string name,
List<AbilityIdentifier> abilityIdParam=null,
List<SpecialAbilityIdentifier> specialAbilityIdParam=null,
EvolveIdentifier evolveId=null,
IceCubeIdentifier iceCubeId=null,
TailIdentifier tailId=null)
{
this.name = name;
Expand All @@ -71,12 +73,12 @@ public CustomCard(
this.abilities.Add(id.id);
abilitiesToRemove.Add(id);
}

foreach (AbilityIdentifier id in abilitiesToRemove)
{
abilityIdParam.Remove(id);
}

if (abilityIdParam.Count > 0)
{
CustomCard.abilityIds[CustomCard.cards.Count - 1] = abilityIdParam;
Expand All @@ -91,12 +93,12 @@ public CustomCard(
this.specialAbilities.Add(id.id);
specialAbilitiesToRemove.Add(id);
}

foreach (SpecialAbilityIdentifier id in specialAbilitiesToRemove)
{
specialAbilityIdParam.Remove(id);
}

if (specialAbilityIdParam.Count > 0)
{
CustomCard.specialAbilityIds[CustomCard.cards.Count - 1] = specialAbilityIdParam;
Expand Down Expand Up @@ -133,6 +135,14 @@ public CardInfo AdjustCard(CardInfo card)
tex.filterMode = FilterMode.Point;
card.portraitTex = Sprite.Create(tex, CardUtils.DefaultCardArtRect, CardUtils.DefaultVector2);
card.portraitTex.name = "portrait_" + name;
if (this.emissionTex is not null)
{
emissionTex.name = tex.name + "_emission";
emissionTex.filterMode = FilterMode.Point;
Sprite emissionSprite = Sprite.Create(emissionTex, CardUtils.DefaultCardArtRect, CardUtils.DefaultVector2);
emissionSprite.name = tex.name + "_emission";
emissions.Add(tex.name, emissionSprite);
}
}

if (this.altTex is not null)
Expand All @@ -156,4 +166,4 @@ public CardInfo AdjustCard(CardInfo card)
return card;
}
}
}
}
33 changes: 21 additions & 12 deletions Models/NewCard.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using CardLoaderPlugin.lib;
using DiskCardGame;
using UnityEngine;

Expand All @@ -15,7 +14,9 @@ public static class NewCard
public static Dictionary<int, EvolveIdentifier> evolveIds = new();
public static Dictionary<int, IceCubeIdentifier> iceCubeIds = new();
public static Dictionary<int, TailIdentifier> tailIds = new();


public static Dictionary<string, Sprite> emissions = new();

public static void Add(CardInfo card, List<AbilityIdentifier> abilityIdsParam = null,
List<SpecialAbilityIdentifier> specialAbilitiesIdsParam = null,
EvolveIdentifier evolveId = null,
Expand All @@ -36,14 +37,14 @@ public static void Add(string name, string displayedName, int baseAttack, int ba
int bloodCost = 0, int bonesCost = 0, int energyCost = 0,
List<GemType> gemsCost = null, SpecialStatIcon specialStatIcon = SpecialStatIcon.None,
List<Tribe> tribes = null, List<Trait> traits = null, List<SpecialTriggeredAbility> specialAbilities = null,
List<Ability> abilities = null, List<AbilityIdentifier> abilityIdsParam = null,
List<Ability> abilities = null, List<AbilityIdentifier> abilityIdsParam = null,
List<SpecialAbilityIdentifier> specialAbilitiesIdsParam = null, EvolveParams evolveParams = null,
string defaultEvolutionName = null, TailParams tailParams = null, IceCubeParams iceCubeParams = null,
bool flipPortraitForStrafe = false, bool onePerDeck = false,
List<CardAppearanceBehaviour.Appearance> appearanceBehaviour = null, Texture2D defaultTex = null,
Texture2D altTex = null, Texture titleGraphic = null, Texture2D pixelTex = null,
GameObject animatedPortrait = null, List<Texture> decals = null, EvolveIdentifier evolveId = null,
IceCubeIdentifier iceCubeId = null, TailIdentifier tailId = null)
Texture2D emissionTex = null, GameObject animatedPortrait = null, List<Texture> decals = null,
EvolveIdentifier evolveId = null, IceCubeIdentifier iceCubeId = null, TailIdentifier tailId = null)
{
CardInfo card = ScriptableObject.CreateInstance<CardInfo>();

Expand Down Expand Up @@ -119,7 +120,7 @@ public static void Add(string name, string displayedName, int baseAttack, int ba
}

// textures
DetermineAndSetCardArt(name, card, defaultTex, altTex, pixelTex);
DetermineAndSetCardArt(name, card, defaultTex, altTex, pixelTex, emissionTex);

if (animatedPortrait is not null)
{
Expand Down Expand Up @@ -166,23 +167,23 @@ private static void HandleIdentifiers(
{
abilityIdsParam.Remove(id);
}

if (abilityIdsParam.Count > 0)
{
NewCard.abilityIds[NewCard.cards.Count - 1] = abilityIdsParam;
}
}

// Handle SpecialAbilityIds
List<SpecialAbilityIdentifier> specialAbilitiesToRemove = new List<AbilityIdentifier>();
List<SpecialAbilityIdentifier> specialAbilitiesToRemove = new List<SpecialAbilityIdentifier>();
if (specialAbilitiesIdsParam is not null)
{
foreach (var id in specialAbilitiesIdsParam.Where(id => id.id != 0))
{
card.specialAbilities.Add(id.id);
specialAbilitiesToRemove.Add(id);
}

foreach (SpecialAbilityIdentifier id in specialAbilitiesToRemove)
{
specialAbilitiesIdsParam.Remove(id);
Expand Down Expand Up @@ -215,7 +216,7 @@ private static void HandleIdentifiers(

private static void DetermineAndSetCardArt(
string name, CardInfo card,
Texture2D defaultTex, Texture2D altTex, Texture2D pixelTex)
Texture2D defaultTex, Texture2D altTex, Texture2D pixelTex, Texture2D emissionTex)
{
var newName = "portrait_" + name;
if (defaultTex is not null)
Expand All @@ -225,6 +226,14 @@ private static void DetermineAndSetCardArt(

card.portraitTex = Sprite.Create(defaultTex, CardUtils.DefaultCardArtRect, CardUtils.DefaultVector2);
card.portraitTex.name = newName;
if (emissionTex is not null)
{
emissionTex.name = newName + "_emission";
emissionTex.filterMode = FilterMode.Point;
Sprite emissionSprite = Sprite.Create(emissionTex, CardUtils.DefaultCardArtRect, CardUtils.DefaultVector2);
emissionSprite.name = newName + "_emission";
emissions.Add(newName, emissionSprite);
}
}

if (altTex is not null)
Expand All @@ -247,4 +256,4 @@ private static void DetermineAndSetCardArt(
}
}
}
}
}
4 changes: 2 additions & 2 deletions Patches/AbilitiesUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace API.Patches
{
[HarmonyPatch(typeof(AbilitiesUtil), "LoadAbilityIcon",
[HarmonyPatch(typeof(AbilitiesUtil), "LoadAbilityIcon",
typeof(string), typeof(bool), typeof(bool))]
public class AbilitiesUtil_LoadAbilityIcon
{
Expand All @@ -24,7 +24,7 @@ public static bool Prefix(string abilityName, CardTriggerHandler __instance, ref
}
}

[HarmonyPatch(typeof(AbilitiesUtil), "GetAbilities",
[HarmonyPatch(typeof(AbilitiesUtil), "GetAbilities",
typeof(bool), typeof(bool), typeof(int), typeof(int), typeof(AbilityMetaCategory))]
public class AbilitiesUtil_GetAbilities
{
Expand Down
5 changes: 2 additions & 3 deletions Patches/StatIconInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
namespace API.Patches
{
[HarmonyPatch(typeof(StatIconInfo), "LoadAbilityData")]
public class StatIconInfoPatch
public class StatIconInfo_LoadAbilityData
{
[HarmonyPostfix]
static void Postfix()
{
foreach (var ability in NewSpecialAbility.specialAbilities)
Expand All @@ -21,4 +20,4 @@ static void Postfix()

}
}
}
}
2 changes: 1 addition & 1 deletion Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public partial class Plugin : BaseUnityPlugin
{
private const string PluginGuid = "cyantist.inscryption.api";
private const string PluginName = "API";
private const string PluginVersion = "1.11.0.0";
private const string PluginVersion = "1.12.0.0";

internal static ManualLogSource Log;
internal static ConfigEntry<bool> configEnergy;
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "API",
"version_number": "1.11.0",
"version_number": "1.12.0",
"website_url": "https://github.com/ScottWilson0903/InscryptionAPI",
"description": "This plugin is a BepInEx plugin made for Inscryption as an API. It can currently create custom cards and abilities and inject them into the data pool, or modify existing cards in the card pool.",
"dependencies": [
Expand Down

0 comments on commit b5a69de

Please sign in to comment.