Time Rewizer  v.1.1
Created by: Mark Oostveen
MarkOostveen.TimeRewizer.ScriptableBake Class Reference

Scriptable Object containing info for baked rewinding practices More...

+ Inheritance diagram for MarkOostveen.TimeRewizer.ScriptableBake:
+ Collaboration diagram for MarkOostveen.TimeRewizer.ScriptableBake:

Public Member Functions

float RunTime (string tag)
 Returns runtime of object in seconds More...
 
void SetContents (ObjectSerializer[] input)
 Install Snapshots for rewinding into scriptableobject More...
 
void DeleteType (Type type, string tag="")
 Delete Type from Scriptableobject More...
 
void Clear ()
 clears scriptableobject More...
 
void Preload ()
 Load all assemblies of this bake More...
 
ObjectSerializer [] GetContents (Type type)
 Get Snapshots from scriptable object based on type, in their struct form More...
 
ObjectSerializer [] GetContents (string tag)
 Get Snapshots from scriptable object based on type, in their struct form More...
 
ISnapShot [] GetSnapshots (Type type)
 Get's snapshots of type from this scriptableobject More...
 

Public Attributes

int Count => m_SnapshotSteps.Length
 Count of snapshots serialized in this object More...
 
string [] Assemblies => m_Assemblies.ToArray()
 Returns linked assemblies More...
 

Package Functions

 ScriptableBake ()
 

Detailed Description

Scriptable Object containing info for baked rewinding practices

Constructor & Destructor Documentation

◆ ScriptableBake()

MarkOostveen.TimeRewizer.ScriptableBake.ScriptableBake ( )
package
24  {
25  m_Assemblies = new List<string>();
26  Clear();
27  }

Member Function Documentation

◆ Clear()

void MarkOostveen.TimeRewizer.ScriptableBake.Clear ( )

clears scriptableobject

115  {
116  m_SnapshotSteps = new ObjectSerializer[0];
117  }

◆ DeleteType()

void MarkOostveen.TimeRewizer.ScriptableBake.DeleteType ( Type  type,
string  tag = "" 
)

Delete Type from Scriptableobject

Parameters
type
tag
90  {
91  List<ObjectSerializer> list = ChangeToList;
92 
93  List<ObjectSerializer> toRemove = new List<ObjectSerializer>();
94 
95  for (int i = list.Count - 1; i >= 0; i--)
96  {
97  if (list[i].TypeName + list[i].TagName == type + tag)
98  {
99  toRemove.Add(list[i]);
100  }
101  }
102 
103  for (int i = toRemove.Count - 1; i >= 0; i--)
104  {
105  list.Remove(toRemove[i]);
106  }
107 
108  m_SnapshotSteps = list.ToArray();
109  }
+ Here is the caller graph for this function:

◆ GetContents() [1/2]

ObjectSerializer [] MarkOostveen.TimeRewizer.ScriptableBake.GetContents ( Type  type)

Get Snapshots from scriptable object based on type, in their struct form

Parameters
type
Returns
149  {
150  List<ObjectSerializer> output = new List<ObjectSerializer>();
151 
152  string typename = type.ToString();
153 
154  for (int i = 0; i < m_SnapshotSteps.Length; i++)
155  {
156  if (m_SnapshotSteps[i].TypeName != typename) continue;
157 
158  ObjectSerializer serializerobj = m_SnapshotSteps[i];
159  output.Add(serializerobj);
160  }
161 
162  return output.ToArray();
163  }
+ Here is the caller graph for this function:

◆ GetContents() [2/2]

ObjectSerializer [] MarkOostveen.TimeRewizer.ScriptableBake.GetContents ( string  tag)

Get Snapshots from scriptable object based on type, in their struct form

Parameters
tag
Returns
171  {
172  List<ObjectSerializer> output = new List<ObjectSerializer>();
173 
174  for (int i = 0; i < m_SnapshotSteps.Length; i++)
175  {
176  if (m_SnapshotSteps[i].TagName != tag) continue;
177 
178  ObjectSerializer serializerobj = m_SnapshotSteps[i];
179  output.Add(serializerobj);
180  }
181 
182  return output.ToArray();
183  }

◆ GetSnapshots()

ISnapShot [] MarkOostveen.TimeRewizer.ScriptableBake.GetSnapshots ( Type  type)

Get's snapshots of type from this scriptableobject

Parameters
type
Returns
191  {
192  ObjectSerializer[] compatible = GetContents(type);
193 
194  ISnapShot[] output = new ISnapShot[compatible.Length];
195 
196  string fullname = type.ToString();
197 
198  string[] assemblies = m_Assemblies.ToArray();
199 
200  for (int i = 0; i < compatible.Length; i++)
201  {
202  if (compatible[i].TypeName != fullname) continue;
203 
204  compatible[i].Deserialize(assemblies);
205  output[i] = compatible[i].GetValue as ISnapShot;
206  }
207 
208  return output;
209  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Preload()

void MarkOostveen.TimeRewizer.ScriptableBake.Preload ( )

Load all assemblies of this bake

124  {
125  if (m_Loaded) return;
126 
127  m_Loaded = true;
128  Task load = Task.Factory.StartNew(() =>
129  {
130  string[] assemblies = m_Assemblies.ToArray();
131  ParallelLoopResult loop = Parallel.For(0, m_SnapshotSteps.Length, i =>
132  m_SnapshotSteps[i].Deserialize(assemblies)
133  );
134 
135  while (!loop.IsCompleted)
136  {
137  }
138  });
139 
140  Task.WaitAll(load);
141  }
+ Here is the call graph for this function:

◆ RunTime()

float MarkOostveen.TimeRewizer.ScriptableBake.RunTime ( string  tag)

Returns runtime of object in seconds

Parameters
tag
63  {
64  ObjectSerializer[] compatibletypes = GetContents(tag);
65  return compatibletypes.Length / 60f;
66  }
+ Here is the caller graph for this function:

◆ SetContents()

void MarkOostveen.TimeRewizer.ScriptableBake.SetContents ( ObjectSerializer []  input)

Install Snapshots for rewinding into scriptableobject

Parameters
input
73  {
74  List<ObjectSerializer> list = ChangeToList;
75 
76  for (int i = 0; i < input.Length; i++)
77  {
78  list.Add(input[i]);
79  }
80 
81  m_SnapshotSteps = list.ToArray();
82  }
+ Here is the caller graph for this function:

Member Data Documentation

◆ Assemblies

string [] MarkOostveen.TimeRewizer.ScriptableBake.Assemblies => m_Assemblies.ToArray()

Returns linked assemblies

◆ Count

int MarkOostveen.TimeRewizer.ScriptableBake.Count => m_SnapshotSteps.Length

Count of snapshots serialized in this object