diff --git a/Assets/_Project/Develop/Runtime/Logic/Gameplay/Entities/EntitiesFactory.cs b/Assets/_Project/Develop/Runtime/Logic/Gameplay/Entities/EntitiesFactory.cs index 3a8703c..74bff16 100644 --- a/Assets/_Project/Develop/Runtime/Logic/Gameplay/Entities/EntitiesFactory.cs +++ b/Assets/_Project/Develop/Runtime/Logic/Gameplay/Entities/EntitiesFactory.cs @@ -231,7 +231,8 @@ namespace _Project.Develop.Runtime.Entities .AddFindTeleportPointRequest() .AddEndTeleportEvent() - .AddEnergyTeleportCost(new ReactiveVariable(20)) + .AddTeleportEnergyCost(new ReactiveVariable(20)) + .AddTeleportSearchRadius(new ReactiveVariable(6)) .AddCurrentEnergy(new ReactiveVariable(60)) .AddMaxEnergy(new ReactiveVariable(60)) @@ -260,7 +261,7 @@ namespace _Project.Develop.Runtime.Entities ICompositeCondition canStartTeleport = new CompositeCondition() .Add(new FuncCondition(() => entity.IsDead.Value == false)) - .Add(new FuncCondition(() => entity.CurrentEnergy.Value >= entity.EnergyTeleportCost.Value)); + .Add(new FuncCondition(() => entity.CurrentEnergy.Value >= entity.TeleportEnergyCost.Value)); ICompositeCondition mustDie = new CompositeCondition() .Add(new FuncCondition(() => entity.CurrentHealth.Value <= 0)); diff --git a/Assets/_Project/Develop/Runtime/Logic/Gameplay/Entities/Generated/EntityAPI.cs b/Assets/_Project/Develop/Runtime/Logic/Gameplay/Entities/Generated/EntityAPI.cs index b08d07f..c261145 100644 --- a/Assets/_Project/Develop/Runtime/Logic/Gameplay/Entities/Generated/EntityAPI.cs +++ b/Assets/_Project/Develop/Runtime/Logic/Gameplay/Entities/Generated/EntityAPI.cs @@ -116,6 +116,30 @@ namespace _Project.Develop.Runtime.Entities return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportToPoint() {Value = value}); } + public _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportSearchRadius TeleportSearchRadiusC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportSearchRadius>(); + + public _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable TeleportSearchRadius => TeleportSearchRadiusC.Value; + + public bool TryGetTeleportSearchRadius(out _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable value) + { + bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportSearchRadius component); + if(result) + value = component.Value; + else + value = default(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable); + return result; + } + + public _Project.Develop.Runtime.Entities.Entity AddTeleportSearchRadius() + { + return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportSearchRadius() { Value = new _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable() }); + } + + public _Project.Develop.Runtime.Entities.Entity AddTeleportSearchRadius(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable value) + { + return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportSearchRadius() {Value = value}); + } + public _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.FindTeleportPointRequest FindTeleportPointRequestC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.FindTeleportPointRequest>(); public _Project.Develop.Runtime.Utils.ReactiveManagement.Event.ReactiveEvent FindTeleportPointRequest => FindTeleportPointRequestC.Value; @@ -279,13 +303,13 @@ namespace _Project.Develop.Runtime.Entities return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.EndTeleportEvent() {Value = value}); } - public _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.EnergyTeleportCost EnergyTeleportCostC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.EnergyTeleportCost>(); + public _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportEnergyCost TeleportEnergyCostC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportEnergyCost>(); - public _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable EnergyTeleportCost => EnergyTeleportCostC.Value; + public _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable TeleportEnergyCost => TeleportEnergyCostC.Value; - public bool TryGetEnergyTeleportCost(out _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable value) + public bool TryGetTeleportEnergyCost(out _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable value) { - bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.EnergyTeleportCost component); + bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportEnergyCost component); if(result) value = component.Value; else @@ -293,14 +317,14 @@ namespace _Project.Develop.Runtime.Entities return result; } - public _Project.Develop.Runtime.Entities.Entity AddEnergyTeleportCost() + public _Project.Develop.Runtime.Entities.Entity AddTeleportEnergyCost() { - return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.EnergyTeleportCost() { Value = new _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable() }); + return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportEnergyCost() { Value = new _Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable() }); } - public _Project.Develop.Runtime.Entities.Entity AddEnergyTeleportCost(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable value) + public _Project.Develop.Runtime.Entities.Entity AddTeleportEnergyCost(_Project.Develop.Runtime.Utils.ReactiveManagement.ReactiveVariable value) { - return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.EnergyTeleportCost() {Value = value}); + return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportEnergyCost() {Value = value}); } public _Project.Develop.Runtime.Logic.Gameplay.Features.Sensors.CapsuleColliderComponent CapsuleColliderC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Sensors.CapsuleColliderComponent>(); diff --git a/Assets/_Project/Develop/Runtime/Logic/Gameplay/Features/Energy/Systems/RegenEnergyByPercentageSystem.cs b/Assets/_Project/Develop/Runtime/Logic/Gameplay/Features/Energy/Systems/RegenEnergyByPercentageSystem.cs index ba5925c..7a12592 100644 --- a/Assets/_Project/Develop/Runtime/Logic/Gameplay/Features/Energy/Systems/RegenEnergyByPercentageSystem.cs +++ b/Assets/_Project/Develop/Runtime/Logic/Gameplay/Features/Energy/Systems/RegenEnergyByPercentageSystem.cs @@ -45,8 +45,7 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Energy.Systems if (energyDifference <= 0) return; - float regenAmountFloat = _maxEnergy.Value * (percentage / 100f); - int regenAmount = (int)math.floor(regenAmountFloat); + int regenAmount= (int)math.floor(_maxEnergy.Value * (percentage / 100f)); if (regenAmount < 1 && _maxEnergy.Value > 0) regenAmount = 1; diff --git a/Assets/_Project/Develop/Runtime/Logic/Gameplay/Features/Teleport/Systems/FindRandomPointForTeleportSystem.cs b/Assets/_Project/Develop/Runtime/Logic/Gameplay/Features/Teleport/Systems/FindRandomPointForTeleportSystem.cs index 5d555b8..52b180e 100644 --- a/Assets/_Project/Develop/Runtime/Logic/Gameplay/Features/Teleport/Systems/FindRandomPointForTeleportSystem.cs +++ b/Assets/_Project/Develop/Runtime/Logic/Gameplay/Features/Teleport/Systems/FindRandomPointForTeleportSystem.cs @@ -1,7 +1,9 @@ using System; using _Project.Develop.Runtime.Entities; +using _Project.Develop.Runtime.Utils.ReactiveManagement; using _Project.Develop.Runtime.Utils.ReactiveManagement.Event; using UnityEngine; +using Random = UnityEngine.Random; namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.Systems { @@ -11,12 +13,15 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.Systems private ReactiveEvent _findPointRequest; private ReactiveEvent _findPointEvent; + + private ReactiveVariable _radius; private IDisposable _findPointRequestDisposable; public void OnInit(Entity entity) { _toPoint = entity.TeleportToPoint; + _radius = entity.TeleportSearchRadius; _findPointRequest = entity.FindTeleportPointRequest; _findPointEvent = entity.FindTeleportPointEvent; @@ -30,8 +35,11 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.Systems private void OnFindPointRequest() { - _toPoint.position = Vector3.zero; + _toPoint.position = GetRandomPointByRadius(_radius.Value); _findPointEvent.Invoke(); } + + private Vector3 GetRandomPointByRadius(float radius) + => new(Random.Range(0, radius), 0, Random.Range(0, radius)); } } \ No newline at end of file diff --git a/Assets/_Project/Develop/Runtime/Logic/Gameplay/Features/Teleport/Systems/TeleportStartByEnergySystem.cs b/Assets/_Project/Develop/Runtime/Logic/Gameplay/Features/Teleport/Systems/TeleportStartByEnergySystem.cs index b179dd5..fa6d4de 100644 --- a/Assets/_Project/Develop/Runtime/Logic/Gameplay/Features/Teleport/Systems/TeleportStartByEnergySystem.cs +++ b/Assets/_Project/Develop/Runtime/Logic/Gameplay/Features/Teleport/Systems/TeleportStartByEnergySystem.cs @@ -21,7 +21,7 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.Systems public void OnInit(Entity entity) { - _teleportCost = entity.EnergyTeleportCost; + _teleportCost = entity.TeleportEnergyCost; _useEnergyRequest = entity.UseEnergyRequest; _startTeleportRequest = entity.StartTeleportRequest; diff --git a/Assets/_Project/Develop/Runtime/Logic/Gameplay/Features/Teleport/TeleportComponents.cs b/Assets/_Project/Develop/Runtime/Logic/Gameplay/Features/Teleport/TeleportComponents.cs index e221ab8..098d605 100644 --- a/Assets/_Project/Develop/Runtime/Logic/Gameplay/Features/Teleport/TeleportComponents.cs +++ b/Assets/_Project/Develop/Runtime/Logic/Gameplay/Features/Teleport/TeleportComponents.cs @@ -8,6 +8,7 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport { public class TeleportTarget : IEntityComponent { public Transform Value; } public class TeleportToPoint : IEntityComponent { public Transform Value; } + public class TeleportSearchRadius : IEntityComponent { public ReactiveVariable Value; } public class FindTeleportPointRequest : IEntityComponent { public ReactiveEvent Value; } public class FindTeleportPointEvent : IEntityComponent { public ReactiveEvent Value; } @@ -20,5 +21,5 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport public class EndTeleportEvent : IEntityComponent { public ReactiveEvent Value; } - public class EnergyTeleportCost : IEntityComponent { public ReactiveVariable Value; } + public class TeleportEnergyCost : IEntityComponent { public ReactiveVariable Value; } } \ No newline at end of file