Browse Source

clean up code and add ISequencer interface

tags/Rel2b2
sebas77 6 years ago
parent
commit
55852fbba7
2 changed files with 11 additions and 39 deletions
  1. +1
    -34
      Svelto.ECS/Profiler/EngineInfo.cs
  2. +10
    -5
      Svelto.ECS/Sequencer.cs

+ 1
- 34
Svelto.ECS/Profiler/EngineInfo.cs View File

@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;

//This profiler is based on the Entitas Visual Debugging tool
//https://github.com/sschmid/Entitas-CSharp

@@ -8,28 +5,12 @@ namespace Svelto.ECS.Profiler
{
public sealed class EngineInfo
{
enum UpdateType
{
Update = 0,
LateUpdate = 1,
FixedUpdate = 2,
}

readonly IEngine _engine;
readonly string _engineName;
readonly Type _engineType;

const int NUM_UPDATE_TYPES = 3;
const int NUM_FRAMES_TO_AVERAGE = 10;

//use a queue to averave out the last 30 frames
Queue<double>[] _updateFrameTimes = new Queue<double>[NUM_UPDATE_TYPES];
readonly double[] _accumulatedUpdateDuration = new double[NUM_UPDATE_TYPES];
readonly double[] _lastUpdateDuration = new double[NUM_UPDATE_TYPES];

readonly double[] _minUpdateDuration = new double[NUM_UPDATE_TYPES];
readonly double[] _maxUpdateDuration = new double[NUM_UPDATE_TYPES];

double _accumulatedAddDuration;
double _minAddDuration;
double _maxAddDuration;
@@ -58,13 +39,7 @@ namespace Svelto.ECS.Profiler

int foundNamespace = _engineName.LastIndexOf(".");
_engineName = _engineName.Remove(0, foundNamespace + 1);

_engineType = engine.GetType();

for (int i = 0; i < NUM_UPDATE_TYPES; i++)
{
_updateFrameTimes[i] = new Queue<double>();
}
ResetDurations();
}

@@ -98,14 +73,6 @@ namespace Svelto.ECS.Profiler

public void ResetDurations()
{
for (int i = 0; i < NUM_UPDATE_TYPES; i++)
{
_accumulatedUpdateDuration[i] = 0;
_minUpdateDuration[i] = 0;
_maxUpdateDuration[i] = 0;
_updateFrameTimes[i].Clear();
}

_accumulatedAddDuration = 0;
_minAddDuration = 0;
_maxAddDuration = 0;


+ 10
- 5
Svelto.ECS/Sequencer.cs View File

@@ -22,7 +22,14 @@ namespace Svelto.ECS
void Step(ref T token, int condition);
}

public class Sequencer
public interface ISequencer
{
void Next<T>(IEngine engine, ref T param);

void Next<T>(IEngine engine, ref T param, int condition);
}

public class Sequencer : ISequencer
{
public void SetSequence(Steps steps)
{
@@ -36,8 +43,7 @@ namespace Svelto.ECS

public void Next<T>(IEngine engine, ref T param, int condition)
{
var tos = _steps[engine];
var steps = tos[condition];
var steps = _steps[engine][condition];

if (steps != null)
for (int i = 0; i < steps.Length; i++)
@@ -47,8 +53,7 @@ namespace Svelto.ECS
Steps _steps;
}

//you can inherit from Condition and add yours
public class Condition
public static class Condition
{
public const int always = 0;
}

Loading…
Cancel
Save