Elin Decompiled Documentation EA 23.345.1 Nightly
Loading...
Searching...
No Matches
Expedition.cs
Go to the documentation of this file.
1using Newtonsoft.Json;
2using UnityEngine;
3
4public class Expedition : EClass
5{
6 [JsonProperty]
7 public int hours;
8
9 [JsonProperty]
10 public int uidChara;
11
12 [JsonProperty]
14
16
18
20
21 public int MinHour => (int)((float)hours * 0.8f);
22
23 public int MaxHour => (int)((float)hours * 1.2f);
24
25 public string strType => ("ex" + type).lang();
26
27 public void SetOwner(FactionBranch _branch)
28 {
29 branch = _branch;
30 }
31
32 public void OnCreate()
33 {
34 _ = branch.resources;
35 switch (type)
36 {
37 case ExpeditionType.Search:
38 hours = 24;
39 break;
40 case ExpeditionType.Training:
41 hours = 120;
42 break;
43 case ExpeditionType.Explore:
44 hours = 10;
45 break;
46 case ExpeditionType.Hunt:
47 hours = 10;
48 break;
49 default:
50 hours = 24;
51 break;
52 }
53 }
54
55 public void Start()
56 {
58 costs.Pay();
59 WidgetPopText.Say("expeditionStart".lang(chara.Name, strType));
60 EClass.Branch.Log("bExpeditionStart", chara, strType);
62 {
63 Msg.Say("bExpeditionStart", chara, strType);
64 }
65 chara.MoveZone("somewhere");
66 }
67
68 public void OnAdvanceHour()
69 {
70 hours--;
71 if (hours <= 0)
72 {
73 End();
74 }
75 }
76
77 public void End()
78 {
80 Chara chara = this.chara;
81 if (chara?.homeZone == null)
82 {
83 Debug.Log("Expedition.End: chara " + uidChara + " no longer exists, dropping");
84 return;
85 }
87 WidgetPopText.Say("expeditionEnd".lang(this.chara.Name, strType));
88 branch.Log("bExpeditionEnd", this.chara, strType);
89 if (this.chara.IsInActiveZone)
90 {
91 Msg.Say("bExpeditionEnd", this.chara, strType);
92 }
93 switch (type)
94 {
95 case ExpeditionType.Search:
96 {
98 {
99 if (!item.isKnown)
100 {
101 item.isKnown = true;
102 WidgetPopText.Say("discoverZone".lang(item.Name), FontColor.Great);
103 }
104 }
105 Zone zone = EClass.world.region.CreateRandomSite(this.chara.homeZone);
106 if (zone != null)
107 {
108 zone.isKnown = true;
109 WidgetPopText.Say("discoverZone".lang(zone.Name), FontColor.Great);
110 }
111 break;
112 }
113 case ExpeditionType.Explore:
114 this.chara.GetWorkSummary().progress = 100;
115 break;
116 }
117 }
118
120 {
121 Expedition expedition = new Expedition();
122 expedition.uidChara = c.uid;
123 expedition.type = type;
124 expedition.SetOwner(c.homeBranch);
125 expedition.OnCreate();
126 return expedition;
127 }
128}
ExpeditionType
FontColor
Definition: FontColor.cs:2
string Name
Definition: Card.cs:2191
int uid
Definition: Card.cs:125
Definition: Chara.cs:10
WorkSummary GetWorkSummary()
Definition: Chara.cs:9759
Zone homeZone
Definition: Chara.cs:271
bool IsInActiveZone
Definition: Chara.cs:885
FactionBranch homeBranch
Definition: Chara.cs:1113
void MoveZone(string alias)
Definition: Chara.cs:3577
Definition: EClass.cs:6
static World world
Definition: EClass.cs:41
static FactionBranch Branch
Definition: EClass.cs:23
Dictionary< int, Expedition > dict
int MinHour
Definition: Expedition.cs:21
void End()
Definition: Expedition.cs:77
int MaxHour
Definition: Expedition.cs:23
int uidChara
Definition: Expedition.cs:10
string strType
Definition: Expedition.cs:25
static Expedition Create(Chara c, ExpeditionType type)
Definition: Expedition.cs:119
void OnCreate()
Definition: Expedition.cs:32
void Start()
Definition: Expedition.cs:55
void OnAdvanceHour()
Definition: Expedition.cs:68
HomeResource.CostList costs
Definition: Expedition.cs:15
int hours
Definition: Expedition.cs:7
void SetOwner(FactionBranch _branch)
Definition: Expedition.cs:27
ExpeditionType type
Definition: Expedition.cs:13
FactionBranch branch
Definition: Expedition.cs:17
Chara chara
Definition: Expedition.cs:19
ExpeditionManager expeditions
string Log(string idLang, string ref1=null, string ref2=null, string ref3=null, string ref4=null)
HomeResourceManager resources
Definition: Msg.cs:5
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:58
Definition: Rand.cs:4
static int Range(int min, int max)
Definition: Rand.cs:49
static Chara Get(int uid)
Definition: RefChara.cs:36
Zone CreateRandomSite(Zone center, int radius=8, string idSource=null, bool updateMesh=true, int lv=0)
Definition: Region.cs:141
List< Zone > ListZonesInRadius(Zone center, int radius=10)
Definition: Region.cs:305
virtual string Name
Definition: Spatial.cs:509
static void Say(string text, FontColor fontColor=FontColor.Default, Sprite sprite=null)
Region region
Definition: World.cs:23
Definition: Zone.cs:12