83 lines
3.2 KiB
C#
83 lines
3.2 KiB
C#
using System;
|
|
using GeometryTD.DataTable;
|
|
using GeometryTD.Definition;
|
|
|
|
namespace GeometryTD.Factory
|
|
{
|
|
public static class ComponentItemFactory
|
|
{
|
|
public static MuzzleCompItemData CreateMuzzle(
|
|
DRMuzzleComp config,
|
|
long instanceId,
|
|
RarityType rarity,
|
|
InventoryTagRandomContext randomContext)
|
|
{
|
|
RarityType normalizedRarity = InventoryRarityRuleService.NormalizeComponentRarity(rarity);
|
|
return new MuzzleCompItemData
|
|
{
|
|
InstanceId = instanceId,
|
|
ConfigId = config.Id,
|
|
Name = config.Name,
|
|
Rarity = normalizedRarity,
|
|
Endurance = 100f,
|
|
Constraint = config.Constraint,
|
|
Tags = ComponentTagGenerationService.ResolveComponentTags(
|
|
config.PossibleTag,
|
|
normalizedRarity,
|
|
randomContext),
|
|
AttackDamage = config.AttackDamage != null ? (int[])config.AttackDamage.Clone() : Array.Empty<int>(),
|
|
DamageRandomRate = config.DamageRandomRate,
|
|
AttackMethodType = config.AttackMethodType
|
|
};
|
|
}
|
|
|
|
public static BearingCompItemData CreateBearing(
|
|
DRBearingComp config,
|
|
long instanceId,
|
|
RarityType rarity,
|
|
InventoryTagRandomContext randomContext)
|
|
{
|
|
RarityType normalizedRarity = InventoryRarityRuleService.NormalizeComponentRarity(rarity);
|
|
return new BearingCompItemData
|
|
{
|
|
InstanceId = instanceId,
|
|
ConfigId = config.Id,
|
|
Name = config.Name,
|
|
Rarity = normalizedRarity,
|
|
Endurance = 100f,
|
|
Constraint = config.Constraint,
|
|
Tags = ComponentTagGenerationService.ResolveComponentTags(
|
|
config.PossibleTag,
|
|
normalizedRarity,
|
|
randomContext),
|
|
RotateSpeed = config.RotateSpeed != null ? (float[])config.RotateSpeed.Clone() : Array.Empty<float>(),
|
|
AttackRange = config.AttackRange != null ? (float[])config.AttackRange.Clone() : Array.Empty<float>()
|
|
};
|
|
}
|
|
|
|
public static BaseCompItemData CreateBase(
|
|
DRBaseComp config,
|
|
long instanceId,
|
|
RarityType rarity,
|
|
InventoryTagRandomContext randomContext)
|
|
{
|
|
RarityType normalizedRarity = InventoryRarityRuleService.NormalizeComponentRarity(rarity);
|
|
return new BaseCompItemData
|
|
{
|
|
InstanceId = instanceId,
|
|
ConfigId = config.Id,
|
|
Name = config.Name,
|
|
Rarity = normalizedRarity,
|
|
Endurance = 100f,
|
|
Constraint = config.Constraint,
|
|
Tags = ComponentTagGenerationService.ResolveComponentTags(
|
|
config.PossibleTag,
|
|
normalizedRarity,
|
|
randomContext),
|
|
AttackSpeed = config.AttackSpeed != null ? (float[])config.AttackSpeed.Clone() : Array.Empty<float>(),
|
|
AttackPropertyType = config.AttackPropertyType
|
|
};
|
|
}
|
|
}
|
|
}
|