Skip to content

Commit a248513

Browse files
Backwards compatibility support
1 parent caaeef5 commit a248513

13 files changed

Lines changed: 805 additions & 0 deletions
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using DiskCardGame;
2+
using InscryptionAPI.Guid;
3+
4+
namespace APIPlugin
5+
{
6+
[Obsolete("Use AbilityManager instead", true)]
7+
public class AbilityIdentifier
8+
{
9+
internal string guid;
10+
private string name;
11+
public Ability id; // This creates a point of fragility - I need to ensure this never changes
12+
internal Ability realID; // As such, I will actually just use this field
13+
14+
private AbilityIdentifier(string guid, string name)
15+
{
16+
this.guid = guid;
17+
this.name = name;
18+
realID = id = GuidManager.GetEnumValue<Ability>(guid, name);
19+
}
20+
21+
public static AbilityIdentifier GetAbilityIdentifier(string guid, string name)
22+
{
23+
return GetID(guid, name);
24+
}
25+
26+
public static AbilityIdentifier GetID(string guid, string name)
27+
{
28+
return new AbilityIdentifier(guid, name);
29+
}
30+
31+
public override string ToString()
32+
{
33+
return $"{guid}({name})";
34+
}
35+
}
36+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using DiskCardGame;
2+
using UnityEngine;
3+
4+
namespace APIPlugin
5+
{
6+
[Obsolete("Use AbilityManager and extension methods instead", true)]
7+
public class AbilityInfoUtils
8+
{
9+
public static AbilityInfo CreateInfoWithDefaultSettings(string rulebookName, string rulebookDescription)
10+
{
11+
AbilityInfo info = ScriptableObject.CreateInstance<AbilityInfo>();
12+
info.powerLevel = 0;
13+
info.rulebookName = rulebookName;
14+
info.rulebookDescription = rulebookDescription;
15+
info.metaCategories = new List<AbilityMetaCategory>()
16+
{
17+
AbilityMetaCategory.Part1Modular, AbilityMetaCategory.Part1Rulebook
18+
};
19+
20+
return info;
21+
}
22+
}
23+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
using BepInEx;
2+
using DiskCardGame;
3+
using InscryptionAPI.Helpers;
4+
using UnityEngine;
5+
6+
namespace APIPlugin
7+
{
8+
[Obsolete("Use CardManager and extension methods instead", true)]
9+
public static class CardUtils
10+
{
11+
public static readonly Vector2 DefaultVector2 = new Vector2(0.5f, 0.5f);
12+
public static readonly Rect DefaultCardArtRect = new Rect(0.0f, 0.0f, 114.0f, 94.0f);
13+
public static readonly Rect DefaultCardPixelArtRect = new Rect(0.0f, 0.0f, 41.0f, 28.0f);
14+
15+
public static Predicate<CardInfo> IsNonLivingCard = card
16+
=> card.traits.Exists(t => t is Trait.Terrain or Trait.Pelt);
17+
18+
public static List<CardMetaCategory> getNormalCardMetadata = new()
19+
{ CardMetaCategory.ChoiceNode, CardMetaCategory.TraderOffer };
20+
21+
public static List<CardMetaCategory> getRareCardMetadata = new()
22+
{ CardMetaCategory.ChoiceNode, CardMetaCategory.TraderOffer, CardMetaCategory.Rare };
23+
24+
public static List<CardMetaCategory> getGBCCardMetadata = new()
25+
{ CardMetaCategory.GBCPack, CardMetaCategory.GBCPlayable };
26+
27+
public static List<CardMetaCategory> getGBCRareCardMetadata = new()
28+
{
29+
CardMetaCategory.GBCPack, CardMetaCategory.GBCPlayable, CardMetaCategory.Rare
30+
};
31+
32+
public static List<CardMetaCategory> getAllActsCardMetadata = new()
33+
{
34+
CardMetaCategory.ChoiceNode, CardMetaCategory.Rare, CardMetaCategory.TraderOffer, CardMetaCategory.Rare,
35+
CardMetaCategory.GBCPack, CardMetaCategory.GBCPlayable, CardMetaCategory.Part3Random
36+
};
37+
38+
39+
// card appearance
40+
41+
public static List<CardAppearanceBehaviour.Appearance> getRareAppearance = new()
42+
{ CardAppearanceBehaviour.Appearance.RareCardBackground };
43+
44+
public static List<CardAppearanceBehaviour.Appearance> getTerrainBackgroundAppearance = new()
45+
{
46+
CardAppearanceBehaviour.Appearance.TerrainBackground
47+
};
48+
49+
public static List<CardAppearanceBehaviour.Appearance> getTerrainLayoutAppearance = new()
50+
{
51+
CardAppearanceBehaviour.Appearance.TerrainLayout
52+
};
53+
54+
public static List<CardAppearanceBehaviour.Appearance> getTerrainAppearance = new()
55+
{
56+
CardAppearanceBehaviour.Appearance.TerrainBackground, CardAppearanceBehaviour.Appearance.TerrainLayout
57+
};
58+
59+
public static List<CardAppearanceBehaviour.Appearance> getHologramAppearance = new()
60+
{
61+
CardAppearanceBehaviour.Appearance.HologramPortrait
62+
};
63+
64+
public static List<CardAppearanceBehaviour.Appearance> getAnimatedAppearance = new()
65+
{
66+
CardAppearanceBehaviour.Appearance.AnimatedPortrait
67+
};
68+
69+
public static List<CardAppearanceBehaviour.Appearance> getGoldAppearance = new()
70+
{
71+
CardAppearanceBehaviour.Appearance.GoldEmission
72+
};
73+
74+
public static List<CardAppearanceBehaviour.Appearance> getBloodDecalAppearance = new()
75+
{
76+
CardAppearanceBehaviour.Appearance.AlternatingBloodDecal
77+
};
78+
79+
public static List<CardAppearanceBehaviour.Appearance> getDynamicAppearance = new()
80+
{
81+
CardAppearanceBehaviour.Appearance.DynamicPortrait
82+
};
83+
84+
public static byte[] ReadArtworkFileAsBytes(string nameOfCardArt)
85+
{
86+
return File.ReadAllBytes(
87+
Directory.GetFiles(Paths.PluginPath, nameOfCardArt, SearchOption.AllDirectories)[0]
88+
);
89+
}
90+
91+
public static Texture2D getAndloadImageAsTexture(string pathCardArt)
92+
{
93+
return TextureHelper.GetImageAsTexture(pathCardArt);
94+
}
95+
}
96+
}
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
using System.Collections.Generic;
2+
using DiskCardGame;
3+
using InscryptionAPI.Card;
4+
using UnityEngine;
5+
6+
namespace APIPlugin
7+
{
8+
[Obsolete("Use CardManager instead", true)]
9+
public class CustomCard
10+
{
11+
public static List<CustomCard> cards = new();
12+
13+
public static Dictionary<int,List<AbilityIdentifier>> abilityIds = new();
14+
public static Dictionary<int, List<SpecialAbilityIdentifier>> specialAbilityIds = new();
15+
public static Dictionary<int,EvolveIdentifier> evolveIds = new();
16+
public static Dictionary<int,IceCubeIdentifier> iceCubeIds = new();
17+
public static Dictionary<int,TailIdentifier> tailIds = new();
18+
public static Dictionary<string, Sprite> emissions = new();
19+
20+
public string name;
21+
public List<CardMetaCategory> metaCategories;
22+
public CardComplexity? cardComplexity;
23+
public CardTemple? temple;
24+
public string displayedName;
25+
public int? baseAttack;
26+
public int? baseHealth;
27+
public string description;
28+
public bool? hideAttackAndHealth;
29+
public int? cost;
30+
public int? bonesCost;
31+
public int? energyCost;
32+
public List<GemType> gemsCost;
33+
public SpecialStatIcon? specialStatIcon;
34+
public List<Tribe> tribes;
35+
public List<Trait> traits;
36+
public List<SpecialTriggeredAbility> specialAbilities;
37+
public List<Ability> abilities;
38+
public EvolveParams evolveParams;
39+
public string defaultEvolutionName;
40+
public TailParams tailParams;
41+
public IceCubeParams iceCubeParams;
42+
public bool? flipPortraitForStrafe;
43+
public bool? onePerDeck;
44+
public List<CardAppearanceBehaviour.Appearance> appearanceBehaviour;
45+
[IgnoreMapping] public Texture2D tex;
46+
[IgnoreMapping] public Texture2D altTex;
47+
public Texture titleGraphic;
48+
[IgnoreMapping] public Texture2D pixelTex;
49+
[IgnoreMapping] public Texture2D emissionTex;
50+
public GameObject animatedPortrait;
51+
public List<Texture> decals;
52+
53+
[IgnoreMapping] private List<AbilityIdentifier> abilityIdParam;
54+
[IgnoreMapping] private List<SpecialAbilityIdentifier> specialAbilityIdParam;
55+
[IgnoreMapping] private EvolveIdentifier evolveId;
56+
[IgnoreMapping] private IceCubeIdentifier iceCubeId;
57+
[IgnoreMapping] private TailIdentifier tailId;
58+
59+
public CustomCard(
60+
string name,
61+
List<AbilityIdentifier> abilityIdParam=null,
62+
List<SpecialAbilityIdentifier> specialAbilityIdParam=null,
63+
EvolveIdentifier evolveId=null,
64+
IceCubeIdentifier iceCubeId=null,
65+
TailIdentifier tailId=null)
66+
{
67+
this.name = name;
68+
this.abilityIdParam = abilityIdParam;
69+
this.specialAbilityIdParam = specialAbilityIdParam;
70+
this.evolveId = evolveId;
71+
this.iceCubeId = iceCubeId;
72+
this.tailId = tailId;
73+
74+
CardManager.ModifyCardList += delegate(List<CardInfo> cards)
75+
{
76+
CardInfo targetCard = cards.CardByName(this.name);
77+
78+
if (targetCard != null)
79+
this.AdjustCard(targetCard, cards);
80+
81+
return cards;
82+
};
83+
}
84+
85+
public CardInfo AdjustCard(CardInfo card, List<CardInfo> cardsToSearch)
86+
{
87+
TypeMapper<CustomCard, CardInfo>.Convert(this, card);
88+
89+
if (this.tex is not null)
90+
card.SetPortrait(this.tex);
91+
92+
if (this.altTex is not null)
93+
card.SetAltPortrait(this.altTex);
94+
95+
if (this.pixelTex is not null)
96+
card.SetPixelPortrait(this.pixelTex);
97+
98+
if (this.decals is not null)
99+
card.AddDecal(this.decals.ToArray());
100+
101+
if (this.abilityIdParam != null)
102+
card.AddAbilities(this.abilityIdParam.Select(ai => ai.realID).ToArray());
103+
104+
if (this.specialAbilityIdParam != null)
105+
card.AssignSpecialAbilities(this.specialAbilityIdParam);
106+
107+
if (this.evolveId != null)
108+
{
109+
// We're already in the mapper. I don't want to add another event handler
110+
CardInfo evolveTarget = cardsToSearch.CardByName(this.evolveId.name);
111+
if (evolveTarget != null)
112+
card.SetEvolve(evolveTarget, this.evolveId.turnsToEvolve, new List<CardModificationInfo>() { this.evolveId.mods });
113+
}
114+
115+
if (this.tailId != null)
116+
{
117+
// We're already in the mapper. I don't want to add another event handler
118+
CardInfo tail = cardsToSearch.CardByName(this.tailId.name);
119+
if (tail != null)
120+
card.SetTail(tail, this.tailId.tailLostTex, mods:new List<CardModificationInfo>() { this.tailId.mods });
121+
}
122+
123+
if (this.iceCubeId != null)
124+
{
125+
// We're already in the mapper. I don't want to add another event handler
126+
CardInfo iceCubeTarget = cardsToSearch.CardByName(this.iceCubeId.name);
127+
if (iceCubeTarget != null)
128+
card.SetIceCube(iceCubeTarget, new List<CardModificationInfo>() { this.iceCubeId.mods });
129+
}
130+
131+
return card;
132+
}
133+
}
134+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using DiskCardGame;
2+
using InscryptionAPI.Card;
3+
4+
namespace APIPlugin
5+
{
6+
[Obsolete("Use CardManager and CardInfo extension methods instead", true)]
7+
public class EvolveIdentifier
8+
{
9+
internal string name;
10+
internal int turnsToEvolve;
11+
internal CardModificationInfo mods;
12+
private EvolveParams evolution;
13+
14+
public EvolveParams Evolution
15+
{
16+
get
17+
{
18+
if (this.evolution == null)
19+
SetParams(CardLoader.GetCardByName(this.name));
20+
21+
return this.evolution;
22+
}
23+
}
24+
25+
public EvolveIdentifier(string name, int turnsToEvolve, CardModificationInfo mods = null)
26+
{
27+
this.name = name;
28+
this.turnsToEvolve = turnsToEvolve;
29+
this.mods = mods;
30+
}
31+
32+
private void SetParams(CardInfo card)
33+
{
34+
this.evolution = new EvolveParams();
35+
36+
this.evolution.turnsToEvolve = this.turnsToEvolve;
37+
this.evolution.evolution = card;
38+
39+
if (this.mods != null)
40+
{
41+
this.evolution.evolution.mods.Add(this.mods);
42+
}
43+
}
44+
45+
public override string ToString()
46+
{
47+
return name;
48+
}
49+
}
50+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using DiskCardGame;
2+
using InscryptionAPI.Card;
3+
4+
namespace APIPlugin
5+
{
6+
[Obsolete("Use CardManager and CardInfo extension methods instead", true)]
7+
public class IceCubeIdentifier
8+
{
9+
internal string name;
10+
internal CardModificationInfo mods;
11+
12+
private IceCubeParams iceCube;
13+
public IceCubeParams IceCube
14+
{
15+
get
16+
{
17+
if (this.iceCube == null)
18+
SetParams(CardLoader.GetCardByName(this.name));
19+
20+
return this.iceCube;
21+
}
22+
}
23+
24+
public IceCubeIdentifier(string name, CardModificationInfo mods = null)
25+
{
26+
this.name = name;
27+
this.mods = mods;
28+
}
29+
30+
private void SetParams(CardInfo card)
31+
{
32+
this.iceCube = new IceCubeParams();
33+
34+
this.iceCube.creatureWithin = card;
35+
36+
if (this.mods != null)
37+
{
38+
this.iceCube.creatureWithin.mods.Add(this.mods);
39+
}
40+
}
41+
42+
public override string ToString()
43+
{
44+
return name;
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)