Elin Decompiled Documentation EA 23.102 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 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 CanMarry()
64 {
66 {
67 return CurrentStage >= Stage.Love;
68 }
69 return true;
70 }
71
72 public bool CanSleepBeside()
73 {
75 {
76 return CurrentStage >= Stage.Fond;
77 }
78 return true;
79 }
80
81 public Sprite GetIcon()
82 {
83 int affinity = CC._affinity;
84 if (affinity <= -100)
85 {
87 }
88 if (affinity <= -10)
89 {
91 }
92 if (CurrentStage >= Stage.Love)
93 {
95 }
96 if (CurrentStage >= Stage.Respected)
97 {
99 }
100 return null;
101 }
102
104 {
105 t.CheckJustCooked();
106 Thing result = CC.AddThing(t.Thing);
107 EClass.pc.PlaySound("build_resource");
108 int num = 0;
109 bool num2 = t.HasTag(CTAG.gift);
110 bool flag = t.category.IsChildOf(CC.GetFavCat());
111 bool flag2 = t.id == CC.GetFavFood().id;
113 {
114 flag2 = true;
115 }
116 num = Mathf.Clamp(t.GetPrice() / (flag2 ? 10 : (flag ? 20 : 200)), 0, 50) + (flag2 ? 20 : (flag ? 5 : 0));
117 num = num * (100 + (t.HasElement(757) ? 50 : 0)) / (100 + CC.LV * 10);
118 if (num2)
119 {
120 num += 100;
121 CC.Say("give_ring", CC);
122 CC.Talk("thanks3");
123 }
124 else if (flag2 || num > 20)
125 {
126 CC.Talk("thanks3");
127 }
128 else if (flag || num > 10)
129 {
130 CC.Talk("thanks");
131 }
132 else
133 {
134 CC.Talk("thanks2");
135 }
136 CC.ModAffinity(EClass.pc, num);
137 return result;
138 }
139
140 public void OnTalkRumor()
141 {
142 bool flag = EClass.rnd(60 + EClass.pc.CHA * 2 + EClass.pc.Evalue(291) * 3) > 50 + difficulty + EClass.rnd(CC.CHA + 1);
144 {
145 CC.interest -= 10 + EClass.rnd(10);
146 }
148 {
149 if (EClass.rnd(4) == 0)
150 {
151 CC.ModAffinity(EClass.pc, flag ? 1 : 0, show: false);
152 EClass.pc.ModExp(291, 5);
153 }
154 }
155 else
156 {
157 CC.ModAffinity(EClass.pc, flag ? (EClass.rnd(4) + 1) : (-EClass.rnd(4) - 1), show: false);
158 EClass.pc.ModExp(291, 20);
159 }
160 }
161
162 public int Mod(int a)
163 {
164 if (a < 0)
165 {
166 CC._affinity += a;
167 return a;
168 }
169 int num = 0;
170 for (int i = 0; i < a; i++)
171 {
172 Affinity affinity = Get(CC);
173 if (EClass.rnd(100 + affinity.difficulty) < 100)
174 {
175 CC._affinity++;
176 num++;
177 }
178 }
179 return num;
180 }
181}
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:140
int Mod(int a)
Definition: Affinity.cs:162
Stage CurrentStage
Definition: Affinity.cs:32
bool CanMarry()
Definition: Affinity.cs:63
bool CanSleepBeside()
Definition: Affinity.cs:72
static Chara CC
Definition: Affinity.cs:24
Sprite GetIcon()
Definition: Affinity.cs:81
static List< Affinity > list
Definition: Affinity.cs:30
bool CanForceTradeEquip()
Definition: Affinity.cs:49
int value
Definition: Affinity.cs:26
int difficulty
Definition: Affinity.cs:28
Thing OnGift(Thing t)
Definition: Affinity.cs:103
bool IsPCFactionOrMinion
Definition: Card.cs:2132
bool HasElement(int ele, int req=1)
Definition: Card.cs:5214
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:5404
virtual int GetPrice(CurrencyType currency=CurrencyType.Money, bool sell=false, PriceType priceType=PriceType.Default, Chara c=null)
Definition: Card.cs:6449
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:2901
void Talk(string idTopic, string ref1=null, string ref2=null, bool forceSync=false)
Definition: Card.cs:5949
int CHA
Definition: Card.cs:2207
bool HasTag(CTAG tag)
Definition: Card.cs:2455
Trait trait
Definition: Card.cs:49
virtual Thing Thing
Definition: Card.cs:1934
int Evalue(int ele)
Definition: Card.cs:2431
void CheckJustCooked()
Definition: Card.cs:5857
void ModExp(string alias, int a)
Definition: Card.cs:2508
SourceCategory.Row category
Definition: Card.cs:1925
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6046
Definition: Chara.cs:10
SourceCategory.Row GetFavCat()
Definition: Chara.cs:7274
int _affinity
Definition: Chara.cs:288
void ModAffinity(Chara c, int a, bool show=true, bool showOnlyEmo=false)
Definition: Chara.cs:7166
SourceThing.Row GetFavFood()
Definition: Chara.cs:7254
bool marryAnytime
Definition: CoreDebug.cs:223
bool inviteAnytime
Definition: CoreDebug.cs:221
bool unlimitedInterest
Definition: CoreDebug.cs:219
bool alwaysFavFood
Definition: CoreDebug.cs:227
Affinity affnity
Definition: CoreRef.cs:128
Icons icons
Definition: CoreRef.cs:339
CoreRef refs
Definition: Core.cs:51
Definition: EClass.cs:5
static int rnd(int a)
Definition: EClass.cs:50
static GameData gamedata
Definition: EClass.cs:36
static Core core
Definition: EClass.cs:6
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