Skip to content

Commit 228e05d

Browse files
committed
Refactored and moved specific patches to /Patches.
Moved adding new abilities, cards, regions to /Models
1 parent 5797722 commit 228e05d

File tree

12 files changed

+633
-484
lines changed

12 files changed

+633
-484
lines changed

Models/CustomCard.cs

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
using System.Collections.Generic;
2+
using DiskCardGame;
3+
using UnityEngine;
4+
5+
namespace APIPlugin
6+
{
7+
public class CustomCard
8+
{
9+
public static List<CustomCard> cards = new List<CustomCard>();
10+
public string name;
11+
public List<CardMetaCategory> metaCategories;
12+
public CardComplexity? cardComplexity;
13+
public CardTemple? temple;
14+
public string displayedName;
15+
public int? baseAttack;
16+
public int? baseHealth;
17+
public string description;
18+
public bool? hideAttackAndHealth;
19+
public int? cost;
20+
public int? bonesCost;
21+
public int? energyCost;
22+
public List<GemType> gemsCost;
23+
public SpecialStatIcon? specialStatIcon;
24+
public List<Tribe> tribes;
25+
public List<Trait> traits;
26+
public List<SpecialTriggeredAbility> specialAbilities;
27+
public List<Ability> abilities;
28+
public EvolveParams evolveParams;
29+
public string defaultEvolutionName;
30+
public TailParams tailParams;
31+
public IceCubeParams iceCubeParams;
32+
public bool? flipPortraitForStrafe;
33+
public bool? onePerDeck;
34+
public List<CardAppearanceBehaviour.Appearance> appearanceBehaviour;
35+
[IgnoreMapping]
36+
public Texture2D tex;
37+
[IgnoreMapping]
38+
public Texture2D altTex;
39+
public Texture titleGraphic;
40+
[IgnoreMapping]
41+
public Texture2D pixelTex;
42+
public GameObject animatedPortrait;
43+
public List<Texture> decals;
44+
45+
public CustomCard(string name)
46+
{
47+
this.name = name;
48+
CustomCard.cards.Add(this);
49+
}
50+
51+
public CardInfo AdjustCard(CardInfo card)
52+
{
53+
TypeMapper<CustomCard, CardInfo>.Convert(this, card);
54+
55+
if (this.tex is not null)
56+
{
57+
tex.name = "portrait_" + name;
58+
tex.filterMode = FilterMode.Point;
59+
card.portraitTex = Sprite.Create(tex, new Rect(0.0f, 0.0f, 114.0f, 94.0f), new Vector2(0.5f, 0.5f));
60+
card.portraitTex.name = "portrait_" + name;
61+
}
62+
if (this.altTex is not null)
63+
{
64+
altTex.name = "portrait_" + name;
65+
altTex.filterMode = FilterMode.Point;
66+
card.alternatePortrait = Sprite.Create(altTex, new Rect(0.0f, 0.0f, 114.0f, 94.0f), new Vector2(0.5f, 0.5f));
67+
card.alternatePortrait.name = "portrait_" + name;
68+
}
69+
if (this.pixelTex is not null)
70+
{
71+
pixelTex.name = "portrait_" + name;
72+
pixelTex.filterMode = FilterMode.Point;
73+
card.pixelPortrait = Sprite.Create(pixelTex, new Rect(0.0f, 0.0f, 41.0f, 28.0f), new Vector2(0.5f, 0.5f));
74+
card.pixelPortrait.name = "portrait_" + name;
75+
}
76+
Plugin.Log.LogInfo($"Adjusted default card {name}!");
77+
return card;
78+
}
79+
}
80+
}

