Elin Decompiled Documentation EA 23.344.1 Nightly
Loading...
Searching...
No Matches
Affinity.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4
5[Serializable]
6public class Affinity : EClass
7{
8 public enum Stage
9 {
10 Foe,
11 Hate,
13 Normal,
18 Fond,
19 Love,
22 }
23
24 public static Chara CC;
25
26 public int value;
27
28 public int difficulty;
29
30 public static List<Affinity> list => EClass.gamedata.affinities;
31
32 public Stage CurrentStage => list.IndexOf(this).ToEnum<Stage>();
33
34 public string Name => Lang.GetList("affinity").TryGet(list.IndexOf(this), list.Count - 1);
35
36 public bool IsWeddingHater => CurrentStage <= Stage.Hate;
37
38 public static Affinity Get(Chara c)
39 {
40 CC = c;
41 foreach (Affinity item in list)
42 {
43 if (c._affinity < item.value)
44 {
45 return item;
46 }
47 }
48 return list.LastItem();
49 }
50
51 public bool CanForceTradeEquip()
52 {
53 return CurrentStage >= Stage.Respected;
54 }
55
56 public bool CanInvite()
57 {
59 {
60 return CurrentStage >= Stage.Respected;
61 }
62 return true;
63 }
64
65 public bool CanBecomeMama()
66 {
67 return CurrentStage >= Stage.Respected;
68 }
69
70 public bool CanGiveCard()
71 {
72 if (CurrentStage >= Stage.Love)
73 {
74 return CC.source.LV < 10000;
75 }
76 return false;
77 }
78
79 public bool CanMarry()
80 {
82 {
83 return CurrentStage >= Stage.Love;
84 }
85 return true;
86 }
87
88 public bool CanSleepBeside()
89 {
91 {
92 return CurrentStage >= Stage.Fond;
93 }
94 return true;
95 }
96
97 public int GetLunchChance()
98 {
99 if (!EClass.debug.enable)
100 {
101 if (CurrentStage < Stage.LoveLoveLove)
102 {
103 if (CurrentStage < Stage.LoveLove)
104 {
105 if (CurrentStage < Stage.Love)
106 {
107 return 0;
108 }
109 return 10;
110 }
111 return 40;
112 }
113 return 80;
114 }
115 return 100;
116 }
117
118 public Sprite GetIcon()
119 {
120 int affinity = CC._affinity;
121 if (affinity <= -100)
122 {
124 }
125 if (affinity <= -10)
126 {
128 }
129 if (CurrentStage >= Stage.Love)
130 {
132 }
133 if (CurrentStage >= Stage.Respected)
134 {
136 }
137 return null;
138 }
139
141 {
142 t.CheckJustCooked();
143 Thing result = CC.AddThing(t.Thing);
144 EClass.pc.PlaySound("build_resource");
145 int num = 0;
146 bool flag = t.HasTag(CTAG.gift);
147 if (t.trait is TraitFoodChuryu && CC.IsCat)
148 {
149 flag = true;
150 }
151 bool flag2 = t.category.IsChildOf(CC.GetFavCat());
152 bool flag3 = t.id == CC.GetFavFood().id;
154 {
155 flag3 = true;
156 }
157 num = Mathf.Clamp(t.GetPrice() / (flag3 ? 10 : (flag2 ? 20 : 200)), 0, 50) + (flag3 ? 20 : (flag2 ? 5 : 0));
158 num = num * (100 + (t.HasElement(757) ? 50 : 0)) / (100 + CC.LV * 10);
159 if (t.category.id == "currency")
160 {
161 num = 0;
162 }
163 if (flag)
164 {
165 num += 100;
166 CC.Say("give_ring", CC);
167 CC.Talk("thanks3");
168 }
169 else if (flag3 || num > 20)
170 {
171 CC.Talk("thanks3");
172 }
173 else if (flag2 || num > 10)
174 {
175 CC.Talk("thanks");
176 }
177 else
178 {
179 CC.Talk("thanks2");
180 }
181 if (flag3 || flag2)
182 {
183 CC.SetStr(72, CC.GetFavFood().id);
184 CC.SetStr(73, CC.GetFavCat().id);
185 }
186 CC.ModAffinity(EClass.pc, num);
187 return result;
188 }
189
190 public void OnTalkRumor()
191 {
192 bool flag = EClass.rnd(60 + EClass.pc.CHA * 2 + EClass.pc.Evalue(291) * 3) > 50 + difficulty + EClass.rnd(CC.CHA + 1);
194 {
195 CC.interest -= 10 + EClass.rnd(10);
196 }
198 {
199 if (EClass.rnd(4) == 0)
200 {
201 CC.ModAffinity(EClass.pc, flag ? 1 : 0, show: false);
202 EClass.pc.ModExp(291, 5);
203 }
204 }
205 else
206 {
207 CC.ModAffinity(EClass.pc, flag ? (EClass.rnd(4) + 1) : (-EClass.rnd(4) - 1), show: false);
208 EClass.pc.ModExp(291, 20);
209 }
210 }
211
212 public int Mod(int a)
213 {
214 if (a < 0)
215 {
216 CC._affinity += a;
217 return a;
218 }
219 int num = 0;
220 for (int i = 0; i < a; i++)
221 {
222 Affinity affinity = Get(CC);
223 if (EClass.rnd(100 + affinity.difficulty) < 100)
224 {
225 CC._affinity++;
226 num++;
227 }
228 }
229 return num;
230 }
231}
CTAG
Definition: CTAG.cs:2
bool CanInvite()
Definition: Affinity.cs:56
string Name
Definition: Affinity.cs:34
static Affinity Get(Chara c)
Definition: Affinity.cs:38
void OnTalkRumor()
Definition: Affinity.cs:190
int Mod(int a)
Definition: Affinity.cs:212
Stage CurrentStage
Definition: Affinity.cs:32
bool CanMarry()
Definition: Affinity.cs:79
bool CanSleepBeside()
Definition: Affinity.cs:88
static Chara CC
Definition: Affinity.cs:24
Sprite GetIcon()
Definition: Affinity.cs:118
int GetLunchChance()
Definition: Affinity.cs:97
static List< Affinity > list
Definition: Affinity.cs:30
bool CanForceTradeEquip()
Definition: Affinity.cs:51
bool CanBecomeMama()
Definition: Affinity.cs:65
bool CanGiveCard()
Definition: Affinity.cs:70
bool IsWeddingHater
Definition: Affinity.cs:36
int value
Definition: Affinity.cs:26
int difficulty
Definition: Affinity.cs:28
Thing OnGift(Thing t)
Definition: Affinity.cs:140
bool IsPCFactionOrMinion
Definition: Card.cs:2342
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:6645
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:3280
void Talk(string idTopic, string ref1=null, string ref2=null, bool forceSync=false)
Definition: Card.cs:7205
int CHA
Definition: Card.cs:2417
bool HasTag(CTAG tag)
Definition: Card.cs:2728
Trait trait
Definition: Card.cs:54
void SetStr(string id, string value=null)
Definition: Card.cs:2600
virtual Thing Thing
Definition: Card.cs:2110
int Evalue(int ele)
Definition: Card.cs:2704
void CheckJustCooked()
Definition: Card.cs:7108
void ModExp(string alias, int a)
Definition: Card.cs:2781
SourceCategory.Row category
Definition: Card.cs:2101
bool HasElement(int ele, bool includeNagative=false)
Definition: Card.cs:6383
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:7323
Definition: Chara.cs:10
SourceCategory.Row GetFavCat()
Definition: Chara.cs:8541
int _affinity
Definition: Chara.cs:307
void ModAffinity(Chara c, int a, bool show=true, bool showOnlyEmo=false)
Definition: Chara.cs:8409
SourceThing.Row GetFavFood()
Definition: Chara.cs:8508
bool IsCat
Definition: Chara.cs:1034
bool marryAnytime
Definition: CoreDebug.cs:240
bool inviteAnytime
Definition: CoreDebug.cs:238
bool unlimitedInterest
Definition: CoreDebug.cs:236
bool alwaysFavFood
Definition: CoreDebug.cs:244
bool enable
Definition: CoreDebug.cs:302
Affinity affnity
Definition: CoreRef.cs:135
Icons icons
Definition: CoreRef.cs:358
CoreRef refs
Definition: Core.cs:51
Definition: EClass.cs:6
static GameData gamedata
Definition: EClass.cs:37
static Core core
Definition: EClass.cs:7
static int rnd(long a)
Definition: EClass.cs:59
static Chara pc
Definition: EClass.cs:15
static CoreDebug debug
Definition: EClass.cs:49
List< Affinity > affinities
Definition: GameData.cs:5
Definition: Lang.cs:7
static string[] GetList(string id)
Definition: Lang.cs:113
Definition: Thing.cs:8
override int GetPrice(CurrencyType currency=CurrencyType.Money, bool sell=false, PriceType priceType=PriceType.Default, Chara c=null)
Definition: Thing.cs:829