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:
@@ -1,12 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GeometryTD.CustomComponent;
|
||||
using GeometryTD.Core;
|
||||
using GeometryTD.Procedure;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GeometryTD.Core
|
||||
{
|
||||
public sealed class EventOptionExecutionContext
|
||||
{
|
||||
public EventOptionExecutionContext(int runSeed, int sequenceIndex)
|
||||
{
|
||||
RunSeed = runSeed;
|
||||
SequenceIndex = sequenceIndex;
|
||||
}
|
||||
|
||||
public int RunSeed { get; }
|
||||
public int SequenceIndex { get; }
|
||||
}
|
||||
|
||||
public sealed class EventOptionExecutor
|
||||
{
|
||||
public EventOptionAvailability EvaluateOption(EventOption option, BackpackInventoryData inventory)
|
||||
@@ -37,7 +46,7 @@ namespace GeometryTD.Core
|
||||
public EventOptionExecutionResult Execute(
|
||||
EventItem eventItem,
|
||||
int optionIndex,
|
||||
RunNodeExecutionContext context,
|
||||
EventOptionExecutionContext context,
|
||||
BackpackInventoryData workingInventory)
|
||||
{
|
||||
if (eventItem == null || workingInventory == null)
|
||||
@@ -72,7 +81,7 @@ namespace GeometryTD.Core
|
||||
EventEffectBase[] effects,
|
||||
EventItem eventItem,
|
||||
int optionIndex,
|
||||
RunNodeExecutionContext context,
|
||||
EventOptionExecutionContext context,
|
||||
BackpackInventoryData workingInventory,
|
||||
bool isRewardPhase)
|
||||
{
|
||||
@@ -143,7 +152,7 @@ namespace GeometryTD.Core
|
||||
RemoveRandomCompsParam param,
|
||||
int eventId,
|
||||
int optionIndex,
|
||||
RunNodeExecutionContext context,
|
||||
EventOptionExecutionContext context,
|
||||
BackpackInventoryData workingInventory,
|
||||
int effectIndex)
|
||||
{
|
||||
@@ -171,7 +180,7 @@ namespace GeometryTD.Core
|
||||
AddRandomCompsParam param,
|
||||
int eventId,
|
||||
int optionIndex,
|
||||
RunNodeExecutionContext context,
|
||||
EventOptionExecutionContext context,
|
||||
BackpackInventoryData workingInventory,
|
||||
int effectIndex)
|
||||
{
|
||||
@@ -181,12 +190,12 @@ namespace GeometryTD.Core
|
||||
return;
|
||||
}
|
||||
|
||||
if (GameEntry.InventoryGeneration == null)
|
||||
if (CoreServiceHub.InventoryGeneration == null)
|
||||
{
|
||||
throw new InvalidOperationException("Event component generation requires InventoryGenerationComponent.");
|
||||
}
|
||||
|
||||
IReadOnlyList<TowerCompItemData> generatedComponents = GameEntry.InventoryGeneration.BuildEventRewardComponents(
|
||||
IReadOnlyList<TowerCompItemData> generatedComponents = CoreServiceHub.InventoryGeneration.BuildEventRewardComponents(
|
||||
addCount,
|
||||
param.MinRarity,
|
||||
param.MaxRarity,
|
||||
@@ -205,7 +214,7 @@ namespace GeometryTD.Core
|
||||
DamageRandomTowerEnduranceParam param,
|
||||
int eventId,
|
||||
int optionIndex,
|
||||
RunNodeExecutionContext context,
|
||||
EventOptionExecutionContext context,
|
||||
BackpackInventoryData workingInventory,
|
||||
int effectIndex)
|
||||
{
|
||||
@@ -272,7 +281,7 @@ namespace GeometryTD.Core
|
||||
}
|
||||
}
|
||||
|
||||
private static bool RollProbability(int eventId, int optionIndex, RunNodeExecutionContext context, float probability)
|
||||
private static bool RollProbability(int eventId, int optionIndex, EventOptionExecutionContext context, float probability)
|
||||
{
|
||||
float clampedProbability = Mathf.Clamp01(probability);
|
||||
if (clampedProbability >= 1f)
|
||||
@@ -290,7 +299,7 @@ namespace GeometryTD.Core
|
||||
}
|
||||
|
||||
private static System.Random CreateRandom(
|
||||
RunNodeExecutionContext context,
|
||||
EventOptionExecutionContext context,
|
||||
int eventId,
|
||||
int optionIndex,
|
||||
int effectIndex,
|
||||
|
||||
Reference in New Issue
Block a user