Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
WidgetMinimap.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4using UnityEngine.EventSystems;
5
6public class WidgetMinimap : Widget, IPointerDownHandler, IEventSystemHandler, IPointerUpHandler, IDragHandler, IChangeResolution, IInitializePotentialDragHandler
7{
8 public class Extra
9 {
10 public bool rotate;
11
12 public bool monoColor;
13
14 public bool limitBounds;
15
16 public int alpha;
17
18 public int scale;
19
20 public int width;
21 }
22
23 public static WidgetMinimap Instance;
24
25 public float interval;
26
27 public float intervalPS;
28
29 public float psSize;
30
31 public RectTransform rectAll;
32
33 public RectTransform rectMap;
34
35 public Vector2 baseSize;
36
37 private Point pos = new Point();
38
40
42
44
46
48
49 public ParticleSystem psAlly;
50
51 public ParticleSystem psEnemy;
52
53 public Transform transBound;
54
55 public Vector2 posPs;
56
57 public Transform transCam;
58
59 private Point point = new Point();
60
61 private int count;
62
63 public override Type SetSiblingAfter => typeof(WidgetBottomBar);
64
65 public Extra extra => base.config.extra as Extra;
66
67 public int Size => preview.Size;
68
69 public override bool AlwaysBottom => true;
70
71 public override object CreateExtra()
72 {
73 return new Extra();
74 }
75
76 public override void OnActivate()
77 {
78 Instance = this;
79 preview.limitBounds = extra.limitBounds;
80 preview.monoColor = extra.monoColor;
82 InvokeRepeating("RefreshMarkers", 0f, interval);
85 {
86 id = "mapTool"
87 });
88 }
89
90 public static void UpdateMap(List<Cell> newPoints)
91 {
93 {
94 Instance.preview.UpdateMap(newPoints);
95 }
96 newPoints.Clear();
97 }
98
99 public static void UpdateMap(int x, int z)
100 {
102 {
104 }
105 }
106
107 public static void UpdateMap()
108 {
110 {
112 }
113 }
114
115 public void OnMoveZone()
116 {
118 RefreshStyle();
119 }
120
121 public void Reload()
122 {
124 }
125
126 public void OnPointerDown(PointerEventData e)
127 {
128 if (!EMono.pc.HasNoGoal || EMono.game.activeZone.IsRegion || EMono.ui.IsActive)
129 {
130 SE.BeepSmall();
131 return;
132 }
133 Vector2 size = rectMap.rect.size;
134 RectTransformUtility.ScreenPointToLocalPointInRectangle(rectMap, e.position, e.pressEventCamera, out var localPoint);
135 if (localPoint.x < 0f)
136 {
137 localPoint.x = 0f;
138 }
139 else if (localPoint.x >= size.x)
140 {
141 localPoint.x = size.x;
142 }
143 if (localPoint.y < 0f)
144 {
145 localPoint.y = 0f;
146 }
147 else if (localPoint.y >= size.y)
148 {
149 localPoint.y = size.y;
150 }
151 pos.Set((int)((float)Size * localPoint.x / size.x), (int)((float)Size * localPoint.y / size.y));
152 pos.Clamp();
154 {
155 pos.x += EMono._map.bounds.x - preview.offsetX;
156 pos.z += EMono._map.bounds.z - preview.offsetZ;
157 }
159 {
160 SE.BeepSmall();
161 }
162 else
163 {
165 }
166 }
167
168 public void OnPointerUp(PointerEventData e)
169 {
170 }
171
172 public void OnInitializePotentialDrag(PointerEventData ped)
173 {
174 ped.useDragThreshold = false;
175 }
176
177 public void OnDrag(PointerEventData e)
178 {
179 }
180
181 public override void OnSetContextMenu(UIContextMenu m)
182 {
183 UIContextMenu uIContextMenu = m.AddChild("setting");
184 uIContextMenu.AddSlider("size", (float a) => extra.scale.ToString() ?? "", extra.scale, delegate(float a)
185 {
186 extra.scale = (int)a;
187 RefreshStyle();
188 }, 5f, 20f, isInt: true);
189 uIContextMenu.AddSlider("width", (float a) => 100 + extra.width + "%", extra.width, delegate(float a)
190 {
191 extra.width = (int)a;
192 RefreshStyle();
193 }, -25f, 25f, isInt: true);
194 uIContextMenu.AddSlider("alpha", (float a) => extra.alpha.ToString() ?? "", extra.alpha, delegate(float a)
195 {
196 extra.alpha = (int)a;
197 RefreshStyle();
198 }, 0f, 255f, isInt: true);
199 uIContextMenu.AddToggle("rotation", extra.rotate, delegate(bool a)
200 {
201 extra.rotate = a;
202 RefreshStyle();
203 });
204 uIContextMenu.AddToggle("monoColor", extra.monoColor, delegate(bool a)
205 {
206 extra.monoColor = (preview.monoColor = a);
208 RefreshStyle();
209 });
211 }
212
213 public void RefreshStyle()
214 {
215 rectAll.localEulerAngles = ((extra.rotate && !EMono._zone.IsRegion) ? new Vector3(60f, 0f, -45f) : Vector3.zero);
216 preview.matMap.SetColor("_Color", new Color(1f, 1f, 1f, (float)extra.alpha / 255f));
217 this.Rect().sizeDelta = new Vector2(0.1f * baseSize.x * (float)(10 + extra.scale) * (float)(100 + extra.width) * 0.01f, 0.1f * baseSize.y * (float)(10 + extra.scale));
218 }
219
220 public void OnUpdate()
221 {
224 {
225 point.x -= EMono._map.bounds.x - preview.offsetX;
226 point.z -= EMono._map.bounds.z - preview.offsetZ;
227 }
228 float x = (float)(point.x / Size) - 0.5f;
229 float y = (float)(point.z / Size) - 0.5f;
230 transBound.localScale = new Vector3(Mathf.Min((float)EMono.screen.width / (float)Size * 1.5f, 1f), Mathf.Min((float)EMono.screen.height / (float)Size / 2f, 1f), 1f);
231 transBound.localPosition = new Vector3(x, y, 50f);
232 transCam.localScale = new Vector3(1f / EMono.core.uiScale, 1f / EMono.core.uiScale, 1f);
233 }
234
235 public void RefreshMarkers()
236 {
237 if (!base.gameObject.activeInHierarchy)
238 {
239 return;
240 }
241 psAlly.Clear();
244 {
245 return;
246 }
247 foreach (Chara chara in EMono._map.charas)
248 {
249 if (chara.IsHostile())
250 {
252 }
253 }
254 }
255
256 public void EmitParticle(Card c, ParticleSystem ps, Color col)
257 {
258 int num = c.pos.x;
259 int num2 = c.pos.z;
260 float z = (c.IsPCFactionOrMinion ? 9f : (10f + 0.01f * (float)(c.pos.z * 200 + c.pos.x)));
262 {
263 num -= EMono._map.bounds.x - preview.offsetX;
264 num2 -= EMono._map.bounds.z - preview.offsetZ;
265 }
266 float x = (float)num / (float)Size - 0.5f;
267 float y = (float)num2 / (float)Size - 0.5f;
268 count++;
269 ParticleSystem.EmitParams emitParams = default(ParticleSystem.EmitParams);
270 emitParams.position = new Vector3(x, y, z);
271 emitParams.startSize = psSize;
272 emitParams.startLifetime = intervalPS;
273 emitParams.startColor = col;
274 ParticleSystem.EmitParams emitParams2 = emitParams;
275 psAlly.Emit(emitParams2, 1);
276 }
277}
Definition: Card.cs:11
Point pos
Definition: Card.cs:55
bool isSeen
Definition: Cell.cs:282
bool outOfBounds
Definition: Cell.cs:414
Definition: Chara.cs:10
void SetAIImmediate(AIAct g)
Definition: Chara.cs:8077
bool HasNoGoal
Definition: Chara.cs:821
bool IsHostile()
Definition: Chara.cs:5884
override float uiScale
Definition: Core.cs:95
Definition: EMono.cs:4
static Core core
Definition: EMono.cs:5
static Chara pc
Definition: EMono.cs:13
static Zone _zone
Definition: EMono.cs:19
static BaseGameScreen screen
Definition: EMono.cs:29
static Game game
Definition: EMono.cs:7
static UI ui
Definition: EMono.cs:15
static Map _map
Definition: EMono.cs:17
Zone activeZone
Definition: Game.cs:245
Zone zone
Definition: Map.cs:87
List< Chara > charas
Definition: Map.cs:81
Definition: Point.cs:9
Point Set(int _x, int _z)
Definition: Point.cs:479
int x
Definition: Point.cs:36
int z
Definition: Point.cs:39
Point Clamp(bool useBounds=false)
Definition: Point.cs:972
Cell cell
Definition: Point.cs:51
virtual bool IsRegion
Definition: Spatial.cs:501
void SetItem(Item i)
Definition: UIButton.cs:259
UIContextMenuItem AddToggle(string idLang="", bool isOn=false, UnityAction< bool > action=null)
UIContextMenuItem AddSlider(string text, Func< float, string > textFunc, float value, Action< float > action, float min=0f, float max=1f, bool isInt=false, bool hideOther=true, bool useInput=false)
UIContextMenu AddChild(string idLang, TextAnchor anchor)
void SetMap(Map _map)
bool limitBounds
Definition: UIMapPreview.cs:84
Material matMap
Definition: UIMapPreview.cs:53
void UpdateMap(int x, int z)
void OnInitializePotentialDrag(PointerEventData ped)
override Type SetSiblingAfter
Vector2 baseSize
override void OnActivate()
RectTransform rectAll
void OnDrag(PointerEventData e)
static void UpdateMap(int x, int z)
void EmitParticle(Card c, ParticleSystem ps, Color col)
void OnPointerUp(PointerEventData e)
UIButton buttonMaptool
void RefreshMarkers()
UIMapPreview preview
override void OnSetContextMenu(UIContextMenu m)
override object CreateExtra()
static WidgetMinimap Instance
Transform transBound
void RefreshStyle()
RectTransform rectMap
void OnPointerDown(PointerEventData e)
static void UpdateMap(List< Cell > newPoints)
Transform transCam
ParticleSystem psEnemy
static void UpdateMap()
ParticleSystem psAlly
override bool AlwaysBottom
Definition: Widget.cs:7
void SetBaseContextMenu(UIContextMenu m)
Definition: Widget.cs:608
bool ShowEnemyOnMinimap
Definition: Zone.cs:325
bool IsActiveZone
Definition: Zone.cs:486