-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathYourMod.cs
More file actions
135 lines (123 loc) · 2.97 KB
/
YourMod.cs
File metadata and controls
135 lines (123 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
using BerryLoaderNS;
using BepInEx;
using System.Collections;
using System.Reflection;
using UnityEngine;
namespace YourModNS
{
class Main : BerryLoaderMod
{
public override void Init()
{
BerryLoader.L.LogInfo("hello from YourMod.Main.Init");
}
}
class Composter : GameCard
{
protected override void Awake()
{
ReflectionHelper.CopyGameCardProps(this, BerryLoader.tempCurrentGameCard);
base.Awake();
}
protected override void Update()
{
base.Update();
this.CardData.Update();
}
}
class Miku : GameCard
{
protected override void Awake()
{
ReflectionHelper.CopyGameCardProps(this, BerryLoader.tempCurrentGameCard);
base.Awake();
BerryLoader.L.LogInfo("MIKU TIME");
StartCoroutine(Sing());
}
protected override void Update()
{
base.Update();
this.CardData.Update();
}
IEnumerator Sing()
{
while (true)
{
base.RotWobble(1f);
yield return new WaitForSeconds(2f);
}
}
}
class Silo : CardData
{
[ExtraData("holding_id")]
public string holdingId;
[ExtraData("holding_name")]
public string holdingName;
[ExtraData("hold_count")]
public int holdCount;
public int maxCount = 50;
protected override bool CanHaveCard(CardData otherCard) => holdingId.Equals("") ? true : otherCard.Id == holdingId;
public override void Update()
{
if (this.holdCount == 0)
{
this.holdingId = "";
this.holdingName = "";
}
foreach (GameCard childCard in this.MyGameCard.GetChildCards())
{
BerryLoader.L.LogInfo(childCard.CardData.Id);
if (childCard.CardData.Id == holdingId || holdingId.Equals(""))
{
if (this.holdCount < maxCount)
{
childCard.DestroyCard(true);
++this.holdCount;
this.holdingId = childCard.CardData.Id;
this.holdingName = childCard.CardData.Name;
}
}
else
childCard.RemoveFromStack();
}
this.gameObject.GetComponent<ModOverride>().Description = $"Holding {this.holdCount}/{this.maxCount} {this.holdingName}";
base.Update();
}
public override void Clicked()
{
if (this.holdCount > 0)
{
var amount = Mathf.Min(5, holdCount);
GameCard cards = CreateCards(this.transform.position + Vector3.up * 0.2f, holdingId, amount, false);
WorldManager.instance.StackSend(cards.GetRootCard());
this.holdCount -= amount;
if (holdCount == 0)
this.holdingId = "";
}
}
GameCard CreateCards(Vector3 pos, string id, int amount, bool checkAddToStack = true)
{
if (amount == 0)
return (GameCard)null;
GameCard gold = (GameCard)null;
int num;
for (; amount > 0; amount -= num)
{
num = Mathf.Min(amount, 30);
gold = (GameCard)null;
for (int index = 0; index < num; ++index)
{
GameCard gameCard = WorldManager.instance.CreateCard(pos, id, checkAddToStack: checkAddToStack).MyGameCard;
if ((UnityEngine.Object)gold != (UnityEngine.Object)null)
{
gameCard.Parent = gold;
gold.Child = gameCard;
}
gold = gameCard;
}
}
return gold;
}
}
}