Godot Nature of Code  1.2.0
Nature of Code implemented in Godot Engine
Public Member Functions | Static Public Attributes | List of all members
Examples.SceneLoader Class Reference

Dynamic scene loader. More...

Inherits Node.

Public Member Functions

delegate void ScenesLoaded ()
 Signal sent when all scenes are loaded More...
 
List< string > GetCurrentChapterSampleNames ()
 Get current chapter sample names. More...
 
int GetCurrentChapterSamplesCount ()
 Get current chapter sample count. More...
 
List< string > GetChapterNames ()
 Get chapter names. More...
 
PackedScene GetCurrentSample ()
 Get current sample scene. More...
 
void SetCurrentSample (string name)
 Set current sample from name. More...
 
void SetCurrentChapter (string name)
 Set current chapter from name. More...
 
int GetNextSampleId ()
 Get next sample index. Returns '-1' if next sample does not exist. More...
 
int GetPrevSampleId ()
 Get previous sample index. Returns '-1' if previous sample does not exist. More...
 
int GetNextChapterId ()
 Get next chapter index. Returns '-1' if next chapter does not exist. More...
 
int GetPrevChapterId ()
 Get previous chapter index. Returns '-1' if previous chapter does not exist. More...
 

Static Public Attributes

const int SampleNameMaxLength = 30
 Sample name max length More...
 

Detailed Description

Dynamic scene loader.

Definition at line 10 of file SceneLoader.cs.

Member Function Documentation

◆ GetChapterNames()

List<string> Examples.SceneLoader.GetChapterNames ( )
inline

Get chapter names.

Returns
Chapter names

Definition at line 71 of file SceneLoader.cs.

72  {
73  return chaptersList;
74  }

◆ GetCurrentChapterSampleNames()

List<string> Examples.SceneLoader.GetCurrentChapterSampleNames ( )
inline

Get current chapter sample names.

Returns
Sample names

Definition at line 41 of file SceneLoader.cs.

42  {
43  if (currentChapter != "")
44  {
45  return scenesList[currentChapter];
46  }
47  else
48  {
49  return new List<string>();
50  }
51  }

◆ GetCurrentChapterSamplesCount()

int Examples.SceneLoader.GetCurrentChapterSamplesCount ( )
inline

Get current chapter sample count.

Returns
Sample count

Definition at line 57 of file SceneLoader.cs.

58  {
59  if (currentChapter != "")
60  {
61  return scenesDict[currentChapter].Count;
62  }
63 
64  return -1;
65  }

◆ GetCurrentSample()

PackedScene Examples.SceneLoader.GetCurrentSample ( )
inline

Get current sample scene.

Returns
Sample scene

Definition at line 80 of file SceneLoader.cs.

81  {
82  if (currentChapter != "" && currentScene != "")
83  {
84  return scenesDict[currentChapter][currentScene];
85  }
86 
87  return null;
88  }

◆ GetNextChapterId()

int Examples.SceneLoader.GetNextChapterId ( )
inline

Get next chapter index. Returns '-1' if next chapter does not exist.

Returns
Chapter index

Definition at line 159 of file SceneLoader.cs.

160  {
161  if (currentChapter != "")
162  {
163  int chapPos = chaptersList.IndexOf(currentChapter);
164  if (chapPos == chaptersList.Count - 1)
165  {
166  return 0;
167  }
168  else
169  {
170  return chapPos + 1;
171  }
172  }
173 
174  return -1;
175  }

◆ GetNextSampleId()

int Examples.SceneLoader.GetNextSampleId ( )
inline

Get next sample index. Returns '-1' if next sample does not exist.

Returns
Sample index

Definition at line 113 of file SceneLoader.cs.

114  {
115  if (currentChapter != "" && currentScene != "")
116  {
117  var scenePos = scenesList[currentChapter].IndexOf(currentScene);
118  if (scenePos == scenesList[currentChapter].Count - 1)
119  {
120  return -1;
121  }
122  else
123  {
124  return scenePos + 1;
125  }
126  }
127 
128  return -1;
129  }

◆ GetPrevChapterId()

int Examples.SceneLoader.GetPrevChapterId ( )
inline

Get previous chapter index. Returns '-1' if previous chapter does not exist.

Returns
Chapter index

Definition at line 182 of file SceneLoader.cs.

183  {
184  if (currentChapter != "")
185  {
186  int chapPos = chaptersList.IndexOf(currentChapter);
187  if (chapPos == 0)
188  {
189  return chaptersList.Count - 1;
190  }
191  else
192  {
193  return chapPos - 1;
194  }
195  }
196 
197  return -1;
198  }

◆ GetPrevSampleId()

int Examples.SceneLoader.GetPrevSampleId ( )
inline

Get previous sample index. Returns '-1' if previous sample does not exist.

Returns
Sample index

Definition at line 136 of file SceneLoader.cs.

137  {
138  if (currentChapter != "" && currentScene != "")
139  {
140  var scenePos = scenesList[currentChapter].IndexOf(currentScene);
141  if (scenePos == 0)
142  {
143  return -1;
144  }
145  else
146  {
147  return scenePos - 1;
148  }
149  }
150 
151  return -1;
152  }

◆ ScenesLoaded()

delegate void Examples.SceneLoader.ScenesLoaded ( )

Signal sent when all scenes are loaded

◆ SetCurrentChapter()

void Examples.SceneLoader.SetCurrentChapter ( string  name)
inline

Set current chapter from name.

Parameters
nameChapter name

Definition at line 103 of file SceneLoader.cs.

104  {
105  currentChapter = name;
106  }

◆ SetCurrentSample()

void Examples.SceneLoader.SetCurrentSample ( string  name)
inline

Set current sample from name.

Parameters
nameSample name

Definition at line 94 of file SceneLoader.cs.

95  {
96  currentScene = name;
97  }

Member Data Documentation

◆ SampleNameMaxLength

const int Examples.SceneLoader.SampleNameMaxLength = 30
static

Sample name max length

Definition at line 18 of file SceneLoader.cs.


The documentation for this class was generated from the following file: