mirror of
https://github.com/Bragin-Stepan/project-entity.git
synced 2026-04-19 21:19:41 +00:00
feat: att team feature
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 073e06f2bd1243408c61652926dbac9a
|
||||
timeCreated: 1773390931
|
||||
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using _Project.Develop.Runtime.Configs.Gameplay.Entities;
|
||||
using _Project.Develop.Runtime.Entities;
|
||||
using _Project.Develop.Runtime.Logic.Gameplay.Features.AI;
|
||||
using _Project.Develop.Runtime.Logic.Gameplay.Features.Selectors;
|
||||
using _Project.Develop.Runtime.Utils.ReactiveManagement;
|
||||
using Assets._Project.Develop.Runtime.Infrastructure.DI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Enemies
|
||||
{
|
||||
public class EnemiesFactory
|
||||
{
|
||||
private readonly EntitiesFactory _entitiesFactory;
|
||||
private readonly BrainsFactory _brainsFactory;
|
||||
private readonly EntitiesLifeContext _entitiesLifeContext;
|
||||
|
||||
public EnemiesFactory(DIContainer container)
|
||||
{
|
||||
_entitiesFactory = container.Resolve<EntitiesFactory>();
|
||||
_brainsFactory = container.Resolve<BrainsFactory>();
|
||||
_entitiesLifeContext = container.Resolve<EntitiesLifeContext>();
|
||||
}
|
||||
|
||||
public Entity Create(Vector3 position, EntityConfigSO config)
|
||||
{
|
||||
Entity entity;
|
||||
|
||||
switch (config)
|
||||
{
|
||||
case GhostConfigSO ghostConfig:
|
||||
entity = _entitiesFactory.CreateGhost(position, ghostConfig);
|
||||
_brainsFactory.CreateGhostBrain(entity);
|
||||
break;
|
||||
|
||||
case WizardConfigSO wizardConfig:
|
||||
entity = _entitiesFactory.CreateTeleportWizard(position, wizardConfig);
|
||||
_brainsFactory.CreateDangerWizardBrain(entity, new LowestHealthTargetSelector(entity));
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new ArgumentException($"Not support {config.GetType()} type config");
|
||||
}
|
||||
|
||||
entity.AddTeam(new ReactiveVariable<Teams.Teams>(Teams.Teams.Enemies));
|
||||
|
||||
_entitiesLifeContext.Add(entity);
|
||||
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 51102a09ab584bd8a413995baf3ed9b9
|
||||
timeCreated: 1773390941
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3bfebd749d5b44a295ddf91039d598a4
|
||||
timeCreated: 1773389854
|
||||
@@ -0,0 +1,6 @@
|
||||
using _Project.Develop.Runtime.Entities;
|
||||
|
||||
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.MainHero
|
||||
{
|
||||
public class IsMainHero : IEntityComponent { }
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d7f214ebbb94ba3a40b05d47a56ea32
|
||||
timeCreated: 1773389869
|
||||
@@ -0,0 +1,44 @@
|
||||
using _Project.Develop.Runtime.Configs.Gameplay.Entities;
|
||||
using _Project.Develop.Runtime.Entities;
|
||||
using _Project.Develop.Runtime.Logic.Gameplay.Features.AI;
|
||||
using _Project.Develop.Runtime.Utils.ReactiveManagement;
|
||||
using Assets._Project.Develop.Runtime.Infrastructure.DI;
|
||||
using Assets._Project.Develop.Runtime.Utilities.ConfigsManagement;
|
||||
using UnityEngine;
|
||||
|
||||
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.MainHero
|
||||
{
|
||||
public class MainHeroFactory
|
||||
{
|
||||
private readonly EntitiesFactory _entitiesFactory;
|
||||
private readonly BrainsFactory _brainsFactory;
|
||||
private readonly ConfigsProviderService _configLoader;
|
||||
private readonly EntitiesLifeContext _entitiesLifeContext;
|
||||
|
||||
public MainHeroFactory(DIContainer container)
|
||||
{
|
||||
_entitiesFactory = container.Resolve<EntitiesFactory>();
|
||||
_brainsFactory = container.Resolve<BrainsFactory>();
|
||||
_configLoader = container.Resolve<ConfigsProviderService>();
|
||||
_entitiesLifeContext = container.Resolve<EntitiesLifeContext>();
|
||||
}
|
||||
|
||||
public Entity Create(Vector3 position)
|
||||
{
|
||||
HeroConfigSO config = _configLoader.GetConfig<HeroConfigSO>();
|
||||
|
||||
Entity entity = _entitiesFactory.CreateHero(position, config);
|
||||
|
||||
entity
|
||||
.AddIsMainHero()
|
||||
.AddTeam(new ReactiveVariable<Teams.Teams>(Teams.Teams.MainHero));
|
||||
|
||||
entity.AddCurrentTarget();
|
||||
_brainsFactory.CreateMainHeroBrain(entity);
|
||||
|
||||
_entitiesLifeContext.Add(entity);
|
||||
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f02ea9aeb6334badac37cab0a5e69da0
|
||||
timeCreated: 1773390441
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2bf870f1fd6247d7aaa3343f010cfd52
|
||||
timeCreated: 1773394525
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teams
|
||||
{
|
||||
public enum Teams
|
||||
{
|
||||
MainHero,
|
||||
Enemies
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b5919366f522d048bcde4e406462f16
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,10 @@
|
||||
using _Project.Develop.Runtime.Entities;
|
||||
using _Project.Develop.Runtime.Utils.ReactiveManagement;
|
||||
|
||||
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teams
|
||||
{
|
||||
public class Team : IEntityComponent
|
||||
{
|
||||
public ReactiveVariable<Teams> Value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d8073d07bb648c5b6e3dc920591e9db
|
||||
timeCreated: 1773394552
|
||||
Reference in New Issue
Block a user