Elin Decompiled Documentation EA 23.102 Nightly
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 }
67 if (actors.Count <= 0)
68 {
69 return GetActor("narrator");
70 }
71 return actors.FirstItem();
72 }
73
74 public T GetEvent<T>(string idStep) where T : DramaEvent
75 {
76 foreach (DramaEvent @event in events)
77 {
78 if (@event.step == idStep)
79 {
80 return @event as T;
81 }
82 }
83 return null;
84 }
85
86 public DramaActor AddActor(string id, Person person)
87 {
88 if (actors.ContainsKey(id))
89 {
90 return actors[id];
91 }
92 DramaActor dramaActor = Util.Instantiate(manager.moldActor, manager.actorPos);
93 dramaActor.Init(this, id, person);
94 actors.Add(id, dramaActor);
95 return dramaActor;
96 }
97
98 public void AddStep(string id)
99 {
100 steps.Add(id, events.Count);
101 events.Add(new DramaEvent
102 {
103 sequence = this,
104 step = id
105 });
106 }
107
109 {
110 if (!e.step.IsEmpty())
111 {
112 steps.Add(e.step, events.Count);
113 }
114 e.sequence = this;
115 events.Add(e);
116 return e;
117 }
118
119 public void PlayNext()
120 {
121 Play(currentEventID + 1);
122 }
123
124 public void Play(string id)
125 {
126 if (id == "last")
127 {
128 id = lastlastStep;
129 }
130 if (!id.IsEmpty() && !steps.ContainsKey(id))
131 {
132 Debug.Log(id);
133 }
134 Play((!string.IsNullOrEmpty(id)) ? steps[id] : 0);
135 }
136
137 public void Play(int eventID = 0)
138 {
139 if (isExited)
140 {
141 return;
142 }
143 if (eventID >= events.Count)
144 {
145 if (!isLoop)
146 {
147 Exit();
148 return;
149 }
150 eventID = 0;
151 }
152 currentEventID = eventID;
153 currentEvent = events[eventID];
155 string text = eventID + "/";
156 foreach (KeyValuePair<string, int> step in steps)
157 {
158 if (step.Value == eventID)
159 {
160 text += step.Key;
161 }
162 if (step.Value == eventID && !step.Key.StartsWith("flag"))
163 {
165 lastStep = step.Key;
166 break;
167 }
168 }
169 OnUpdate();
170 }
171
172 public void Exit()
173 {
174 isExited = true;
175 currentEvent = null;
176 manager.SetActive(enable: false);
177 }
178
179 public void OnUpdate()
180 {
181 if (tempEvents.Count > 0)
182 {
183 if (tempEvents[0].Play() && tempEvents.Count > 0)
184 {
185 tempEvents.RemoveAt(0);
186 }
187 }
188 else
189 {
190 if (currentEvent == null)
191 {
192 return;
193 }
195 {
196 string text = currentEvent.idJump;
197 if (text == "*")
198 {
199 if (setup.step.IsEmpty())
200 {
201 PlayNext();
202 return;
203 }
204 text = setup.step;
205 }
206 Play(text);
207 }
208 else if (currentEvent.Play())
209 {
210 PlayNext();
211 }
212 }
213 }
214}
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 SourceManager sources
Definition: EClass.cs:42
Definition: Person.cs:6
SourcePerson persons