perf: DelegateExtensions.InvokeSafe marked obsolete for memory allocation reasons, soon to be removed

This commit is contained in:
2025-05-29 21:48:08 +03:00
parent 1b0f25e854
commit bf8fbebae3
35 changed files with 116 additions and 115 deletions

View File

@@ -37,7 +37,7 @@ public class Universe : BaseEntity, IUniverse
float previousTimeScale = _timeScale;
_timeScale = value;
OnTimeScaleChanged?.InvokeSafe(this, previousTimeScale);
OnTimeScaleChanged?.Invoke(this, previousTimeScale);
}
}
@@ -60,7 +60,7 @@ public class Universe : BaseEntity, IUniverse
if (!universeObject.EnterUniverse(this))
throw new Exception($"{universeObject.Name} can't enter the universe");
OnUniverseObjectRegistered?.InvokeSafe(this, universeObject);
OnUniverseObjectRegistered?.Invoke(this, universeObject);
}
public T InstantiateUniverseObject<T>(params object?[]? args) where T : class, IUniverseObject
@@ -95,7 +95,7 @@ public class Universe : BaseEntity, IUniverse
if (!universeObject.Finalize())
throw new Exception($"{universeObject.Name} can't be finalized");
OnUniverseObjectUnRegistered?.InvokeSafe(this, universeObject);
OnUniverseObjectUnRegistered?.Invoke(this, universeObject);
}
protected override void InitializeInternal()
@@ -118,18 +118,18 @@ public class Universe : BaseEntity, IUniverse
UnscaledTime = engineTime;
Time = new(TimeSpan.FromTicks((long)(Time.TimeSinceStart.Ticks + engineTime.DeltaSpan.Ticks * TimeScale)), TimeSpan.FromTicks((long)(engineTime.DeltaSpan.Ticks * TimeScale)));
OnPreUpdate?.InvokeSafe(this, Time);
OnUpdate?.InvokeSafe(this, Time);
OnPostUpdate?.InvokeSafe(this, Time);
OnPreUpdate?.Invoke(this, Time);
OnUpdate?.Invoke(this, Time);
OnPostUpdate?.Invoke(this, Time);
}
public void Draw()
{
Debug.Assert.AssertInitialized(this);
OnPreDraw?.InvokeSafe(this);
OnDraw?.InvokeSafe(this);
OnPostDraw?.InvokeSafe(this);
OnPreDraw?.Invoke(this);
OnDraw?.Invoke(this);
OnPostDraw?.Invoke(this);
}
private void OnUniverseObjectFinalize(IInitializable initializable)