Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using Game.Gameplay.AI.States;
- using Zenject;
- namespace Game.Gameplay
- {
- public class StateFactory : PlaceholderFactory<Type, IState>
- {
- public class Custom : IFactory<Type, IState>
- {
- private readonly DiContainer _container;
- public Custom(DiContainer container) => _container = container;
- public IState Create(Type type)
- {
- if (typeof(IState).IsAssignableFrom(type))
- return (IState)_container.Instantiate(type);
- throw new ArgumentException($"Argument {nameof(type)} is not valid value. ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement