Elin Decompiled Documentation EA 23.278 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 CanGiveCard()
66 {
67 return CurrentStage >= Stage.Love;
68 }
69
70 public bool CanMarry()
71 {
73 {
74 return CurrentStage >= Stage.Love;
75 }
76 return true;
77 }
78
79 public bool CanSleepBeside()
80 {
82 {
83 return CurrentStage >= Stage.Fond;
84 }
85 return true;
86 }
87
88 public int GetLunchChance()
89 {
90 if (!EClass.debug.enable)
91 {
92 if (CurrentStage < Stage.LoveLoveLove)
93 {
94 if (CurrentStage < Stage.LoveLove)
95 {
96 if (CurrentStage < Stage.Love)
97 {
98 return 0;
99 }
100 return 10;
101 }
102 return 40;
103 }
104 return 80;
105 }
106 return 100;
107 }
108
109 public Sprite GetIcon()
110 {
111 int affinity = CC._affinity;
112 if (affinity <= -100)
113 {
115 }
116 if (affinity <= -10)
117 {
119 }
120 if (CurrentStage >= Stage.Love)
121 {
123 }
124 if (CurrentStage >= Stage.Respected)
125 {
127 }
128 return null;
129 }
130
132 {
133 t.CheckJustCooked();
134 Thing result = CC.AddThing(t.Thing);
135 EClass.pc.PlaySound("build_resource");
136 int num = 0;
137 bool flag = t.HasTag(CTAG.gift);
138 if (t.trait is TraitFoodChuryu && CC.IsCat)
139 {
140 flag = true;
141 }
142 bool flag2 = t.category.IsChildOf(CC.GetFavCat());
143 bool flag3 = t.id == CC.GetFavFood().id;
145 {
146 flag3 = true;
147 }
148 num = Mathf.Clamp(t.GetPrice() / (flag3 ? 10 : (flag2 ? 20 : 200)), 0, 50) + (flag3 ? 20 : (flag2 ? 5 : 0));
149 num = num * (100 + (t.HasElement(757) ? 50 : 0)) / (100 + CC.LV * 10);
150 if (flag)
151 {
152 num += 100;
153 CC.Say("give_ring", CC);
154 CC.Talk("thanks3");
155 }
156 else if (flag3 || num > 20)
157 {
158 CC.Talk("thanks3");
159 }
160 else if (flag2 || num > 10)
161 {
162 CC.Talk("thanks");
163 }
164 else
165 {
166 CC.Talk("thanks2");
167 }
168 CC.ModAffinity(EClass.pc, num);
169 return result;
170 }
171
172 public void OnTalkRumor()
173 {
174 bool flag = EClass.rnd(60 + EClass.pc.CHA * 2 + EClass.pc.Evalue(291) * 3) > 50 + difficulty + EClass.rnd(CC.CHA + 1);
176 {
177 CC.interest -= 10 + EClass.rnd(10);
178 }
180 {
181 if (EClass.rnd(4) == 0)
182 {
183 CC.ModAffinity(EClass.pc, flag ? 1 : 0, show: false);
184 EClass.pc.ModExp(291, 5);
185 }
186 }
187 else
188 {
189 CC.ModAffinity(EClass.pc, flag ? (EClass.rnd(4) + 1) : (-EClass.rnd(4) - 1), show: false);
190 EClass.pc.ModExp(291, 20);
191 }
192 }
193
194 public int Mod(int a)
195 {
196 if (a < 0)
197 {
198 CC._affinity += a;
199 return a;
200 }
201 int num = 0;
202 for (int i = 0; i < a; i++)
203 {
204 Affinity affinity = Get(CC);
205 if (EClass.rnd(100 + affinity.difficulty) < 100)
206 {
207 CC._affinity++;
208 num++;
209 }
210 }
211 return num;
212 }
213}
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:172
int Mod(int a)
Definition: Affinity.cs:194
Stage CurrentStage
Definition: Affinity.cs:32
bool CanMarry()
Definition: Affinity.cs:70
bool CanSleepBeside()
Definition: Affinity.cs:79
static Chara CC
Definition: Affinity.cs:24
Sprite GetIcon()
Definition: Affinity.cs:109
int GetLunchChance()
Definition: Affinity.cs:88
static List< Affinity > list
Definition: Affinity.cs:30
bool CanForceTradeEquip()
Definition: Affinity.cs:51
bool CanGiveCard()
Definition: Affinity.cs:65
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:131
bool IsPCFactionOrMinion
Definition: Card.cs:2300
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:6343
virtual int GetPrice(CurrencyType currency=CurrencyType.Money, bool sell=false, PriceType priceType=PriceType.Default, Chara c=null)
Definition: Card.cs:7472
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:3152
void Talk(string idTopic, string ref1=null, string ref2=null, bool forceSync=false)
Definition: Card.cs:6903
int CHA
Definition: Card.cs:2375
bool HasTag(CTAG tag)
Definition: Card.cs:2623
Trait trait
Definition: Card.cs:54
virtual Thing Thing
Definition: Card.cs:2084
int Evalue(int ele)
Definition: Card.cs:2599
void CheckJustCooked()
Definition: Card.cs:6806
void ModExp(string alias, int a)
Definition: Card.cs:2676
SourceCategory.Row category
Definition: Card.cs:2075
bool HasElement(int ele, bool includeNagative=false)
Definition: Card.cs:6090
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:7020
Definition: Chara.cs:10
SourceCategory.Row GetFavCat()
Definition: Chara.cs:8190
int _affinity
Definition: Chara.cs:305
void ModAffinity(Chara c, int a, bool show=true, bool showOnlyEmo=false)
Definition: Chara.cs:8071
SourceThing.Row GetFavFood()
Definition: Chara.cs:8170
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:114
Definition: Thing.cs:8