Skip to content

Commit 1d334f6

Browse files
Merge pull request #3 from julian-perge/feature/refactor_v1
Feature/refactor v1
2 parents 5797722 + bb23cb7 commit 1d334f6

File tree

13 files changed

+671
-484
lines changed

13 files changed

+671
-484
lines changed

Models/CustomCard.cs

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

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

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)