- S4-03 | 先固化 Tag 系统设计与首发范围
- S4-04 | 实现组件实例 Tag 的统一生成入口 - S4-05 | 实现组塔后的 Tag 汇总与展示入口
This commit is contained in:
+80
-9
@@ -17,17 +17,20 @@ namespace GeometryTD.CustomComponent
|
||||
|
||||
private readonly List<DROutGameDropPool> _eligibleDropPoolBuffer = new();
|
||||
private readonly Dictionary<RarityType, float> _rarityRollWeightBuffer = new();
|
||||
private readonly Dictionary<TagType, RarityType> _tagMinRarityByTag = new();
|
||||
|
||||
private IDataTable<DROutGameDropPool> _drOutGameDropPool;
|
||||
private IDataTable<DRMuzzleComp> _drMuzzleComp;
|
||||
private IDataTable<DRBearingComp> _drBearingComp;
|
||||
private IDataTable<DRBaseComp> _drBaseComp;
|
||||
private IDataTable<DRTag> _drTag;
|
||||
private long _nextDropItemInstanceId = 1;
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_eligibleDropPoolBuffer.Clear();
|
||||
_rarityRollWeightBuffer.Clear();
|
||||
_tagMinRarityByTag.Clear();
|
||||
_nextDropItemInstanceId = 1;
|
||||
}
|
||||
|
||||
@@ -304,6 +307,35 @@ namespace GeometryTD.CustomComponent
|
||||
return _drOutGameDropPool;
|
||||
}
|
||||
|
||||
private bool EnsureTagMinRarityLookup()
|
||||
{
|
||||
if (_tagMinRarityByTag.Count > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
_drTag ??= GameEntry.DataTable.GetDataTable<DRTag>();
|
||||
if (_drTag == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DRTag[] rows = _drTag.GetAllDataRows();
|
||||
for (int i = 0; i < rows.Length; i++)
|
||||
{
|
||||
DRTag row = rows[i];
|
||||
if (row == null || row.Id <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
TagType tagType = (TagType)row.Id;
|
||||
_tagMinRarityByTag[tagType] = row.MinRarity;
|
||||
}
|
||||
|
||||
return _tagMinRarityByTag.Count > 0;
|
||||
}
|
||||
|
||||
private bool TryBuildDropItem(DROutGameDropPool row, out TowerCompItemData droppedItem)
|
||||
{
|
||||
droppedItem = null;
|
||||
@@ -340,21 +372,34 @@ namespace GeometryTD.CustomComponent
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!EnsureTagMinRarityLookup())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DRMuzzleComp config = _drMuzzleComp.GetDataRow(row.ItemId);
|
||||
if (config == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
long instanceId = _nextDropItemInstanceId++;
|
||||
RarityType rarity = InventoryRarityRuleService.NormalizeComponentRarity(row.Rarity);
|
||||
droppedItem = new MuzzleCompItemData
|
||||
{
|
||||
InstanceId = _nextDropItemInstanceId++,
|
||||
InstanceId = instanceId,
|
||||
ConfigId = config.Id,
|
||||
Name = config.Name,
|
||||
Rarity = InventoryRarityRuleService.NormalizeComponentRarity(row.Rarity),
|
||||
Rarity = rarity,
|
||||
Endurance = 100f,
|
||||
Constraint = config.Constraint,
|
||||
Tags = config.PossibleTag != null ? (TagType[])config.PossibleTag.Clone() : Array.Empty<TagType>(),
|
||||
Tags = InventoryTagRuleService.ResolveComponentTags(
|
||||
config.PossibleTag,
|
||||
rarity,
|
||||
InventoryTagSourceType.Drop,
|
||||
instanceId,
|
||||
config.Id,
|
||||
_tagMinRarityByTag),
|
||||
AttackDamage = config.AttackDamage != null ? (int[])config.AttackDamage.Clone() : Array.Empty<int>(),
|
||||
DamageRandomRate = config.DamageRandomRate,
|
||||
AttackMethodType = config.AttackMethodType
|
||||
@@ -371,21 +416,34 @@ namespace GeometryTD.CustomComponent
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!EnsureTagMinRarityLookup())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DRBearingComp config = _drBearingComp.GetDataRow(row.ItemId);
|
||||
if (config == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
long instanceId = _nextDropItemInstanceId++;
|
||||
RarityType rarity = InventoryRarityRuleService.NormalizeComponentRarity(row.Rarity);
|
||||
droppedItem = new BearingCompItemData
|
||||
{
|
||||
InstanceId = _nextDropItemInstanceId++,
|
||||
InstanceId = instanceId,
|
||||
ConfigId = config.Id,
|
||||
Name = config.Name,
|
||||
Rarity = InventoryRarityRuleService.NormalizeComponentRarity(row.Rarity),
|
||||
Rarity = rarity,
|
||||
Endurance = 100f,
|
||||
Constraint = config.Constraint,
|
||||
Tags = config.PossibleTag != null ? (TagType[])config.PossibleTag.Clone() : Array.Empty<TagType>(),
|
||||
Tags = InventoryTagRuleService.ResolveComponentTags(
|
||||
config.PossibleTag,
|
||||
rarity,
|
||||
InventoryTagSourceType.Drop,
|
||||
instanceId,
|
||||
config.Id,
|
||||
_tagMinRarityByTag),
|
||||
RotateSpeed = config.RotateSpeed != null ? (float[])config.RotateSpeed.Clone() : Array.Empty<float>(),
|
||||
AttackRange = config.AttackRange != null ? (float[])config.AttackRange.Clone() : Array.Empty<float>()
|
||||
};
|
||||
@@ -401,21 +459,34 @@ namespace GeometryTD.CustomComponent
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!EnsureTagMinRarityLookup())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DRBaseComp config = _drBaseComp.GetDataRow(row.ItemId);
|
||||
if (config == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
long instanceId = _nextDropItemInstanceId++;
|
||||
RarityType rarity = InventoryRarityRuleService.NormalizeComponentRarity(row.Rarity);
|
||||
droppedItem = new BaseCompItemData
|
||||
{
|
||||
InstanceId = _nextDropItemInstanceId++,
|
||||
InstanceId = instanceId,
|
||||
ConfigId = config.Id,
|
||||
Name = config.Name,
|
||||
Rarity = InventoryRarityRuleService.NormalizeComponentRarity(row.Rarity),
|
||||
Rarity = rarity,
|
||||
Endurance = 100f,
|
||||
Constraint = config.Constraint,
|
||||
Tags = config.PossibleTag != null ? (TagType[])config.PossibleTag.Clone() : Array.Empty<TagType>(),
|
||||
Tags = InventoryTagRuleService.ResolveComponentTags(
|
||||
config.PossibleTag,
|
||||
rarity,
|
||||
InventoryTagSourceType.Drop,
|
||||
instanceId,
|
||||
config.Id,
|
||||
_tagMinRarityByTag),
|
||||
AttackSpeed = config.AttackSpeed != null ? (float[])config.AttackSpeed.Clone() : Array.Empty<float>(),
|
||||
AttackPropertyType = config.AttackPropertyType
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user