Add initial resource and presenter classes for game entities and effects
This commit is contained in:
24
Code/Factories/EffectFactory.cs
Normal file
24
Code/Factories/EffectFactory.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices.ComTypes;
|
||||
using CryptonymThunder.Code.Resources;
|
||||
using CryptonymThunder.Code.Resources.Effects;
|
||||
using GameCore.Combat.Effects;
|
||||
using GameCore.Combat.Interfaces;
|
||||
|
||||
namespace CryptonymThunder.Code.Factories;
|
||||
|
||||
public class EffectFactory
|
||||
{
|
||||
public IEffect Create(EffectResource resource)
|
||||
{
|
||||
return resource switch
|
||||
{
|
||||
FireProjectileEffectResource fire =>
|
||||
new BulkProjectileEffect(fire.ProjectileArchetypeId, fire.Count, fire.SpreadAngle, fire.ProjectileSpeed),
|
||||
DamageEffectResource damage => new DamageEffect(damage.Amount),
|
||||
HitscanEffectResource hitscan => new HitscanEffect(hitscan.Range),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(resource),
|
||||
$"Effect type {resource.GetType().Name} not recognized")
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user