feat: Introduce new services and refactor existing code for better structure

- Added ISpriteCacheService, IStaticDataService, and ITextService interfaces for improved service management.
- Implemented RunContracts for managing run states and node execution contexts.
- Created EnemyTagStatusRuntime to handle enemy status effects and their application.
- Refactored ShopPriceRuleService to utilize static data service for shop prices.
- Enhanced InventoryTowerEnduranceUtility to manage tower endurance reduction.
- Updated EventFormUseCase to work with new EventOptionExecutionContext.
- Removed unused dictionary loading code from ProcedurePreload.
- Cleaned up various utility classes and ensured consistent naming conventions.
- Updated tests to reflect changes in context and service usage.
This commit is contained in:
2026-05-13 22:18:47 +08:00
parent 9fc0ef2216
commit 7106e0adbe
45 changed files with 590 additions and 426 deletions
@@ -0,0 +1,31 @@
using System;
namespace GeometryTD.Core
{
public static class CoreServiceHub
{
public static IPlayerInventoryManager PlayerInventory { get; private set; }
public static IInventoryGenerationManager InventoryGeneration { get; private set; }
public static IEventFlowManager EventFlow { get; private set; }
public static ISpriteCacheService SpriteCache { get; private set; }
public static IStaticDataService StaticData { get; private set; }
public static ITextService TextService { get; private set; }
public static void Bind(
IPlayerInventoryManager playerInventory,
IInventoryGenerationManager inventoryGeneration,
IEventFlowManager eventFlow,
ISpriteCacheService spriteCache,
IStaticDataService staticData,
ITextService textService)
{
PlayerInventory = playerInventory ?? throw new ArgumentNullException(nameof(playerInventory));
InventoryGeneration = inventoryGeneration ?? throw new
ArgumentNullException(nameof(inventoryGeneration));
EventFlow = eventFlow ?? throw new ArgumentNullException(nameof(eventFlow));
SpriteCache = spriteCache ?? throw new ArgumentNullException(nameof(spriteCache));
StaticData = staticData ?? throw new ArgumentNullException(nameof(staticData));
TextService = textService ?? throw new ArgumentNullException(nameof(textService));
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 95f8a75dcf78e4545b36f1e24b92d82e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
namespace GeometryTD.Core
{
public interface IEventFlowManager
{
void EndEvent();
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c14fccc4cf6d239489afdc5b302c03b9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,17 @@
using System.Collections.Generic;
namespace GeometryTD.Core
{
public interface IInventoryGenerationManager
{
IReadOnlyList<TowerCompItemData> BuildEventRewardComponents(
int count,
RarityType minRarity,
RarityType maxRarity,
int runSeed,
int sequenceIndex,
int eventId,
int optionIndex,
int effectIndex);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ba83daa081633074ab92ff9ad75c9c52
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
namespace GeometryTD.Core
{
public interface IPlayerInventoryManager
{
BackpackInventoryData GetInventorySnapshot();
void ReplaceInventorySnapshot(BackpackInventoryData snapshot);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0ce0e4176795db941a0f7ed57065f73d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,11 @@
using System;
using UnityEngine;
namespace GeometryTD.Core
{
public interface ISpriteCacheService
{
void Get(string key, Action<Sprite> callback);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 675e9ac521922ac46b3b7afe4973a706
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,12 @@
namespace GeometryTD.Core
{
public interface IStaticDataService
{
DRLevel GetLevel(int id);
DRTag GetTag(int id);
DRShopPrice[] GetAllShopPrices();
DRBearingComp[] GetAllBearingComps();
DRBaseComp[] GetAllBaseComps();
DRMuzzleComp[] GetAllMuzzleComps();
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: db37b943863752b41a8a0deef641dca6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
namespace GeometryTD.Core
{
public interface ITextService
{
string Get(string key, params object[] args);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9440fb32740fa50409ce370f9eab4d6d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: