Elin Decompiled Documentation EA 23.327 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 return CurrentStage >= Stage.Love;
73 }
74
75 public bool CanMarry()
76 {
78 {
79 return CurrentStage >= Stage.Love;
80 }
81 return true;
82 }
83
84 public bool CanSleepBeside()
85 {
87 {
88 return CurrentStage >= Stage.Fond;
89 }
90 return true;
91 }
92
93 public int GetLunchChance()
94 {
95 if (!EClass.debug.enable)
96 {
97 if (CurrentStage < Stage.LoveLoveLove)
98 {
99 if (CurrentStage < Stage.LoveLove)
100 {
101 if (CurrentStage < Stage.Love)
102 {
103 return 0;
104 }
105 return 10;
106 }
107 return 40;
108 }
109 return 80;
110 }
111 return 100;
112 }
113
114 public Sprite GetIcon()
115 {
116 int affinity = CC._affinity;
117 if (affinity <= -100)
118 {
120 }
121 if (affinity <= -10)
122 {
124 }
125 if (CurrentStage >= Stage.Love)
126 {
128 }
129 if (CurrentStage >= Stage.Respected)
130 {
132 }
133 return null;
134 }
135
137 {
138 t.CheckJustCooked();
139 Thing result = CC.AddThing(t.Thing);
140 EClass.pc.PlaySound("build_resource");
141 int num = 0;
142 bool flag = t.HasTag(CTAG.gift);
143 if (t.trait is TraitFoodChuryu && CC.IsCat)
144 {
145 flag = true;
146 }
147 bool flag2 = t.category.IsChildOf(CC.GetFavCat());
148 bool flag3 = t.id == CC.GetFavFood().id;
150 {
151 flag3 = true;
152 }
153 num = Mathf.Clamp(t.GetPrice() / (flag3 ? 10 : (flag2 ? 20 : 200)), 0, 50) + (flag3 ? 20 : (flag2 ? 5 : 0));
154 num = num * (100 + (t.HasElement(757) ? 50 : 0)) / (100 + CC.LV * 10);
155 if (flag)
156 {
157 num += 100;
158 CC.Say("give_ring", CC);
159 CC.Talk("thanks3");
160 }
161 else if (flag3 || num > 20)
162 {
163 CC.Talk("thanks3");
164 }
165 else if (flag2 || num > 10)
166 {
167 CC.Talk("thanks");
168 }
169 else
170 {
171 CC.Talk("thanks2");
172 }
173 if (flag3 || flag2)
174 {
175 CC.SetStr(72, CC.GetFavFood().id);
176 CC.SetStr(73, CC.GetFavCat().id);
177 }
178 CC.ModAffinity(EClass.pc, num);
179 return result;
180 }
181
182 public void OnTalkRumor()
183 {
184 bool flag = EClass.rnd(60 + EClass.pc.CHA * 2 + EClass.pc.Evalue(291) * 3) > 50 + difficulty + EClass.rnd(CC.CHA + 1);
186 {
187 CC.interest -= 10 + EClass.rnd(10);
188 }
190 {
191 if (EClass.rnd(4) == 0)
192 {
193 CC.ModAffinity(EClass.pc, flag ? 1 : 0, show: false);
194 EClass.pc.ModExp(291, 5);
195 }
196 }
197 else
198 {
199 CC.ModAffinity(EClass.pc, flag ? (EClass.rnd(4) + 1) : (-EClass.rnd(4) - 1), show: false);
200 EClass.pc.ModExp(291, 20);
201 }
202 }
203
204 public int Mod(int a)
205 {
206 if (a < 0)
207 {
208 CC._affinity += a;
209 return a;
210 }
211 int num = 0;
212 for (int i = 0; i < a; i++)
213 {
214 Affinity affinity = Get(CC);
215 if (EClass.rnd(100 + affinity.difficulty) < 100)
216 {
217 CC._affinity++;
218 num++;
219 }
220 }
221 return num;
222 }
223}
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:182
int Mod(int a)
Definition: Affinity.cs:204
Stage CurrentStage
Definition: Affinity.cs:32
bool CanMarry()
Definition: Affinity.cs:75
bool CanSleepBeside()
Definition: Affinity.cs:84
static Chara CC
Definition: Affinity.cs:24
Sprite GetIcon()
Definition: Affinity.cs:114
int GetLunchChance()
Definition: Affinity.cs:93
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:136
bool IsPCFactionOrMinion
Definition: Card.cs:2342
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:6606
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:3273
void Talk(string idTopic, string ref1=null, string ref2=null, bool forceSync=false)
Definition: Card.cs:7166
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:7069
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:6344
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:7284
Definition: Chara.cs:10
SourceCategory.Row GetFavCat()
Definition: Chara.cs:8476
int _affinity
Definition: Chara.cs:307
void ModAffinity(Chara c, int a, bool show=true, bool showOnlyEmo=false)
Definition: Chara.cs:8344
SourceThing.Row GetFavFood()
Definition: Chara.cs:8443
bool IsCat
Definition: Chara.cs:1034
bool marryAnytime
Definition: CoreDebug.cs:239
bool inviteAnytime
Definition: CoreDebug.cs:237
bool unlimitedInterest
Definition: CoreDebug.cs:235
bool alwaysFavFood
Definition: CoreDebug.cs:243
bool enable
Definition: CoreDebug.cs:301
Affinity affnity
Definition: CoreRef.cs:133
Icons icons
Definition: CoreRef.cs:356
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