mirror of
https://github.com/Bragin-Stepan/project-entity.git
synced 2026-03-05 07:41:10 +00:00
update: add radius for teleport
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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<float> _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));
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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<float> 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<int> Value; }
|
||||
public class TeleportEnergyCost : IEntityComponent { public ReactiveVariable<int> Value; }
|
||||
}
|
||||
Reference in New Issue
Block a user