Elin Decompiled Documentation EA 23.188 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 static Affinity Get(Chara c)
37 {
38 CC = c;
39 foreach (Affinity item in list)
40 {
41 if (c._affinity < item.value)
42 {
43 return item;
44 }
45 }
46 return list.LastItem();
47 }
48
49 public bool CanForceTradeEquip()
50 {
51 return CurrentStage >= Stage.Respected;
52 }
53
54 public bool CanInvite()
55 {
57 {
58 return CurrentStage >= Stage.Respected;
59 }
60 return true;
61 }
62
63 public bool CanGiveCard()
64 {
65 return CurrentStage >= Stage.Love;
66 }
67
68 public bool CanMarry()
69 {
71 {
72 return CurrentStage >= Stage.Love;
73 }
74 return true;
75 }
76
77 public bool CanSleepBeside()
78 {
80 {
81 return CurrentStage >= Stage.Fond;
82 }
83 return true;
84 }
85
86 public int GetLunchChance()
87 {
88 if (!EClass.debug.enable)
89 {
90 if (CurrentStage < Stage.LoveLoveLove)
91 {
92 if (CurrentStage < Stage.LoveLove)
93 {
94 if (CurrentStage < Stage.Love)
95 {
96 return 0;
97 }
98 return 10;
99 }
100 return 40;
101 }
102 return 80;
103 }
104 return 100;
105 }
106
107 public Sprite GetIcon()
108 {
109 int affinity = CC._affinity;
110 if (affinity <= -100)
111 {
113 }
114 if (affinity <= -10)
115 {
117 }
118 if (CurrentStage >= Stage.Love)
119 {
121 }
122 if (CurrentStage >= Stage.Respected)
123 {
125 }
126 return null;
127 }
128
130 {
131 t.CheckJustCooked();
132 Thing result = CC.AddThing(t.Thing);
133 EClass.pc.PlaySound("build_resource");
134 int num = 0;
135 bool num2 = t.HasTag(CTAG.gift);
136 bool flag = t.category.IsChildOf(CC.GetFavCat());
137 bool flag2 = t.id == CC.GetFavFood().id;
139 {
140 flag2 = true;
141 }
142 num = Mathf.Clamp(t.GetPrice() / (flag2 ? 10 : (flag ? 20 : 200)), 0, 50) + (flag2 ? 20 : (flag ? 5 : 0));
143 num = num * (100 + (t.HasElement(757) ? 50 : 0)) / (100 + CC.LV * 10);
144 if (num2)
145 {
146 num += 100;
147 CC.Say("give_ring", CC);
148 CC.Talk("thanks3");
149 }
150 else if (flag2 || num > 20)
151 {
152 CC.Talk("thanks3");
153 }
154 else if (flag || num > 10)
155 {
156 CC.Talk("thanks");
157 }
158 else
159 {
160 CC.Talk("thanks2");
161 }
162 CC.ModAffinity(EClass.pc, num);
163 return result;
164 }
165
166 public void OnTalkRumor()
167 {
168 bool flag = EClass.rnd(60 + EClass.pc.CHA * 2 + EClass.pc.Evalue(291) * 3) > 50 + difficulty + EClass.rnd(CC.CHA + 1);
170 {
171 CC.interest -= 10 + EClass.rnd(10);
172 }
174 {
175 if (EClass.rnd(4) == 0)
176 {
177 CC.ModAffinity(EClass.pc, flag ? 1 : 0, show: false);
178 EClass.pc.ModExp(291, 5);
179 }
180 }
181 else
182 {
183 CC.ModAffinity(EClass.pc, flag ? (EClass.rnd(4) + 1) : (-EClass.rnd(4) - 1), show: false);
184 EClass.pc.ModExp(291, 20);
185 }
186 }
187
188 public int Mod(int a)
189 {
190 if (a < 0)
191 {
192 CC._affinity += a;
193 return a;
194 }
195 int num = 0;
196 for (int i = 0; i < a; i++)
197 {
198 Affinity affinity = Get(CC);
199 if (EClass.rnd(100 + affinity.difficulty) < 100)
200 {
201 CC._affinity++;
202 num++;
203 }
204 }
205 return num;
206 }
207}
CTAG
Definition: CTAG.cs:2
bool CanInvite()
Definition: Affinity.cs:54
string Name
Definition: Affinity.cs:34
static Affinity Get(Chara c)
Definition: Affinity.cs:36
void OnTalkRumor()
Definition: Affinity.cs:166
int Mod(int a)
Definition: Affinity.cs:188
Stage CurrentStage
Definition: Affinity.cs:32
bool CanMarry()
Definition: Affinity.cs:68
bool CanSleepBeside()
Definition: Affinity.cs:77
static Chara CC
Definition: Affinity.cs:24
Sprite GetIcon()
Definition: Affinity.cs:107
int GetLunchChance()
Definition: Affinity.cs:86
static List< Affinity > list
Definition: Affinity.cs:30
bool CanForceTradeEquip()
Definition: Affinity.cs:49
bool CanGiveCard()
Definition: Affinity.cs:63
int value
Definition: Affinity.cs:26
int difficulty
Definition: Affinity.cs:28
Thing OnGift(Thing t)
Definition: Affinity.cs:129
bool IsPCFactionOrMinion
Definition: Card.cs:2234
bool HasElement(int ele, int req=1)
Definition: Card.cs:5638
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:5852
virtual int GetPrice(CurrencyType currency=CurrencyType.Money, bool sell=false, PriceType priceType=PriceType.Default, Chara c=null)
Definition: Card.cs:6951
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:3057
void Talk(string idTopic, string ref1=null, string ref2=null, bool forceSync=false)
Definition: Card.cs:6402
int CHA
Definition: Card.cs:2309
bool HasTag(CTAG tag)
Definition: Card.cs:2557
Trait trait
Definition: Card.cs:51
virtual Thing Thing
Definition: Card.cs:2020
int Evalue(int ele)
Definition: Card.cs:2533
void CheckJustCooked()
Definition: Card.cs:6305
void ModExp(string alias, int a)
Definition: Card.cs:2610
SourceCategory.Row category
Definition: Card.cs:2011
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6499
Definition: Chara.cs:10
SourceCategory.Row GetFavCat()
Definition: Chara.cs:7680
int _affinity
Definition: Chara.cs:301
void ModAffinity(Chara c, int a, bool show=true, bool showOnlyEmo=false)
Definition: Chara.cs:7567
SourceThing.Row GetFavFood()
Definition: Chara.cs:7660
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:130
Icons icons
Definition: CoreRef.cs:353
CoreRef refs
Definition: Core.cs:51
Definition: EClass.cs:5
static GameData gamedata
Definition: EClass.cs:36
static Core core
Definition: EClass.cs:6
static int rnd(long a)
Definition: EClass.cs:58
static Chara pc
Definition: EClass.cs:14
static CoreDebug debug
Definition: EClass.cs:48
List< Affinity > affinities
Definition: GameData.cs:5
Definition: Lang.cs:6
static string[] GetList(string id)
Definition: Lang.cs:114
Definition: Thing.cs:8