Elin Decompiled Documentation EA 23.219 Nightly 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 flag = t.HasTag(CTAG.gift);
136 if (t.trait is TraitFoodChuryu && CC.IsCat)
137 {
138 flag = true;
139 }
140 bool flag2 = t.category.IsChildOf(CC.GetFavCat());
141 bool flag3 = t.id == CC.GetFavFood().id;
143 {
144 flag3 = true;
145 }
146 num = Mathf.Clamp(t.GetPrice() / (flag3 ? 10 : (flag2 ? 20 : 200)), 0, 50) + (flag3 ? 20 : (flag2 ? 5 : 0));
147 num = num * (100 + (t.HasElement(757) ? 50 : 0)) / (100 + CC.LV * 10);
148 if (flag)
149 {
150 num += 100;
151 CC.Say("give_ring", CC);
152 CC.Talk("thanks3");
153 }
154 else if (flag3 || num > 20)
155 {
156 CC.Talk("thanks3");
157 }
158 else if (flag2 || num > 10)
159 {
160 CC.Talk("thanks");
161 }
162 else
163 {
164 CC.Talk("thanks2");
165 }
166 CC.ModAffinity(EClass.pc, num);
167 return result;
168 }
169
170 public void OnTalkRumor()
171 {
172 bool flag = EClass.rnd(60 + EClass.pc.CHA * 2 + EClass.pc.Evalue(291) * 3) > 50 + difficulty + EClass.rnd(CC.CHA + 1);
174 {
175 CC.interest -= 10 + EClass.rnd(10);
176 }
178 {
179 if (EClass.rnd(4) == 0)
180 {
181 CC.ModAffinity(EClass.pc, flag ? 1 : 0, show: false);
182 EClass.pc.ModExp(291, 5);
183 }
184 }
185 else
186 {
187 CC.ModAffinity(EClass.pc, flag ? (EClass.rnd(4) + 1) : (-EClass.rnd(4) - 1), show: false);
188 EClass.pc.ModExp(291, 20);
189 }
190 }
191
192 public int Mod(int a)
193 {
194 if (a < 0)
195 {
196 CC._affinity += a;
197 return a;
198 }
199 int num = 0;
200 for (int i = 0; i < a; i++)
201 {
202 Affinity affinity = Get(CC);
203 if (EClass.rnd(100 + affinity.difficulty) < 100)
204 {
205 CC._affinity++;
206 num++;
207 }
208 }
209 return num;
210 }
211}
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:170
int Mod(int a)
Definition: Affinity.cs:192
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:2260
bool HasElement(int ele, int req=1)
Definition: Card.cs:5787
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:6001
virtual int GetPrice(CurrencyType currency=CurrencyType.Money, bool sell=false, PriceType priceType=PriceType.Default, Chara c=null)
Definition: Card.cs:7105
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:3085
void Talk(string idTopic, string ref1=null, string ref2=null, bool forceSync=false)
Definition: Card.cs:6556
int CHA
Definition: Card.cs:2335
bool HasTag(CTAG tag)
Definition: Card.cs:2583
Trait trait
Definition: Card.cs:53
virtual Thing Thing
Definition: Card.cs:2046
int Evalue(int ele)
Definition: Card.cs:2559
void CheckJustCooked()
Definition: Card.cs:6459
void ModExp(string alias, int a)
Definition: Card.cs:2636
SourceCategory.Row category
Definition: Card.cs:2037
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6653
Definition: Chara.cs:10
SourceCategory.Row GetFavCat()
Definition: Chara.cs:7844
int _affinity
Definition: Chara.cs:301
void ModAffinity(Chara c, int a, bool show=true, bool showOnlyEmo=false)
Definition: Chara.cs:7731
SourceThing.Row GetFavFood()
Definition: Chara.cs:7824
bool IsCat
Definition: Chara.cs:985
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: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