Elin Decompiled Documentation EA 23.295 Stable Patch 2
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 CC.ModAffinity(EClass.pc, num);
174 return result;
175 }
176
177 public void OnTalkRumor()
178 {
179 bool flag = EClass.rnd(60 + EClass.pc.CHA * 2 + EClass.pc.Evalue(291) * 3) > 50 + difficulty + EClass.rnd(CC.CHA + 1);
181 {
182 CC.interest -= 10 + EClass.rnd(10);
183 }
185 {
186 if (EClass.rnd(4) == 0)
187 {
188 CC.ModAffinity(EClass.pc, flag ? 1 : 0, show: false);
189 EClass.pc.ModExp(291, 5);
190 }
191 }
192 else
193 {
194 CC.ModAffinity(EClass.pc, flag ? (EClass.rnd(4) + 1) : (-EClass.rnd(4) - 1), show: false);
195 EClass.pc.ModExp(291, 20);
196 }
197 }
198
199 public int Mod(int a)
200 {
201 if (a < 0)
202 {
203 CC._affinity += a;
204 return a;
205 }
206 int num = 0;
207 for (int i = 0; i < a; i++)
208 {
209 Affinity affinity = Get(CC);
210 if (EClass.rnd(100 + affinity.difficulty) < 100)
211 {
212 CC._affinity++;
213 num++;
214 }
215 }
216 return num;
217 }
218}
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:177
int Mod(int a)
Definition: Affinity.cs:199
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:2312
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:6421
virtual int GetPrice(CurrencyType currency=CurrencyType.Money, bool sell=false, PriceType priceType=PriceType.Default, Chara c=null)
Definition: Card.cs:7552
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:3180
void Talk(string idTopic, string ref1=null, string ref2=null, bool forceSync=false)
Definition: Card.cs:6981
int CHA
Definition: Card.cs:2387
bool HasTag(CTAG tag)
Definition: Card.cs:2635
Trait trait
Definition: Card.cs:54
virtual Thing Thing
Definition: Card.cs:2096
int Evalue(int ele)
Definition: Card.cs:2611
void CheckJustCooked()
Definition: Card.cs:6884
void ModExp(string alias, int a)
Definition: Card.cs:2688
SourceCategory.Row category
Definition: Card.cs:2087
bool HasElement(int ele, bool includeNagative=false)
Definition: Card.cs:6168
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:7099
Definition: Chara.cs:10
SourceCategory.Row GetFavCat()
Definition: Chara.cs:8260
int _affinity
Definition: Chara.cs:305
void ModAffinity(Chara c, int a, bool show=true, bool showOnlyEmo=false)
Definition: Chara.cs:8141
SourceThing.Row GetFavFood()
Definition: Chara.cs:8240
bool IsCat
Definition: Chara.cs:1001
bool marryAnytime
Definition: CoreDebug.cs:224
bool inviteAnytime
Definition: CoreDebug.cs:222
bool unlimitedInterest
Definition: CoreDebug.cs:220
bool alwaysFavFood
Definition: CoreDebug.cs:228
bool enable
Definition: CoreDebug.cs:286
Affinity affnity
Definition: CoreRef.cs:132
Icons icons
Definition: CoreRef.cs:355
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:6
static string[] GetList(string id)
Definition: Lang.cs:116
Definition: Thing.cs:8