mirror of
https://github.com/Bragin-Stepan/project-entity.git
synced 2026-03-02 22:31:10 +00:00
update: teleport system
This commit is contained in:
@@ -116,6 +116,54 @@ namespace _Project.Develop.Runtime.Entities
|
|||||||
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportToPoint() {Value = value});
|
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.TeleportToPoint() {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;
|
||||||
|
|
||||||
|
public bool TryGetFindTeleportPointRequest(out _Project.Develop.Runtime.Utils.ReactiveManagement.Event.ReactiveEvent value)
|
||||||
|
{
|
||||||
|
bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.FindTeleportPointRequest component);
|
||||||
|
if(result)
|
||||||
|
value = component.Value;
|
||||||
|
else
|
||||||
|
value = default(_Project.Develop.Runtime.Utils.ReactiveManagement.Event.ReactiveEvent);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public _Project.Develop.Runtime.Entities.Entity AddFindTeleportPointRequest()
|
||||||
|
{
|
||||||
|
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.FindTeleportPointRequest() { Value = new _Project.Develop.Runtime.Utils.ReactiveManagement.Event.ReactiveEvent() });
|
||||||
|
}
|
||||||
|
|
||||||
|
public _Project.Develop.Runtime.Entities.Entity AddFindTeleportPointRequest(_Project.Develop.Runtime.Utils.ReactiveManagement.Event.ReactiveEvent value)
|
||||||
|
{
|
||||||
|
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.FindTeleportPointRequest() {Value = value});
|
||||||
|
}
|
||||||
|
|
||||||
|
public _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.FindTeleportPointEvent FindTeleportPointEventC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.FindTeleportPointEvent>();
|
||||||
|
|
||||||
|
public _Project.Develop.Runtime.Utils.ReactiveManagement.Event.ReactiveEvent FindTeleportPointEvent => FindTeleportPointEventC.Value;
|
||||||
|
|
||||||
|
public bool TryGetFindTeleportPointEvent(out _Project.Develop.Runtime.Utils.ReactiveManagement.Event.ReactiveEvent value)
|
||||||
|
{
|
||||||
|
bool result = TryGetComponent(out _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.FindTeleportPointEvent component);
|
||||||
|
if(result)
|
||||||
|
value = component.Value;
|
||||||
|
else
|
||||||
|
value = default(_Project.Develop.Runtime.Utils.ReactiveManagement.Event.ReactiveEvent);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public _Project.Develop.Runtime.Entities.Entity AddFindTeleportPointEvent()
|
||||||
|
{
|
||||||
|
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.FindTeleportPointEvent() { Value = new _Project.Develop.Runtime.Utils.ReactiveManagement.Event.ReactiveEvent() });
|
||||||
|
}
|
||||||
|
|
||||||
|
public _Project.Develop.Runtime.Entities.Entity AddFindTeleportPointEvent(_Project.Develop.Runtime.Utils.ReactiveManagement.Event.ReactiveEvent value)
|
||||||
|
{
|
||||||
|
return AddComponent(new _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.FindTeleportPointEvent() {Value = value});
|
||||||
|
}
|
||||||
|
|
||||||
public _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.CanStartTeleport CanStartTeleportC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.CanStartTeleport>();
|
public _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.CanStartTeleport CanStartTeleportC => GetComponent<_Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.CanStartTeleport>();
|
||||||
|
|
||||||
public _Project.Develop.Runtime.Utilities.Conditions.ICompositeCondition CanStartTeleport => CanStartTeleportC.Value;
|
public _Project.Develop.Runtime.Utilities.Conditions.ICompositeCondition CanStartTeleport => CanStartTeleportC.Value;
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
using System;
|
||||||
|
using _Project.Develop.Runtime.Entities;
|
||||||
|
using _Project.Develop.Runtime.Utils.ReactiveManagement;
|
||||||
|
using _Project.Develop.Runtime.Utils.ReactiveManagement.Event;
|
||||||
|
|
||||||
|
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.Systems
|
||||||
|
{
|
||||||
|
public class EndTeleportSystem : IInitializableSystem, IDisposableSystem
|
||||||
|
{
|
||||||
|
private ReactiveVariable<bool> _inTeleportProcess;
|
||||||
|
|
||||||
|
private ReactiveEvent _findPointEvent;
|
||||||
|
private ReactiveEvent _endTeleportEvent;
|
||||||
|
|
||||||
|
private IDisposable _findEventDisposable;
|
||||||
|
|
||||||
|
public void OnInit(Entity entity)
|
||||||
|
{
|
||||||
|
_findPointEvent = entity.FindTeleportPointEvent;
|
||||||
|
_endTeleportEvent = entity.EndTeleportEvent;
|
||||||
|
_inTeleportProcess = entity.InTeleportProcess;
|
||||||
|
|
||||||
|
_findEventDisposable = _findPointEvent.Subscribe(OnFindEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnDispose()
|
||||||
|
{
|
||||||
|
_findEventDisposable.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnFindEvent()
|
||||||
|
{
|
||||||
|
_inTeleportProcess.Value = false;
|
||||||
|
|
||||||
|
_endTeleportEvent.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c5495feb949542bdac01bbac587fab8b
|
||||||
|
timeCreated: 1771766015
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
using System;
|
||||||
|
using _Project.Develop.Runtime.Entities;
|
||||||
|
using _Project.Develop.Runtime.Utils.ReactiveManagement.Event;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.Systems
|
||||||
|
{
|
||||||
|
public class FindRandomPointForTeleportSystem : IInitializableSystem, IDisposableSystem
|
||||||
|
{
|
||||||
|
private Transform _toPoint;
|
||||||
|
|
||||||
|
private ReactiveEvent _findPointRequest;
|
||||||
|
private ReactiveEvent _findPointEvent;
|
||||||
|
|
||||||
|
private IDisposable _findPointRequestDisposable;
|
||||||
|
|
||||||
|
public void OnInit(Entity entity)
|
||||||
|
{
|
||||||
|
_toPoint = entity.TeleportToPoint;
|
||||||
|
_findPointEvent = entity.FindTeleportPointEvent;
|
||||||
|
|
||||||
|
_findPointRequestDisposable = _findPointRequest.Subscribe(OnFindPointRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnDispose()
|
||||||
|
{
|
||||||
|
_findPointRequestDisposable.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnFindPointRequest()
|
||||||
|
{
|
||||||
|
_toPoint.position = Vector3.zero;
|
||||||
|
_findPointEvent.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 977f0d8298ff47b5baf552f962b6eeb5
|
||||||
|
timeCreated: 1771764055
|
||||||
@@ -5,36 +5,32 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.Systems
|
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.Systems
|
||||||
{
|
{
|
||||||
public class ProcessTeleportSystem : IInitializableSystem, IDisposableSystem
|
public class InstantTeleportSystem : IInitializableSystem, IDisposableSystem
|
||||||
{
|
{
|
||||||
private Transform _target;
|
private Transform _target;
|
||||||
private Transform _toPoint;
|
private Transform _toPoint;
|
||||||
|
|
||||||
private ReactiveEvent _startTeleportEvent;
|
|
||||||
private ReactiveEvent _endTeleportEvent;
|
private ReactiveEvent _endTeleportEvent;
|
||||||
|
|
||||||
private IDisposable _startTeleportEventDisposable;
|
private IDisposable _endTeleportDisposable;
|
||||||
|
|
||||||
public void OnInit(Entity entity)
|
public void OnInit(Entity entity)
|
||||||
{
|
{
|
||||||
_target = entity.TeleportTarget;
|
_target = entity.TeleportTarget;
|
||||||
_toPoint = entity.TeleportToPoint;
|
_toPoint = entity.TeleportToPoint;
|
||||||
|
|
||||||
_startTeleportEvent = entity.StartTeleportEvent;
|
|
||||||
_endTeleportEvent = entity.EndTeleportEvent;
|
_endTeleportEvent = entity.EndTeleportEvent;
|
||||||
|
|
||||||
_startTeleportEventDisposable = _startTeleportEvent.Subscribe(OnStartTeleportProcess);
|
_endTeleportDisposable = _endTeleportEvent.Subscribe(OnEndTeleport);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnStartTeleportProcess()
|
|
||||||
{
|
|
||||||
_target.position = _toPoint.position;
|
|
||||||
_endTeleportEvent.Invoke();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnDispose()
|
public void OnDispose()
|
||||||
{
|
{
|
||||||
_startTeleportEventDisposable.Dispose();
|
_endTeleportDisposable.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnEndTeleport()
|
||||||
|
{
|
||||||
|
_target.position = _toPoint.position;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9f0c47335599454aaa6b713d1056aedc
|
||||||
|
timeCreated: 1771766007
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
using System;
|
||||||
|
using _Project.Develop.Runtime.Entities;
|
||||||
|
using _Project.Develop.Runtime.Utils.ReactiveManagement;
|
||||||
|
using _Project.Develop.Runtime.Utils.ReactiveManagement.Event;
|
||||||
|
|
||||||
|
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.Systems
|
||||||
|
{
|
||||||
|
public class TeleportProcessSystem : IInitializableSystem, IDisposableSystem
|
||||||
|
{
|
||||||
|
private ReactiveEvent _findPointRequest;
|
||||||
|
private ReactiveVariable<bool> _inTeleportProcess;
|
||||||
|
|
||||||
|
private ReactiveEvent _startTeleportEvent;
|
||||||
|
|
||||||
|
private IDisposable _startTeleportEventDisposable;
|
||||||
|
|
||||||
|
public void OnInit(Entity entity)
|
||||||
|
{
|
||||||
|
_findPointRequest = entity.FindTeleportPointRequest;
|
||||||
|
|
||||||
|
_startTeleportEventDisposable = _startTeleportEvent.Subscribe(OnStartTeleportProcess);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnStartTeleportProcess()
|
||||||
|
{
|
||||||
|
_findPointRequest.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnDispose()
|
||||||
|
{
|
||||||
|
_startTeleportEventDisposable.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@ using _Project.Develop.Runtime.Utils.ReactiveManagement.Event;
|
|||||||
|
|
||||||
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.Systems
|
namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport.Systems
|
||||||
{
|
{
|
||||||
public class StartTeleportByEnergySystem: IInitializableSystem, IDisposableSystem
|
public class TeleportStartByEnergySystem: IInitializableSystem, IDisposableSystem
|
||||||
{
|
{
|
||||||
private ReactiveEvent<int> _useEnergyRequest;
|
private ReactiveEvent<int> _useEnergyRequest;
|
||||||
private ReactiveEvent _startTeleportRequest;
|
private ReactiveEvent _startTeleportRequest;
|
||||||
@@ -9,6 +9,9 @@ namespace _Project.Develop.Runtime.Logic.Gameplay.Features.Teleport
|
|||||||
public class TeleportTarget : IEntityComponent { public Transform Value; }
|
public class TeleportTarget : IEntityComponent { public Transform Value; }
|
||||||
public class TeleportToPoint : IEntityComponent { public Transform Value; }
|
public class TeleportToPoint : IEntityComponent { public Transform Value; }
|
||||||
|
|
||||||
|
public class FindTeleportPointRequest : IEntityComponent { public ReactiveEvent Value; }
|
||||||
|
public class FindTeleportPointEvent : IEntityComponent { public ReactiveEvent Value; }
|
||||||
|
|
||||||
public class CanStartTeleport : IEntityComponent { public ICompositeCondition Value; }
|
public class CanStartTeleport : IEntityComponent { public ICompositeCondition Value; }
|
||||||
public class InTeleportProcess : IEntityComponent { public ReactiveVariable<bool> Value; }
|
public class InTeleportProcess : IEntityComponent { public ReactiveVariable<bool> Value; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user