InventoryGenerationComponent + TagRegistryComponent 收口
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using GameFramework.DataTable;
|
||||
using GeometryTD.DataTable;
|
||||
using GeometryTD.Definition;
|
||||
|
||||
namespace GeometryTD.Factory
|
||||
{
|
||||
public sealed class OutGameDropItemBuilder
|
||||
{
|
||||
private readonly IDataTable<DRMuzzleComp> _muzzleCompTable;
|
||||
private readonly IDataTable<DRBearingComp> _bearingCompTable;
|
||||
private readonly IDataTable<DRBaseComp> _baseCompTable;
|
||||
|
||||
public OutGameDropItemBuilder(
|
||||
IDataTable<DRMuzzleComp> muzzleCompTable,
|
||||
IDataTable<DRBearingComp> bearingCompTable,
|
||||
IDataTable<DRBaseComp> baseCompTable)
|
||||
{
|
||||
_muzzleCompTable = muzzleCompTable;
|
||||
_bearingCompTable = bearingCompTable;
|
||||
_baseCompTable = baseCompTable;
|
||||
}
|
||||
|
||||
public bool TryBuildItem(
|
||||
DROutGameDropPool row,
|
||||
RarityType rarity,
|
||||
InventoryGenerationRandomContext randomContext,
|
||||
out TowerCompItemData droppedItem)
|
||||
{
|
||||
droppedItem = null;
|
||||
if (row.ItemId <= 0 || string.IsNullOrWhiteSpace(row.ItemType))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
string itemType = row.ItemType.Trim();
|
||||
if (itemType.Equals("MuzzleComp", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
DRMuzzleComp config = _muzzleCompTable.GetDataRow(row.ItemId);
|
||||
if (config == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
droppedItem = ComponentItemFactory.CreateMuzzle(
|
||||
config,
|
||||
randomContext.CreateStableItemInstanceId(),
|
||||
rarity,
|
||||
randomContext.CreateTagRandomContext(config.Id));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (itemType.Equals("BearingComp", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
DRBearingComp config = _bearingCompTable.GetDataRow(row.ItemId);
|
||||
if (config == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
droppedItem = ComponentItemFactory.CreateBearing(
|
||||
config,
|
||||
randomContext.CreateStableItemInstanceId(),
|
||||
rarity,
|
||||
randomContext.CreateTagRandomContext(config.Id));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (itemType.Equals("BaseComp", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
DRBaseComp config = _baseCompTable.GetDataRow(row.ItemId);
|
||||
if (config == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
droppedItem = ComponentItemFactory.CreateBase(
|
||||
config,
|
||||
randomContext.CreateStableItemInstanceId(),
|
||||
rarity,
|
||||
randomContext.CreateTagRandomContext(config.Id));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c5915901f51c430db50725908113ae1a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user