S5-01 + S5-02 + S5-03
This commit is contained in:
@@ -132,10 +132,10 @@ namespace GeometryTD.CustomComponent
|
||||
out assembledTower);
|
||||
}
|
||||
|
||||
public int ReduceAllTowerEndurance(float enduranceLoss)
|
||||
public int ReduceTowerEndurance(IReadOnlyList<long> towerInstanceIds, float enduranceLoss)
|
||||
{
|
||||
EnsureInitialized();
|
||||
return _towerRosterService.ReduceAllTowerEndurance(enduranceLoss);
|
||||
return _towerRosterService.ReduceTowerEndurance(towerInstanceIds, enduranceLoss);
|
||||
}
|
||||
|
||||
private void EnsureInitialized()
|
||||
@@ -158,4 +158,3 @@ namespace GeometryTD.CustomComponent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -6,7 +6,7 @@ using UnityEngine;
|
||||
|
||||
namespace GeometryTD.CustomComponent
|
||||
{
|
||||
internal struct PlayerInventoryMergeSummary
|
||||
public struct PlayerInventoryMergeSummary
|
||||
{
|
||||
public int GainedGold;
|
||||
public int GainedMuzzleCount;
|
||||
@@ -19,14 +19,14 @@ namespace GeometryTD.CustomComponent
|
||||
GainedTowerCount > 0;
|
||||
}
|
||||
|
||||
internal sealed class PlayerInventoryState
|
||||
public sealed class PlayerInventoryState
|
||||
{
|
||||
public BackpackInventoryData Inventory = new BackpackInventoryData();
|
||||
public long NextInstanceId = 1;
|
||||
public bool IsInitialized;
|
||||
}
|
||||
|
||||
internal sealed class PlayerInventoryQueryModel
|
||||
public sealed class PlayerInventoryQueryModel
|
||||
{
|
||||
private readonly PlayerInventoryState _state;
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace GeometryTD.CustomComponent
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class PlayerInventoryCommandModel
|
||||
public sealed class PlayerInventoryCommandModel
|
||||
{
|
||||
private readonly PlayerInventoryState _state;
|
||||
|
||||
|
||||
+17
-6
@@ -5,7 +5,7 @@ using UnityEngine;
|
||||
|
||||
namespace GeometryTD.CustomComponent
|
||||
{
|
||||
internal sealed class PlayerInventoryTowerRosterService
|
||||
public sealed class PlayerInventoryTowerRosterService
|
||||
{
|
||||
private readonly PlayerInventoryQueryModel _queryModel;
|
||||
private readonly int _maxParticipantTowerCount;
|
||||
@@ -34,11 +34,15 @@ namespace GeometryTD.CustomComponent
|
||||
_maxParticipantTowerCount);
|
||||
}
|
||||
|
||||
public int ReduceAllTowerEndurance(float enduranceLoss)
|
||||
public int ReduceTowerEndurance(IReadOnlyList<long> towerInstanceIds, float enduranceLoss)
|
||||
{
|
||||
float resolvedLoss = Mathf.Max(0f, enduranceLoss);
|
||||
BackpackInventoryData inventory = _queryModel.Inventory;
|
||||
if (resolvedLoss <= 0f || inventory.Towers == null || inventory.Towers.Count <= 0)
|
||||
if (resolvedLoss <= 0f ||
|
||||
towerInstanceIds == null ||
|
||||
towerInstanceIds.Count <= 0 ||
|
||||
inventory.Towers == null ||
|
||||
inventory.Towers.Count <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -46,12 +50,19 @@ namespace GeometryTD.CustomComponent
|
||||
Dictionary<long, MuzzleCompItemData> muzzleMap = BuildComponentMap(inventory.MuzzleComponents);
|
||||
Dictionary<long, BearingCompItemData> bearingMap = BuildComponentMap(inventory.BearingComponents);
|
||||
Dictionary<long, BaseCompItemData> baseMap = BuildComponentMap(inventory.BaseComponents);
|
||||
HashSet<long> processedTowerIds = new HashSet<long>();
|
||||
|
||||
int affectedCount = 0;
|
||||
for (int i = 0; i < inventory.Towers.Count; i++)
|
||||
for (int i = 0; i < towerInstanceIds.Count; i++)
|
||||
{
|
||||
TowerItemData tower = inventory.Towers[i];
|
||||
if (tower == null)
|
||||
long towerInstanceId = towerInstanceIds[i];
|
||||
if (towerInstanceId <= 0 || !processedTowerIds.Add(towerInstanceId))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!InventoryParticipantUtility.TryGetTowerById(inventory, towerInstanceId, out TowerItemData tower) ||
|
||||
tower == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user