Elin Decompiled Documentation EA 23.320 Nyaightly Patch 1
Loading...
Searching...
No Matches
DramaSequence.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using UnityEngine;
3
4public class DramaSequence : EClass
5{
6 public enum Template
7 {
9 }
10
11 public string id;
12
14
15 public Dictionary<string, int> steps = new Dictionary<string, int>();
16
17 public Dictionary<string, DramaActor> actors = new Dictionary<string, DramaActor>();
18
19 public List<DramaEvent> events = new List<DramaEvent>();
20
21 public bool isLoop;
22
23 public bool canCancel = true;
24
25 public bool isExited;
26
27 public bool fullPortrait;
28
30
31 public List<DramaEvent> tempEvents = new List<DramaEvent>();
32
34
35 public string message = "";
36
37 public string skipJump;
38
39 public string lastStep;
40
41 public string lastlastStep;
42
44
45 private int currentEventID;
46
48
49 public void Clear()
50 {
51 steps.Clear();
52 actors.Clear();
53 events.Clear();
54 tempEvents.Clear();
55 }
56
57 public DramaActor GetActor(string id)
58 {
59 if (actors.TryGetValue(id, out var value))
60 {
61 return value;
62 }
63 if (EClass.sources.persons.map.ContainsKey(id))
64 {
65 return AddActor(id, new Person(id));
66 }
68 {
70 if (chara != null)
71 {
72 return AddActor(id, new Person(chara));
73 }
74 }
75 if (EClass.sources.charas.map.TryGetValue(id, out var value2))
76 {
77 Person person = new Person(id)
78 {
79 name = value2.GetName()
80 };
81 if (Portrait.allIds.Contains("UN_" + id + ".png"))
82 {
83 person.idPortrait = "UN_" + id + ".png";
84 }
85 else
86 {
87 person.SetChara(CharaGen.Create(value2.id));
88 }
89 return AddActor(id, person);
90 }
91 if (actors.Count <= 0)
92 {
93 return GetActor("narrator");
94 }
95 return actors.FirstItem();
96 }
97
98 public T GetEvent<T>(string idStep) where T : DramaEvent
99 {
100 foreach (DramaEvent @event in events)
101 {
102 if (@event.step == idStep)
103 {
104 return @event as T;
105 }
106 }
107 return null;
108 }
109
110 public DramaActor AddActor(string id, Person person)
111 {
112 if (actors.TryGetValue(id, out var value))
113 {
114 return value;
115 }
116 value = Util.Instantiate(manager.moldActor, manager.actorPos);
117 value.Init(this, id, person);
118 actors.Add(id, value);
119 return value;
120 }
121
122 public void AddStep(string id)
123 {
124 steps.Add(id, events.Count);
125 events.Add(new DramaEvent
126 {
127 sequence = this,
128 step = id
129 });
130 }
131
133 {
134 if (!e.step.IsEmpty())
135 {
136 steps.Add(e.step, events.Count);
137 }
138 e.sequence = this;
139 events.Add(e);
140 return e;
141 }
142
143 public void PlayNext()
144 {
145 Play(currentEventID + 1);
146 }
147
148 public void Play(string id)
149 {
150 if (id == "last")
151 {
152 id = lastlastStep;
153 }
154 if (!id.IsEmpty() && !steps.ContainsKey(id))
155 {
156 Debug.Log(id);
157 }
158 Play((!string.IsNullOrEmpty(id)) ? steps[id] : 0);
159 }
160
161 public void Play(int eventID = 0)
162 {
163 if (isExited)
164 {
165 return;
166 }
167 if (eventID >= events.Count)
168 {
169 if (!isLoop)
170 {
171 Exit();
172 return;
173 }
174 eventID = 0;
175 }
176 currentEventID = eventID;
177 currentEvent = events[eventID];
179 string text = eventID + "/";
180 foreach (KeyValuePair<string, int> step in steps)
181 {
182 if (step.Value == eventID)
183 {
184 text += step.Key;
185 }
186 if (step.Value == eventID && !step.Key.StartsWith("flag"))
187 {
189 lastStep = step.Key;
190 break;
191 }
192 }
193 OnUpdate();
194 }
195
196 public void Exit()
197 {
198 isExited = true;
199 currentEvent = null;
200 manager.SetActive(enable: false);
201 }
202
203 public void OnUpdate()
204 {
205 if (tempEvents.Count > 0)
206 {
207 if (tempEvents[0].Play() && tempEvents.Count > 0)
208 {
209 tempEvents.RemoveAt(0);
210 }
211 }
212 else
213 {
214 if (currentEvent == null)
215 {
216 return;
217 }
219 {
220 string text = currentEvent.idJump;
221 if (text == "*")
222 {
223 if (setup.step.IsEmpty())
224 {
225 PlayNext();
226 return;
227 }
228 text = setup.step;
229 }
230 Play(text);
231 }
232 else if (!currentEvent.CanPlay() || currentEvent.Play())
233 {
234 PlayNext();
235 }
236 }
237 }
238}
Chara Find(string id)
Definition: CardManager.cs:20
GlobalCharaList globalCharas
Definition: CardManager.cs:46
static Chara Create(string id, int lv=-1)
Definition: CharaGen.cs:17
Definition: Chara.cs:10
bool IsGameStarted
Definition: Core.cs:87
string idJump
Definition: DramaEvent.cs:7
virtual void Reset()
Definition: DramaEvent.cs:32
virtual bool Play()
Definition: DramaEvent.cs:27
string step
Definition: DramaEvent.cs:11
virtual bool CanPlay()
Definition: DramaEvent.cs:37
DialogDrama dialog
Definition: DramaManager.cs:32
Transform actorPos
Definition: DramaManager.cs:22
DramaActor moldActor
Definition: DramaManager.cs:26
DramaSetup setup
Dictionary< string, DramaActor > actors
List< DramaEvent > events
T GetEvent< T >(string idStep)
string lastlastStep
DramaActor AddActor(string id, Person person)
DramaEventTalk firstTalk
DramaActor GetActor(string id)
DramaEvent AddEvent(DramaEvent e)
DramaEvent currentEvent
void Play(string id)
void AddStep(string id)
DramaManager manager
DialogDrama dialog
List< DramaEvent > tempEvents
Dictionary< string, int > steps
void Play(int eventID=0)
string step
Definition: DramaSetup.cs:7
Definition: EClass.cs:6
static Game game
Definition: EClass.cs:9
static Core core
Definition: EClass.cs:7
static Map _map
Definition: EClass.cs:19
static SourceManager sources
Definition: EClass.cs:43
CardManager cards
Definition: Game.cs:156
Chara FindChara(string id)
Definition: Map.cs:2646
Definition: Person.cs:6
void SetChara(Chara c)
Definition: Person.cs:88
static HashSet< string > allIds
Definition: Portrait.cs:20
SourcePerson persons
SourceChara charas