Elin Modding Docs Doc
Loading...
Searching...
No Matches
ZoneEventHarvest.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using UnityEngine;
5
6// Token: 0x0200074C RID: 1868
8{
9 // Token: 0x170010AA RID: 4266
10 // (get) Token: 0x06003636 RID: 13878 RVA: 0x001264D2 File Offset: 0x001246D2
11 public QuestHarvest questHarvest
12 {
13 get
14 {
15 return base.quest as QuestHarvest;
16 }
17 }
18
19 // Token: 0x170010AB RID: 4267
20 // (get) Token: 0x06003637 RID: 13879 RVA: 0x001264E0 File Offset: 0x001246E0
21 public override string TextWidgetDate
22 {
23 get
24 {
25 return "eventHarvest".lang((this.TimeLimit - this.minElapsed <= 30) ? "end_soon".lang() : "", Lang._weight(this.questHarvest.weightDelivered, true, 0), Lang._weight(this.questHarvest.destWeight, true, 0), null, null);
26 }
27 }
28
29 // Token: 0x170010AC RID: 4268
30 // (get) Token: 0x06003638 RID: 13880 RVA: 0x0012653F File Offset: 0x0012473F
31 public override int TimeLimit
32 {
33 get
34 {
35 return 180;
36 }
37 }
38
39 // Token: 0x06003639 RID: 13881 RVA: 0x00126548 File Offset: 0x00124748
40 public override void OnVisit()
41 {
42 if (EClass.game.isLoading)
43 {
44 return;
45 }
46 EClass._zone.SetBGM(17, true);
47 Point centerPos = EClass._map.GetCenterPos();
48 PartialMap.Apply("Special/farm_chest.mp", centerPos);
49 GenBounds genBounds = GenBounds.Create(EClass._zone);
50 genBounds.marginPartial = 2;
51 genBounds.FuncCheckEmpty = ((Cell cell) => cell.sourceFloor.id == 42);
52 List<SourceObj.Row> crops = (from o in EClass.sources.objs.rows
53 where o.tag.Contains("harvest")
54 select o).ToList<SourceObj.Row>();
55 Action<PartialMap, GenBounds> <>9__2;
56 for (int i = 0; i < 50; i++)
57 {
58 GenBounds genBounds2 = genBounds;
59 MapPiece.Type type = MapPiece.Type.Farm;
60 float ruin = 0f;
61 string tags = "";
62 Action<PartialMap, GenBounds> onCreate;
63 if ((onCreate = <>9__2) == null)
64 {
65 onCreate = (<>9__2 = delegate(PartialMap p, GenBounds b)
66 {
67 List<Point> list = b.ListEmptyPoint();
68 SourceObj.Row row = crops.RandomItemWeighted((SourceObj.Row o) => (float)o.chance);
69 int num = 1 + EClass.rnd(5 + this.quest.difficulty * 2);
70 foreach (Point point in list)
71 {
72 if (point.sourceFloor.id == 4 && EClass.rnd(4) != 0)
73 {
74 point.SetObj(row.id, 1, 0);
75 int num2 = point.growth.HarvestStage - EClass.rnd(4);
76 point.growth.SetStage(num2, false);
77 if (num2 == point.growth.HarvestStage)
78 {
79 EClass._map.AddPlant(point, null).size = Mathf.Clamp(num + EClass.rnd(2) - EClass.rnd(2), 0, 9) + 1;
80 }
81 point.cell.isClearSnow = true;
82 }
83 }
84 });
85 }
86 genBounds2.TryAddMapPiece(type, ruin, tags, onCreate);
87 }
88 foreach (Thing thing in EClass._map.things)
89 {
90 thing.isNPCProperty = true;
91 }
92 for (int j = 0; j < 12; j++)
93 {
94 EClass._zone.SpawnMob(null, null);
95 }
96 for (int k = 0; k < 30; k++)
97 {
98 EClass._zone.SpawnMob(null, SpawnSetting.HomeWild(1));
99 }
100 }
101
102 // Token: 0x0600363A RID: 13882 RVA: 0x001266D4 File Offset: 0x001248D4
103 public override ZoneInstance.Status OnReachTimeLimit()
104 {
105 Msg.Say("harvest_end", Lang._weight(this.questHarvest.weightDelivered, true, 0), null, null, null);
106 if (this.questHarvest.weightDelivered < this.questHarvest.destWeight)
107 {
108 return ZoneInstance.Status.Fail;
109 }
110 return ZoneInstance.Status.Success;
111 }
112
113 // Token: 0x0600363B RID: 13883 RVA: 0x00126714 File Offset: 0x00124914
114 public override void OnLeaveZone()
115 {
116 if (EClass._zone.instance.status == ZoneInstance.Status.Running)
117 {
118 EClass._zone.instance.status = this.OnReachTimeLimit();
119 }
120 List<Thing> list = new List<Thing>();
121 Action<Thing> <>9__0;
122 foreach (Chara chara in EClass.pc.party.members)
123 {
124 ThingContainer things = chara.things;
125 Action<Thing> action;
126 if ((action = <>9__0) == null)
127 {
128 action = (<>9__0 = delegate(Thing t)
129 {
130 if (t.GetBool(115) && EClass.rnd(2) != 0)
131 {
132 list.Add(t);
133 }
134 });
135 }
136 things.Foreach(action, true);
137 }
138 if (list.Count > 0)
139 {
140 Msg.Say("harvest_confiscate", list.Count.ToString() ?? "", null, null, null);
141 foreach (Thing thing in list)
142 {
143 thing.Destroy();
144 }
145 EClass.player.ModKarma(-1);
146 }
147 }
148}
Definition Cell.cs:10
Definition Chara.cs:12
Definition Msg.cs:7
Definition Point.cs:11
Definition Thing.cs:10