Elin Decompiled Documentation EA 23.188 Stable Patch 2
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.ContainsKey(id))
60 {
61 return actors[id];
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 (actors.Count <= 0)
76 {
77 return GetActor("narrator");
78 }
79 return actors.FirstItem();
80 }
81
82 public T GetEvent<T>(string idStep) where T : DramaEvent
83 {
84 foreach (DramaEvent @event in events)
85 {
86 if (@event.step == idStep)
87 {
88 return @event as T;
89 }
90 }
91 return null;
92 }
93
94 public DramaActor AddActor(string id, Person person)
95 {
96 if (actors.ContainsKey(id))
97 {
98 return actors[id];
99 }
100 DramaActor dramaActor = Util.Instantiate(manager.moldActor, manager.actorPos);
101 dramaActor.Init(this, id, person);
102 actors.Add(id, dramaActor);
103 return dramaActor;
104 }
105
106 public void AddStep(string id)
107 {
108 steps.Add(id, events.Count);
109 events.Add(new DramaEvent
110 {
111 sequence = this,
112 step = id
113 });
114 }
115
117 {
118 if (!e.step.IsEmpty())
119 {
120 steps.Add(e.step, events.Count);
121 }
122 e.sequence = this;
123 events.Add(e);
124 return e;
125 }
126
127 public void PlayNext()
128 {
129 Play(currentEventID + 1);
130 }
131
132 public void Play(string id)
133 {
134 if (id == "last")
135 {
136 id = lastlastStep;
137 }
138 if (!id.IsEmpty() && !steps.ContainsKey(id))
139 {
140 Debug.Log(id);
141 }
142 Play((!string.IsNullOrEmpty(id)) ? steps[id] : 0);
143 }
144
145 public void Play(int eventID = 0)
146 {
147 if (isExited)
148 {
149 return;
150 }
151 if (eventID >= events.Count)
152 {
153 if (!isLoop)
154 {
155 Exit();
156 return;
157 }
158 eventID = 0;
159 }
160 currentEventID = eventID;
161 currentEvent = events[eventID];
163 string text = eventID + "/";
164 foreach (KeyValuePair<string, int> step in steps)
165 {
166 if (step.Value == eventID)
167 {
168 text += step.Key;
169 }
170 if (step.Value == eventID && !step.Key.StartsWith("flag"))
171 {
173 lastStep = step.Key;
174 break;
175 }
176 }
177 OnUpdate();
178 }
179
180 public void Exit()
181 {
182 isExited = true;
183 currentEvent = null;
184 manager.SetActive(enable: false);
185 }
186
187 public void OnUpdate()
188 {
189 if (tempEvents.Count > 0)
190 {
191 if (tempEvents[0].Play() && tempEvents.Count > 0)
192 {
193 tempEvents.RemoveAt(0);
194 }
195 }
196 else
197 {
198 if (currentEvent == null)
199 {
200 return;
201 }
203 {
204 string text = currentEvent.idJump;
205 if (text == "*")
206 {
207 if (setup.step.IsEmpty())
208 {
209 PlayNext();
210 return;
211 }
212 text = setup.step;
213 }
214 Play(text);
215 }
216 else if (currentEvent.Play())
217 {
218 PlayNext();
219 }
220 }
221 }
222}
Chara Find(string id)
Definition: CardManager.cs:20
GlobalCharaList globalCharas
Definition: CardManager.cs:46
Definition: Chara.cs:10
bool IsGameStarted
Definition: Core.cs:84
void Init(DramaSequence _sequence, string _id, Person _owner)
Definition: DramaActor.cs:19
string idJump
Definition: DramaEvent.cs:5
virtual void Reset()
Definition: DramaEvent.cs:28
virtual bool Play()
Definition: DramaEvent.cs:23
string step
Definition: DramaEvent.cs:9
DialogDrama dialog
Definition: DramaManager.cs:31
Transform actorPos
Definition: DramaManager.cs:21
DramaActor moldActor
Definition: DramaManager.cs:25
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:5
static Game game
Definition: EClass.cs:8
static Core core
Definition: EClass.cs:6
static Map _map
Definition: EClass.cs:18
static SourceManager sources
Definition: EClass.cs:42
CardManager cards
Definition: Game.cs:155
Chara FindChara(string id)
Definition: Map.cs:2568
Definition: Person.cs:6
SourcePerson persons