-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🛠 MonoBehaviour SimulationController implementation, Bugfixes
- Implemented CoroutineMonoSimulationController - Various bugfixes for Event running and scheduling - Added missing/Improved existing documentation comments - Cleanup
- Loading branch information
1 parent
cebb1a3
commit eedbebf
Showing
14 changed files
with
100 additions
and
35 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.Collections; | ||
using UnityEngine; | ||
using UnityDES.Events; | ||
|
||
namespace UnityDES | ||
{ | ||
/// <summary> | ||
/// The MonoBehaviour proxy class of <see cref="SimulationController"/>. | ||
/// Simulation ticks will also be run in a coroutine. | ||
/// </summary> | ||
public class CoroutineMonoSimulationController : MonoBehaviour, ISimulationController<EventBase<SimulationTime>, SimulationTime> | ||
{ | ||
//==========================================================================dd== | ||
// MonoBehaviour METHODS | ||
//==========================================================================dd== | ||
|
||
public int TicksPerFrame; | ||
|
||
protected virtual void Start() | ||
{ | ||
Controller = new SimulationController(TicksPerFrame); | ||
StartCoroutine("RunAvailableTicksCoroutine"); | ||
} | ||
|
||
//==========================================================================dd== | ||
// ISimulationController METHODS | ||
//==========================================================================dd== | ||
|
||
protected SimulationController Controller { get; set; } | ||
|
||
public SimulationTime SimulationTime => Controller.SimulationTime; | ||
|
||
public int SimulationSpeed { get => Controller.SimulationSpeed; set => Controller.SimulationSpeed = value; } | ||
|
||
public bool Reschedule(EventBase<SimulationTime> @event) => Controller.Reschedule(@event); | ||
|
||
public void RunAvailableTicks(float deltaTime) => Controller.RunAvailableTicks(deltaTime); | ||
|
||
public IEnumerator RunAvailableTicksCoroutine() => Controller.RunAvailableTicksCoroutine(); | ||
|
||
public void Schedule(EventBase<SimulationTime> @event, int tickCount = 1) => Controller.Schedule(@event, tickCount); | ||
|
||
public bool Unschedule(EventBase<SimulationTime> @event) => Controller.Unschedule(@event); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
Scripts/Event.cs.meta → ...CoroutineMonoSimulationController.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,8 +1,16 @@ | ||
| ||
namespace UnityDES.Events | ||
{ | ||
/// <summary> | ||
/// Simple base class for any event implementations with <see cref="SimulationTime"/> as a queue key. | ||
/// </summary> | ||
public abstract class SimulationTimeEvent : EventBase<SimulationTime> | ||
{ | ||
protected SimulationTimeEvent(int ticksPerFrame) : base() | ||
{ | ||
QueueKey = new SimulationTime(ticksPerFrame); | ||
} | ||
|
||
protected override void IncreaseKey(float time) => QueueKey.DoTick(time); | ||
} | ||
} |
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
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
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
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
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
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
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