Models/CustomRegion.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using System.Collections.Generic;
2+
using DiskCardGame;
3+
using UnityEngine;
4+
5+
namespace APIPlugin
6+
{
7+
public class CustomRegion
8+
{
9+
public static List<CustomRegion> regions = new List<CustomRegion>();
10+
public string name;
11+
public int? tier;
12+
private List<CardInfo> terrainCards;
13+
private List<ConsumableItemData> consumableItems;
14+
private List<EncounterBlueprintData> encounters;
15+
private List<Opponent.Type> bosses;
16+
private List<CardInfo> likelyCards;
17+
private List<Tribe> dominantTribes;
18+
private PredefinedNodes predefinedNodes;
19+
private EncounterBlueprintData bossPrepEncounter;
20+
private StoryEventCondition bossPrepCondition;
21+
private List<ScarceSceneryEntry> scarceScenery;
22+
private List<FillerSceneryEntry> fillerScenery;
23+
private PredefinedScenery predefinedScenery;
24+
private string ambientLoopId;
25+
private bool? silenceCabinAmbience;
26+
private Color? boardLightColor;
27+
private Color? cardsLightColor;
28+
private bool? dustParticlesDisabled;
29+
private bool? fogEnabled;
30+
private VolumetricFogAndMist.VolumetricFogProfile fogProfile;
31+
private float? fogAlpha;
32+
private Texture mapAlbedo;
33+
private Texture mapEmission;
34+
private Color? mapEmissionColor;
35+
private List<GameObject> mapParticlesPrefabs;
36+
37+
public CustomRegion(string name)
38+
{
39+
this.name = name;
40+
CustomRegion.regions.Add(this);
41+
}
42+
43+
public RegionData AdjustRegion(RegionData region)
44+
{
45+
TypeMapper<CustomRegion, RegionData>.Convert(this, region);
46+
Plugin.Log.LogInfo($"Adjusted default region {name}!");
47+
return region;
48+
}
49+
50+
}
51+
}

Models/NewAbility.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using DiskCardGame;
4+
using UnityEngine;
5+
6+
namespace APIPlugin
7+
{
8+
public class NewAbility
9+
{
10+
public static List<NewAbility> abilities = new List<NewAbility>();
11+
public Ability ability;
12+
public AbilityInfo info;
13+
public Type abilityBehaviour;
14+
public Texture tex;
15+
16+
public NewAbility(AbilityInfo info, Type abilityBehaviour, Texture tex)
17+
{
18+
this.ability = (Ability) 100 + NewAbility.abilities.Count;
19+
info.ability = this.ability;
20+
this.info = info;
21+
this.abilityBehaviour = abilityBehaviour;
22+
this.tex = tex;
23+
NewAbility.abilities.Add(this);
24+
Plugin.Log.LogInfo($"Loaded custom ability {info.rulebookName}!");
25+
}
26+
}
27+
}

Models/NewCard.cs

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
using System.Collections.Generic;
2+
using DiskCardGame;
3+
using UnityEngine;
4+
5+
namespace APIPlugin
6+
{
7+
public static class NewCard
8+
{
9+
public static List<CardInfo> cards = new List<CardInfo>();
10+
private static readonly Vector2 DefaultVector2 = new Vector2(0.5f, 0.5f);
11+
private static readonly Rect DefaultCardArtRect = new Rect(0.0f, 0.0f, 114.0f, 94.0f);
12+
private static readonly Rect DefaultCardPixelArtRect = new Rect(0.0f, 0.0f, 41.0f, 28.0f);
13+
14+
public static void Add(CardInfo card)
15+
{
16+
NewCard.cards.Add(card);
17+
Plugin.Log.LogInfo($"Loaded custom card {card.name}!");
18+
}
19+
20+
// TODO Implement a handler for custom appearanceBehaviour - in particular custom card backs
21+
// TODO Change parameter order, and function setter call order to make more sense
22+
// TODO Rename parameters to be more user friendly
23+
public static void Add(string name, List<CardMetaCategory> metaCategories, CardComplexity cardComplexity,
24+
CardTemple temple, string displayedName, int baseAttack, int baseHealth,
25+
string description = null,
26+
bool hideAttackAndHealth = false, int cost = 0, int bonesCost = 0, int energyCost = 0,
27+
List<GemType> gemsCost = null, SpecialStatIcon specialStatIcon = SpecialStatIcon.None,
28+
List<Tribe> tribes = null, List<Trait> traits = null, List<SpecialTriggeredAbility> specialAbilities = null,
29+
List<Ability> abilities = null, EvolveParams evolveParams = null,
30+
string defaultEvolutionName = null, TailParams tailParams = null, IceCubeParams iceCubeParams = null,
31+
bool flipPortraitForStrafe = false, bool onePerDeck = false,
32+
List<CardAppearanceBehaviour.Appearance> appearanceBehaviour = null, Texture2D tex = null,
33+
Texture2D altTex = null, Texture titleGraphic = null, Texture2D pixelTex = null,
34+
GameObject animatedPortrait = null, List<Texture> decals = null)
35+
{
36+
CardInfo card = ScriptableObject.CreateInstance<CardInfo>();
37+
38+
// names / descryptions
39+
card.defaultEvolutionName = defaultEvolutionName;
40+
card.displayedName = displayedName;
41+
card.name = name;
42+
43+
if (description != "")
44+
{
45+
card.description = description;
46+
}
47+
48+
// card info
49+
card.baseAttack = baseAttack;
50+
card.baseHealth = baseHealth;
51+
card.cardComplexity = cardComplexity;
52+
card.flipPortraitForStrafe = flipPortraitForStrafe;
53+
card.hideAttackAndHealth = hideAttackAndHealth;
54+
card.metaCategories = metaCategories;
55+
card.onePerDeck = onePerDeck;
56+
card.specialStatIcon = specialStatIcon;
57+
card.temple = temple;
58+
59+
if (tribes is not null)
60+
{
61+
card.tribes = tribes;
62+
}
63+
64+
if (traits is not null)
65+
{
66+
card.traits = traits;
67+
}
68+
69+
if (specialAbilities is not null)
70+
{
71+
card.specialAbilities = specialAbilities;
72+
}
73+
74+
if (abilities is not null)
75+
{
76+
card.abilities = abilities;
77+
}
78+
79+
if (evolveParams is not null)
80+
{
81+
card.evolveParams = evolveParams;
82+
}
83+
84+
if (tailParams is not null)
85+
{
86+
card.tailParams = tailParams;
87+
}
88+
89+
if (iceCubeParams is not null)
90+
{
91+
card.iceCubeParams = iceCubeParams;
92+
}
93+
94+
if (appearanceBehaviour is not null)
95+
{
96+
card.appearanceBehaviour = appearanceBehaviour;
97+
}
98+
99+
// costs
100+
card.cost = cost;
101+
card.bonesCost = bonesCost;
102+
card.energyCost = energyCost;
103+
104+
if (gemsCost is not null)
105+
{
106+
card.gemsCost = gemsCost;
107+
}
108+
109+
// textures
110+
DetermineAndSetCardArt(name, card, tex, altTex, pixelTex);
111+
112+
if (animatedPortrait is not null)
113+
{
114+
// TODO Provide a function to create animated card textures
115+
card.animatedPortrait = animatedPortrait;
116+
}
117+
118+
if (decals is not null)
119+
{
120+
// TODO Access and provide default decals
121+
card.decals = decals;
122+
}
123+
124+
if (titleGraphic is not null)
125+
{
126+
card.titleGraphic = titleGraphic;
127+
}
128+
129+
NewCard.cards.Add(card);
130+
Plugin.Log.LogInfo($"Loaded custom card {name}!");
131+
}
132+
133+
private static void DetermineAndSetCardArt(
134+
string name, CardInfo card,
135+
Texture2D tex, Texture2D altTex, Texture2D pixelTex)
136+
{
137+
var newName = "portrait_" + name;
138+
if (tex is not null)
139+
{
140+
tex.name = newName;
141+
tex.filterMode = FilterMode.Point;
142+
143+
card.portraitTex = Sprite.Create(tex, DefaultCardArtRect, DefaultVector2);
144+
card.portraitTex.name = newName;
145+
}
146+
147+
if (altTex is not null)
148+
{
149+
altTex.name = newName;
150+
altTex.filterMode = FilterMode.Point;
151+
152+
card.alternatePortrait = Sprite.Create(altTex, DefaultCardArtRect, DefaultVector2);
153+
card.alternatePortrait.name = newName;
154+
}
155+
156+
if (pixelTex is not null)
157+
{
158+
pixelTex.name = newName;
159+
pixelTex.filterMode = FilterMode.Point;
160+
161+
card.pixelPortrait = Sprite.Create(pixelTex, DefaultCardPixelArtRect, DefaultVector2);
162+
card.pixelPortrait.name = newName;
163+
}
164+
}
165+
}
166+
}

Models/NewRegion.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.Collections.Generic;
2+
using DiskCardGame;
3+
4+
namespace APIPlugin
5+
{
6+
public class NewRegion
7+
{
8+
public static List<NewRegion> regions = new List<NewRegion>();
9+
public RegionData region;
10+
public int tier;
11+
12+
public NewRegion(RegionData region, int tier){
13+
this.region = region;
14+
this.tier = tier;
15+
NewRegion.regions.Add(this);
16+
Plugin.Log.LogInfo($"Loaded custom region {region.name}!");
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)