Skip to content

Commit 3f1de41

Browse files
[Entities] Fix missing EntityCallback PersistentCache;
[Core] Minor code cleanup;
1 parent 33ffb9c commit 3f1de41

File tree

19 files changed

+85
-48
lines changed

19 files changed

+85
-48
lines changed

Engine/Core/Entities/EntityCallback.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,13 @@ internal void UpdateCache()
128128

129129
continue;
130130
}
131+
132+
persistentCache.Add(new()
133+
{
134+
entity = entity,
135+
methodInfo = method,
136+
type = type,
137+
});
131138
}
132139
catch (Exception e)
133140
{

Engine/Core/Entities/EntityID.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace Staple;
1+
using System;
2+
3+
namespace Staple;
24

35
/// <summary>
46
/// Represents an entity ID
@@ -43,7 +45,7 @@ public override readonly bool Equals(object obj)
4345

4446
public override readonly int GetHashCode()
4547
{
46-
return ID.GetHashCode() * 17 + generation.GetHashCode();
48+
return HashCode.Combine(ID, generation);
4749
}
4850

4951
public override readonly string ToString()

Engine/Core/Jobs/JobHandle.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static void CompleteAll(IReadOnlyList<JobHandle> jobs)
4747
Schedulers.JobHandle.CompleteAll(allHandles.AsSpan());
4848
}
4949

50-
public override readonly bool Equals(object? obj)
50+
public override readonly bool Equals(object obj)
5151
{
5252
return obj is JobHandle handle && Equals(handle);
5353
}

Engine/Core/Math/Color.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public Color(string value)
9393

9494
public override readonly int GetHashCode()
9595
{
96-
return r.GetHashCode() ^ g.GetHashCode() ^ b.GetHashCode() ^ a.GetHashCode();
96+
return HashCode.Combine(r, g, b, a);
9797
}
9898

9999
public override readonly bool Equals(object obj)

Engine/Core/Math/Color32.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public Color32(uint value)
104104

105105
public override readonly int GetHashCode()
106106
{
107-
return r.GetHashCode() ^ g.GetHashCode() ^ b.GetHashCode() ^ a.GetHashCode();
107+
return HashCode.Combine(r, g, b, a);
108108
}
109109

110110
public override readonly bool Equals(object obj)

Engine/Core/Math/Matrix3x3.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Diagnostics.CodeAnalysis;
1+
using System;
2+
using System.Diagnostics.CodeAnalysis;
23

34
namespace Staple;
45

@@ -25,9 +26,9 @@ public static Matrix3x3 Identity
2526

2627
public override readonly int GetHashCode()
2728
{
28-
return M11.GetHashCode() ^ M12.GetHashCode() ^ M13.GetHashCode() ^
29-
M21.GetHashCode() ^ M22.GetHashCode() ^ M23.GetHashCode() ^
30-
M31.GetHashCode() ^ M32.GetHashCode() ^ M33.GetHashCode();
29+
return HashCode.Combine(HashCode.Combine(M11, M12, M13),
30+
HashCode.Combine(M21, M22, M23),
31+
HashCode.Combine(M31, M32, M33));
3132
}
3233

3334
public static bool operator==(Matrix3x3 lhs, Matrix3x3 rhs)

Engine/Core/Math/Vector2Int.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public Vector2Int(int X, int Y)
5656

5757
public override readonly int GetHashCode()
5858
{
59-
return X.GetHashCode() ^ Y.GetHashCode();
59+
return HashCode.Combine(X, Y);
6060
}
6161

6262
public override readonly bool Equals(object obj)

Engine/Core/Performance/PerformanceProfiler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Staple;
66

7-
public struct PerformanceProfiler(PerformanceProfilerType type) : IDisposable
7+
public readonly struct PerformanceProfiler(PerformanceProfilerType type) : IDisposable
88
{
99
private readonly PerformanceProfilerType type = type;
1010
private readonly DateTime startTime = DateTime.UtcNow;

Engine/Core/Player/Android/StapleActivity.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private static void LogWarning(string message)
145145
{ Keycode.AltRight, KeyCode.RightAlt },
146146
};
147147

148-
private SurfaceView? surfaceView;
148+
private SurfaceView surfaceView;
149149
private DateTime lastTime;
150150
private float fixedTimer = 0.0f;
151151

@@ -177,7 +177,7 @@ public void DoFrame(long frameTimeNanos)
177177

178178
class TouchCallback : Java.Lang.Object, View.IOnTouchListener
179179
{
180-
public bool OnTouch(View? v, MotionEvent? e)
180+
public bool OnTouch(View v, MotionEvent e)
181181
{
182182
for (var i = 0; i < e.PointerCount; i++)
183183
{
@@ -207,7 +207,7 @@ public bool OnTouch(View? v, MotionEvent? e)
207207

208208
class KeyCallback : Java.Lang.Object, View.IOnKeyListener
209209
{
210-
public bool OnKey(View? v, [GeneratedEnum] Keycode keyCode, KeyEvent? e)
210+
public bool OnKey(View v, [GeneratedEnum] Keycode keyCode, KeyEvent e)
211211
{
212212
AppEventModifierKeys Modifiers()
213213
{
@@ -293,9 +293,9 @@ AppEventModifierKeys Modifiers()
293293
}
294294
}
295295

296-
private FrameCallback? frameCallback;
297-
private TouchCallback? touchCallback;
298-
private KeyCallback? keyCallback;
296+
private FrameCallback frameCallback;
297+
private TouchCallback touchCallback;
298+
private KeyCallback keyCallback;
299299

300300
private void InitIfNeeded()
301301
{
@@ -602,7 +602,7 @@ public override void OnWindowFocusChanged(bool hasFocus)
602602
}
603603
}
604604

605-
protected override void OnCreate(Bundle? savedInstanceState)
605+
protected override void OnCreate(Bundle savedInstanceState)
606606
{
607607
base.OnCreate(savedInstanceState);
608608

@@ -690,8 +690,11 @@ protected override void OnCreate(Bundle? savedInstanceState)
690690
throw new Exception("Failed to deserialize app settings");
691691
}
692692

693-
LayerMask.AllLayers = AppSettings.Current.layers;
694-
LayerMask.AllSortingLayers = AppSettings.Current.sortingLayers;
693+
LayerMask.AllLayers.Clear();
694+
LayerMask.AllSortingLayers.Clear();
695+
696+
LayerMask.AllLayers.AddRange(AppSettings.Current.layers);
697+
LayerMask.AllSortingLayers.AddRange(AppSettings.Current.sortingLayers);
695698
}
696699
catch (Exception e)
697700
{

Engine/Core/Player/PlayerSettings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public static PlayerSettings Load(AppSettings appSettings)
4747
}
4848
catch (Exception e)
4949
{
50+
Log.Error($"[PlayerSettings] Failed to load the player settings. Returning default settings. {e}");
51+
5052
return new PlayerSettings()
5153
{
5254
windowMode = appSettings.defaultWindowMode,

0 commit comments

Comments
 (0)