This repository has been archived by the owner on Sep 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separated Scene class to multiple classes to avoid mess in one file
- Loading branch information
1 parent
ce36910
commit 2ede682
Showing
5 changed files
with
149 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using craftersmine.EtherEngine.Content; | ||
|
||
namespace craftersmine.EtherEngine.Core | ||
{ | ||
public partial class Scene | ||
{ | ||
internal Dictionary<string, AudioChannel> AudioChannels = new Dictionary<string, AudioChannel>(); | ||
|
||
public bool CreateAudioChannel(string id, AudioClip audioClip) | ||
{ | ||
if (!AudioChannels.ContainsKey(id)) | ||
{ | ||
AudioChannels.Add(id, new AudioChannel(audioClip)); | ||
return true; | ||
} | ||
else return false; | ||
} | ||
|
||
public void RemoveAudioChannel(string id) | ||
{ | ||
if (AudioChannels.ContainsKey(id)) | ||
{ | ||
AudioChannels[id].Stop(); | ||
AudioChannels.Remove(id); | ||
} | ||
} | ||
|
||
public AudioChannel GetAudioChannel(string id) | ||
{ | ||
if (AudioChannels.ContainsKey(id)) | ||
return AudioChannels[id]; | ||
else return null; | ||
} | ||
|
||
public void PlayAudioOnce(AudioClip audio) | ||
{ | ||
new AudioChannel(audio).Play(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace craftersmine.EtherEngine.Core | ||
{ | ||
public partial class Scene | ||
{ | ||
internal List<GameObject> GameObjects = new List<GameObject>(); | ||
|
||
/// <summary> | ||
/// Adds <see cref="GameObject"/> to scene | ||
/// </summary> | ||
/// <param name="gameObject">Addable object</param> | ||
public void AddGameObject(GameObject gameObject) | ||
{ | ||
gameObject.InternalCreate(); | ||
GameObjects.Add(gameObject); | ||
} | ||
|
||
/// <summary> | ||
/// Adds range of <see cref="GameObject"/> to scene | ||
/// </summary> | ||
/// <param name="gameObjects">Addable objects collection</param> | ||
public void AddGameObjects(IEnumerable<GameObject> gameObjects) | ||
{ | ||
foreach (var obj in gameObjects) | ||
{ | ||
AddGameObject(obj); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Removes <see cref="GameObject"/> from scene | ||
/// </summary> | ||
/// <param name="gameObject">Removable object</param> | ||
public void RemoveGameObject(GameObject gameObject) | ||
{ | ||
if (GameObjects.Contains(gameObject)) | ||
{ | ||
GameObjects.Remove(gameObject); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace craftersmine.EtherEngine.Core | ||
{ | ||
public partial class Scene | ||
{ | ||
internal List<UIWidget> UIWidgets = new List<UIWidget>(); | ||
|
||
public void AddUIWidget(UIWidget widget) | ||
{ | ||
UIWidgets.Add(widget); | ||
} | ||
|
||
public void RemoveUIWidget(UIWidget widget) | ||
{ | ||
UIWidgets.Remove(widget); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace craftersmine.EtherEngine.Core | ||
{ | ||
public partial class Scene | ||
{ | ||
/// <summary> | ||
/// Calls when scene is being updated | ||
/// </summary> | ||
public virtual void OnUpdate(float deltaTime) | ||
{ | ||
|
||
} | ||
|
||
/// <summary> | ||
/// Calls when scene is being created | ||
/// </summary> | ||
public virtual void OnStart() | ||
{ | ||
|
||
} | ||
|
||
/// <summary> | ||
/// Calls when scene is being unloaded | ||
/// </summary> | ||
public virtual void OnUnload() | ||
{ } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters