Skip to content

Commit

Permalink
fix all shit i made
Browse files Browse the repository at this point in the history
  • Loading branch information
JerryImMouse committed Jul 13, 2024
1 parent 16edf45 commit 1d2786b
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 26 deletions.
1 change: 0 additions & 1 deletion Hypercube.Client/Dependencies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public static void Register(DependenciesContainer rootContainer)

// Caching
rootContainer.Register<ICacheManager, CacheManager>();
rootContainer.Register<ICacheManagerInternal, CacheManager>();

// Camera
rootContainer.Register<ICameraManager, CameraManager>();
Expand Down
2 changes: 1 addition & 1 deletion Hypercube.Client/Graphics/Rendering/Renderer.Render.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public sealed partial class Renderer
private void OnLoad()
{
_baseShader = new Shader("/base", _resourceManager);
_baseTexture = _cacheManager.GetResource<TextureResource>("/icon.png").Texture;
_baseTexture = _cacheManager.GetResource<TextureResource>("/Textures/icon.png").Texture;
_baseTexture.Bind(HTexTarget.Texture2D);

_cameraManager.SetMainCamera(_cameraManager.CreateCamera2D(MainWindow.Size));
Expand Down
16 changes: 1 addition & 15 deletions Hypercube.Client/Graphics/Rendering/Renderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public sealed partial class Renderer : IRenderer, IPostInject, IEventSubscriber
[Dependency] private readonly ITiming _timing = default!;
[Dependency] private readonly ICameraManager _cameraManager = default!;
[Dependency] private readonly IResourceManager _resourceManager = default!;
[Dependency] private readonly ICacheManagerInternal _cacheManagerInternal = default!;
[Dependency] private readonly ICacheManager _cacheManager = default!;

private readonly ILogger _logger = LoggingManager.GetLogger("renderer");
Expand Down Expand Up @@ -73,24 +72,11 @@ public sealed partial class Renderer : IRenderer, IPostInject, IEventSubscriber

public void PostInject()
{
_eventBus.Subscribe<TexturesPreloadEvent>(this, OnTexturesPreload);
_eventBus.Subscribe<HandlesPreloadEvent>(this, OnHandlesPreload);
_eventBus.Subscribe<RuntimeInitializationEvent>(this, OnInitialization);
_eventBus.Subscribe<RuntimeStartupEvent>(this, OnStartup);
_eventBus.Subscribe<UpdateFrameEvent>(this, OnFrameUpdate);
_eventBus.Subscribe<RenderFrameEvent>(this, OnFrameRender);
}

private void OnTexturesPreload(ref TexturesPreloadEvent args)
{
args.Textures.Add("/Icons/image.png");
args.Textures.Add("/icon.png");
}

private void OnHandlesPreload(ref HandlesPreloadEvent args)
{
args.Handles.Add("/icon.png");
}

private void OnInitialization(ref RuntimeInitializationEvent args)
{
Expand Down Expand Up @@ -120,7 +106,7 @@ private void OnStartup(ref RuntimeStartupEvent args)

InitOpenGL();

_cacheManagerInternal.PreloadTextures();
_cacheManager.PreloadTextures();

OnLoad();
}
Expand Down
3 changes: 2 additions & 1 deletion Hypercube.Client/Resources/Caching/CacheManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Hypercube.Client.Resources.Caching;

public partial class CacheManager : ICacheManager, ICacheManagerInternal
public partial class CacheManager : ICacheManager
{
[Dependency] private readonly IResourceManager _resourceManager = default!;

Expand All @@ -33,6 +33,7 @@ public CacheManager()
if (typeDict.TryGetValue(path, out var cache))
return (T) cache;


cache = new T();
try
{
Expand Down
4 changes: 2 additions & 2 deletions Hypercube.Example/Example.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void PostInject()

private void Startup(ref RuntimeStartupEvent args)
{
for (var i = 0; i < 300; i++)
for (var i = 0; i < 1000; i++)
{
var x = _random.NextSingle() * 800 - 400;
var y = _random.NextSingle() * 800 - 400;
Expand All @@ -46,7 +46,7 @@ private void CreateEntity(SceneCoordinates coordinates)
var sprite = _entitiesComponentManager.AddComponent<SpriteComponent>(entity);
var example = _entitiesComponentManager.AddComponent<ExampleComponent>(entity);

sprite.TexturePath = new ResourcePath("/icon.png");
sprite.TexturePath = new ResourcePath("/Textures/icon.png");
example.Offset = _random.Next(0, 1000);
}
}
2 changes: 2 additions & 0 deletions Hypercube.Shared/Resources/Caching/ICacheManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ bool TryGetResource<T>(ResourcePath path, [NotNullWhen(true)] out T? resource)

void CacheResource<T>(ResourcePath path, T resource)
where T : BaseResource, new();

void PreloadTextures();
}
6 changes: 0 additions & 6 deletions Hypercube.Shared/Resources/Caching/ICacheManagerInternal.cs

This file was deleted.

0 comments on commit 1d2786b

Please sign in to comment.