Platformer level management

This commit is contained in:
ThomasCharester committed 2026-03-23 12:01:33 +03:00
1 parent 72070901ec
commit 1aceea1b79
94 files changed
+3656 -197

No files matched your search

@@ -4,9 +4,12 @@ using System.Linq;
using Code.Infrastructure.Configs;
using Code.Infrastructure.EventBus;
using Cysharp.Threading.Tasks;
using Reflex.Core;
using Reflex.Injectors;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
using Object = UnityEngine.Object;
namespace Code.Example.Platformer.Entity
{
@@ -15,7 +18,7 @@ namespace Code.Example.Platformer.Entity
UniTaskVoid WarmEnemy(PlatformerEntityType enemyType);
void ReleaseEnemy(PlatformerEntityType racerType);
UniTaskVoid SpawnEnemy(
void SpawnEnemy(
PlatformerEntityType enemyType,
Vector3 position);
}
@@ -67,10 +70,6 @@ namespace Code.Example.Platformer.Entity
await _enemyPrefabsHandle[enemyType].ToUniTask();
var entity = _enemyPrefabsHandle[enemyType].Result.GetComponent<Entity>();
entity.SetData(_enemyConfigs[enemyType].EntityData);
var health = _enemyPrefabsHandle[enemyType].Result.GetComponent<EntityHealth>();
health.SetMaxHealth(_enemyConfigs[enemyType].EntityData.maxHealth);
_eventBus.RaiseEvent<IPlatformerEnemyLoadedHandle>(x => x.PlatformerEnemyLoaded(enemyType, entity));
}
@@ -81,13 +80,21 @@ namespace Code.Example.Platformer.Entity
_enemyPrefabsHandle.Remove(racerType);
}
public async UniTaskVoid SpawnEnemy(
public void SpawnEnemy(
PlatformerEntityType enemyType,
Vector3 position)
{
if (enemyType == PlatformerEntityType.Player) return;
await Addressables.InstantiateAsync(_enemyConfigs[enemyType].prefabReference, position, Quaternion.identity);
var gameObject = Object.Instantiate(_enemyPrefabsHandle[enemyType].Result, position, Quaternion.identity);
var entity = gameObject.GetComponent<Entity>();
entity.SetData(_enemyConfigs[enemyType].EntityData);
var health = gameObject.GetComponent<EntityHealth>();
health.Setup(_enemyConfigs[enemyType].EntityData.maxHealth, _enemyConfigs[enemyType].EntityData.damageRecieveThreshold);
GameObjectInjector.InjectObject(gameObject, Container.RootContainer);
}
public void Dispose()