mirror of
https://github.com/0x7c13/Pal3.Unity.git
synced 2026-11-26 17:38:10 +08:00
* Optimize DDS texture creation and static POL meshes Separate file decoding from Unity upload through format-neutral texture data and explicit world, sprite and skybox policies. Validate DDS layouts, preserve alpha coverage and use native BC uploads with software RGBA fallback. Compact referenced POL vertices and batch nearby static opaque groups sharing materials. Keep water and dynamic geometry separate, with source ranges retained only in the Editor. Add DDS layout and POL index regression tests. Validation: PAL3 and PAL3A each passed 24 Editor tests, eight combined Game and ResourceViewer style regressions, 936 paired skybox comparisons, and both macOS Player builds on Metal. Editor provenance and Core tests are excluded from Players. * Add core protocol regression tests and copyright checks Cover SCE command contracts, binary readers, resource layouts and full local CPK decompression for PAL3 and PAL3A. Fix CVD time rebasing, binary read bounds and short reads, and CPK/NAV validation. Standardize first-party copyright headers, preserve correct creation years, and update console source generation. Validate both variants in Unity and verify all live CPK entries. * Implement PAL3A command handlers and isolate script execution Correct PAL3A parameter signatures and add handlers for fortune selection, skybox sequences, actor facing and attacks, team and progression state, camera constraints, and battle preparation flags. Give script instances separate locals, advance grouped waits concurrently, and pause PAL3A parents only for their directly decoded child calls. Cancel stale interactions and save replay on reset, preserve finite action semantics, and restore camera orientation after releasing horizontal constraints. Persist supported state in v2 saves and add protocol, runtime, and progression regressions. Full combat gameplay remains outside this change. Validation: PAL3 274/274 and PAL3A 291/291 EditMode tests; 18 PAL3 and 22 PAL3A runtime checks. All 77,889 PAL3A instruction boundaries match EXE signatures. * Run CI only for pull requests and upgrade build actions
102 lines
3.3 KiB
C#
102 lines
3.3 KiB
C#
// ------------------------------------------------------------------------
|
|
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
|
// See LICENSE file in the project root for license information.
|
|
// ------------------------------------------------------------------------
|
|
|
|
namespace Engine.Services
|
|
{
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using Logging;
|
|
using Utilities;
|
|
|
|
/// <summary>
|
|
/// ServiceLocator singleton.
|
|
/// </summary>
|
|
public sealed class ServiceLocator : Singleton<ServiceLocator>
|
|
{
|
|
private ServiceLocator() { } // Hide constructor, use Instance instead.
|
|
|
|
/// <summary>
|
|
/// Currently registered services.
|
|
/// </summary>
|
|
private readonly Dictionary<Type, object> _services = new ();
|
|
|
|
/// <summary>
|
|
/// Gets the service instance of the given type.
|
|
/// </summary>
|
|
/// <typeparam name="T">The type of the service to lookup</typeparam>
|
|
/// <returns>The service instance</returns>
|
|
/// <exception cref="InvalidOperationException">Thrown if the service is not registered.</exception>
|
|
public T Get<T>()
|
|
{
|
|
if (!_services.ContainsKey(typeof(T)))
|
|
{
|
|
string error = $"{typeof(T)} is not registered with {GetType().Name}";
|
|
EngineLogger.LogError(error);
|
|
throw new InvalidOperationException(error);
|
|
}
|
|
|
|
return (T)_services[typeof(T)];
|
|
}
|
|
|
|
/// <summary>
|
|
/// Registers the service with the current service locator.
|
|
/// </summary>
|
|
/// <typeparam name="T">Service typ.</typeparam>
|
|
/// <param name="service">Service instance</param>
|
|
/// <exception cref="ArgumentNullException">Thrown if the service is null.</exception>
|
|
public void Register<T>(T service)
|
|
{
|
|
if (service == null) throw new ArgumentNullException(nameof(service));
|
|
|
|
if (_services.ContainsKey(typeof(T)))
|
|
{
|
|
EngineLogger.LogWarning($"[{typeof(T)}] is already registered");
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
EngineLogger.Log($"Service type [{typeof(T)}] registered");
|
|
}
|
|
|
|
_services.Add(typeof(T), service);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Unregisters the service from the current service locator.
|
|
/// </summary>
|
|
/// <typeparam name="T">Service type</typeparam>
|
|
public void Unregister<T>()
|
|
{
|
|
if (!_services.ContainsKey(typeof(T)))
|
|
{
|
|
EngineLogger.LogWarning($"Failed to unregister service since [{typeof(T)}] is not registered yet");
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
EngineLogger.Log($"Service type [{typeof(T)}] unregistered");
|
|
}
|
|
|
|
_services.Remove(typeof(T));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get all registered services.
|
|
/// </summary>
|
|
public IEnumerable<object> GetAllRegisteredServices()
|
|
{
|
|
return _services.Values;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Unregisters all services.
|
|
/// </summary>
|
|
public void UnregisterAll()
|
|
{
|
|
EngineLogger.Log("All services unregistered");
|
|
_services.Clear();
|
|
}
|
|
}
|
|
} |