1
This commit is contained in:
@@ -6,7 +6,7 @@ using BITKit.Animations;
|
||||
namespace BITKit.Entities
|
||||
{
|
||||
|
||||
public sealed class EntityAnimator : EntityComponent
|
||||
public sealed class EntityAnimator : EntityBehavior
|
||||
{
|
||||
[SerializeField] private UnityAnimator[] animators;
|
||||
[SerializeReference, SubclassSelector] private References[] animationKeyWords;
|
||||
@@ -20,7 +20,7 @@ namespace BITKit.Entities
|
||||
}
|
||||
public override void OnStart()
|
||||
{
|
||||
entity.AddListener<string>(Constant.Animation.Play, Play);
|
||||
UnityEntity.AddListener<string>(Constant.Animation.Play, Play);
|
||||
}
|
||||
|
||||
private void Play(string animationName)
|
||||
@@ -42,7 +42,7 @@ namespace BITKit.Entities
|
||||
animators.ForEach(x =>
|
||||
{
|
||||
if (x.isActiveAndEnabled)
|
||||
x.animator.SetBool(boolPar, entity.Get<bool>(boolPar));
|
||||
x.animator.SetBool(boolPar, UnityEntity.Get<bool>(boolPar));
|
||||
});
|
||||
}
|
||||
foreach (var floatPar in floatParameters)
|
||||
@@ -50,7 +50,7 @@ namespace BITKit.Entities
|
||||
animators.ForEach(x =>
|
||||
{
|
||||
if (x.isActiveAndEnabled)
|
||||
x.animator.SetFloat(floatPar, entity.Get<float>(floatPar));
|
||||
x.animator.SetFloat(floatPar, UnityEntity.Get<float>(floatPar));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -58,14 +58,14 @@ namespace BITKit.Entities
|
||||
private void OnAnimatorMove()
|
||||
{
|
||||
if (enabled is false) return;
|
||||
if (_rootVelocity is not null && entity is not null)
|
||||
entity.Set(_rootVelocity, animators[0].animator.velocity);
|
||||
if (_rootVelocity is not null && UnityEntity is not null)
|
||||
UnityEntity.Set(_rootVelocity, animators[0].animator.velocity);
|
||||
}
|
||||
|
||||
// ReSharper disable once UnusedMember.Local
|
||||
private void AnimationEvent(string eventName)
|
||||
{
|
||||
entity.Invoke(Constant.Animation.OnEvent, eventName);
|
||||
UnityEntity.Invoke(Constant.Animation.OnEvent, eventName);
|
||||
}
|
||||
}
|
||||
}
|
@@ -4,12 +4,12 @@ using UnityEngine;
|
||||
using BITKit.Sensors;
|
||||
namespace BITKit.Entities
|
||||
{
|
||||
public class EntityAudioObject : EntityComponent, IAudioObject
|
||||
public class EntityAudioObject : EntityBehavior, IAudioObject
|
||||
{
|
||||
float volume;
|
||||
public override void OnStart()
|
||||
{
|
||||
entity.AddListener<AudioSO>(OnAuioSO);
|
||||
UnityEntity.AddListener<AudioSO>(OnAuioSO);
|
||||
}
|
||||
public override void OnFixedUpdate(float deltaTime)
|
||||
{
|
||||
|
@@ -2,7 +2,7 @@ using BITKit.Entities.Player;
|
||||
using UnityEngine;
|
||||
namespace BITKit.Entities
|
||||
{
|
||||
public class EntityCamera : EntityPlayerComponent
|
||||
public class EntityCamera : EntityPlayerBehavior
|
||||
{
|
||||
[Header(Constant.Header.Components)]
|
||||
public Behaviour aliveCamera;
|
||||
@@ -11,7 +11,7 @@ namespace BITKit.Entities
|
||||
[SerializeReference, SubclassSelector] public IReference _onSetAlive;
|
||||
public override void OnAwake()
|
||||
{
|
||||
var heal = entity.Get<IHealth>();
|
||||
var heal = UnityEntity.Get<IHealth>();
|
||||
heal.OnSetAlive += OnSetAlive;
|
||||
}
|
||||
private void OnSetAlive(bool alive)
|
||||
|
@@ -4,7 +4,7 @@ using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
namespace BITKit.Entities.Player.Character
|
||||
{
|
||||
public class EntityCharacter : EntityPlayerComponent
|
||||
public class EntityCharacter : EntityPlayerBehavior
|
||||
{
|
||||
[Header(Constant.Header.Components)]
|
||||
[SerializeField] private Renderer[] fpvRenderer = Array.Empty<Renderer>();
|
||||
@@ -13,7 +13,7 @@ namespace BITKit.Entities.Player.Character
|
||||
[SerializeReference, SubclassSelector] public References _getDamage;
|
||||
public override void OnStart()
|
||||
{
|
||||
var heal = entity.Get<IHealth>();
|
||||
var heal = UnityEntity.Get<IHealth>();
|
||||
heal.OnSetAlive += OnSetAlive;
|
||||
heal.OnSetHealthPoint += OnSetHP;
|
||||
}
|
||||
@@ -33,7 +33,7 @@ namespace BITKit.Entities.Player.Character
|
||||
}
|
||||
private void OnSetHP(int hp)
|
||||
{
|
||||
entity.Invoke<string>(Constant.Animation.Play, _getDamage);
|
||||
UnityEntity.Invoke<string>(Constant.Animation.Play, _getDamage);
|
||||
}
|
||||
private void SetFPV(bool isFpv)
|
||||
{
|
||||
|
@@ -6,7 +6,7 @@ using UnityEngine.InputSystem;
|
||||
|
||||
namespace BITKit
|
||||
{
|
||||
public class NavAgentMovement: StateBasedComponent<IEntityMovementState>,IEntityMovement
|
||||
public class NavAgentMovement: StateBasedBehavior<IEntityMovementState>,IEntityMovement
|
||||
{
|
||||
#region 属性
|
||||
[SerializeField] private NavMeshAgent agent;
|
||||
@@ -67,8 +67,8 @@ namespace BITKit
|
||||
GroundVelocity = _groundVelocity;
|
||||
IsGrounded = agent.isOnOffMeshLink is false;
|
||||
|
||||
entity.Set<bool>("IsMoving",Velocity.sqrMagnitude>=0.16f);
|
||||
entity.Set<float>("SqrMagnitude",Velocity.sqrMagnitude);
|
||||
UnityEntity.Set<bool>("IsMoving",Velocity.sqrMagnitude>=0.16f);
|
||||
UnityEntity.Set<float>("SqrMagnitude",Velocity.sqrMagnitude);
|
||||
|
||||
if (!isDead) return;
|
||||
|
||||
|
@@ -6,7 +6,7 @@ using UnityEngine.InputSystem;
|
||||
|
||||
namespace BITKit.Entities.Movement
|
||||
{
|
||||
public class RigidbodyBasedMovement : StateBasedComponent<IEntityMovementState>,IEntityMovement
|
||||
public class RigidbodyBasedMovement : StateBasedBehavior<IEntityMovementState>,IEntityMovement
|
||||
{
|
||||
[SerializeField] private new Rigidbody rigidbody;
|
||||
[SerializeField] private Animator animator;
|
||||
|
@@ -6,7 +6,7 @@ using UnityEngine;
|
||||
|
||||
namespace BITKit
|
||||
{
|
||||
public class AutoHealComponent : EntityComponent,IDamageCallback
|
||||
public class AutoHealBehavior : EntityBehavior,IDamageCallback
|
||||
{
|
||||
[SerializeField] private IntervalUpdate healDelayInterval;
|
||||
[SerializeField] private IntervalUpdate healInterval;
|
||||
@@ -16,12 +16,10 @@ namespace BITKit
|
||||
private IHealth _health;
|
||||
public override void OnStart()
|
||||
{
|
||||
_health = entity.Get<IHealth>();
|
||||
_health = UnityEntity.Get<IHealth>();
|
||||
|
||||
_health.OnSetAlive += OnSetAlive;
|
||||
_health.OnSetHealthPoint += OnSetHP;
|
||||
|
||||
entity.RegisterCallback<IDamageCallback>(this);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
|
@@ -8,7 +8,7 @@ using UnityEngine;
|
||||
|
||||
namespace BITKit
|
||||
{
|
||||
public class AutoRespawnComponent : EntityComponent,IAction
|
||||
public class AutoRespawnBehavior : EntityBehavior,IAction
|
||||
{
|
||||
[SerializeField] private IntervalUpdate respawnInterval;
|
||||
private bool requestRespawn;
|
||||
|
@@ -61,8 +61,8 @@ namespace BITKit.Entities
|
||||
}
|
||||
public record DamageMessage
|
||||
{
|
||||
public IEntity Initiator;
|
||||
public IEntity Target;
|
||||
public IUnityEntity Initiator;
|
||||
public IUnityEntity Target;
|
||||
public bool RawDamage;
|
||||
public int Damage;
|
||||
public IDamagable Hit;
|
||||
@@ -75,7 +75,7 @@ namespace BITKit.Entities
|
||||
}
|
||||
public interface IDamagable
|
||||
{
|
||||
IEntity Entity { get; }
|
||||
IUnityEntity UnityEntity { get; }
|
||||
Rigidbody Rigidbody { get; }
|
||||
void GiveDamage(DamageMessage message);
|
||||
}
|
||||
@@ -99,11 +99,6 @@ namespace BITKit.Entities
|
||||
damageMessage.Initiator?.Invoke(damageMessage);
|
||||
damageMessage.Target?.Invoke(damageMessage);
|
||||
|
||||
foreach (var x in damageMessage.Target?.GetCallbacks<IDamageCallback>()!)
|
||||
{
|
||||
x.OnGetDamage(damageMessage);
|
||||
}
|
||||
|
||||
OnEntityDamaged?.Invoke(damageMessage);
|
||||
if (heal.IsAlive is false)
|
||||
{
|
||||
|
@@ -26,7 +26,7 @@ namespace BITKit.Entities
|
||||
bool IsAlive { get; }
|
||||
}
|
||||
[CustomType(typeof(IHealth))]
|
||||
public class EntityHealth : EntityComponent, IHealth
|
||||
public class EntityHealth : EntityBehavior, IHealth
|
||||
{
|
||||
[Header(Constant.Header.Settings)]
|
||||
[SerializeField] private int healthPoint = 100;
|
||||
@@ -49,7 +49,7 @@ namespace BITKit.Entities
|
||||
public bool IsAlive { get; private set; }
|
||||
public override void OnAwake()
|
||||
{
|
||||
entity.AddListener<DamageMessage>(OnGetDamage);
|
||||
UnityEntity.AddListener<DamageMessage>(OnGetDamage);
|
||||
}
|
||||
|
||||
public override void OnStart()
|
||||
@@ -83,7 +83,7 @@ namespace BITKit.Entities
|
||||
|
||||
private void OnGetDamage(DamageMessage damageMessage)
|
||||
{
|
||||
if (damageMessage.Target != entity) return;
|
||||
if (damageMessage.Target != UnityEntity) return;
|
||||
if (IsAlive is false) return;
|
||||
var damage = damageMessage.Damage;
|
||||
foreach (var x in OnDamageFactory.CastAsFunc().Reverse())
|
||||
|
@@ -9,7 +9,7 @@ using UnityEngine.Events;
|
||||
|
||||
namespace BITKit.Entities
|
||||
{
|
||||
public class GetDamageComponent : EntityComponent
|
||||
public class GetDamageBehavior : EntityBehavior
|
||||
{
|
||||
private readonly Queue<DamageMessage> DamageMessages = new();
|
||||
[SerializeField] private UnityEvent<DamageMessage> onGetDamage;
|
||||
@@ -17,11 +17,11 @@ namespace BITKit.Entities
|
||||
private IDamageCallback[] callbacks;
|
||||
public override void OnAwake()
|
||||
{
|
||||
entity.AddListener<DamageMessage>(OnGetDamage);
|
||||
UnityEntity.AddListener<DamageMessage>(OnGetDamage);
|
||||
}
|
||||
private void OnGetDamage(DamageMessage obj)
|
||||
{
|
||||
if (obj.Target != entity) return;
|
||||
if (obj.Target != UnityEntity) return;
|
||||
DamageMessages.Enqueue(obj);
|
||||
onGetDamage?.Invoke(obj);
|
||||
foreach (var x in callbacks)
|
||||
|
@@ -4,13 +4,13 @@ using UnityEngine;
|
||||
using BITKit;
|
||||
namespace BITKit.Entities
|
||||
{
|
||||
public class EntityHitbox : EntityComponent,IDamagable
|
||||
public class EntityHitbox : EntityBehavior,IDamagable
|
||||
{
|
||||
IEntity IDamagable.Entity => entity;
|
||||
IUnityEntity IDamagable.UnityEntity => UnityEntity;
|
||||
public Rigidbody Rigidbody => m_rigidbody;
|
||||
public void GiveDamage(DamageMessage message)
|
||||
{
|
||||
entity.Invoke(message);
|
||||
UnityEntity.Invoke(message);
|
||||
}
|
||||
[SerializeField]private Rigidbody m_rigidbody;
|
||||
|
||||
|
@@ -7,7 +7,7 @@ using UnityEngine.UIElements;
|
||||
|
||||
namespace BITKit.Entities.InputSystem
|
||||
{
|
||||
public class EntityInputSystem : EntityComponent
|
||||
public class EntityInputSystem : EntityBehavior
|
||||
{
|
||||
protected readonly InputActionGroup inputActionGroup = new()
|
||||
{
|
||||
@@ -24,7 +24,7 @@ namespace BITKit.Entities.InputSystem
|
||||
public override void Initialize(IEntity _entity)
|
||||
{
|
||||
base.Initialize(_entity);
|
||||
_entity.AddService(inputActionGroup);
|
||||
UnityEntity.AddService(inputActionGroup);
|
||||
}
|
||||
|
||||
public override void OnAwake()
|
||||
|
@@ -7,7 +7,7 @@ using UnityEngine.InputSystem.Interactions;
|
||||
namespace BITKit.Entities.Player
|
||||
{
|
||||
[CustomType(typeof(ISelector))]
|
||||
public class EntityInteractive : EntityPlayerComponent,ISelector
|
||||
public class EntityInteractive : EntityPlayerBehavior,ISelector
|
||||
{
|
||||
[Header(Constant.Header.Settings)]
|
||||
[SerializeReference, SubclassSelector] private ISensor sensor;
|
||||
|
@@ -6,7 +6,7 @@ using UnityEngine.Events;
|
||||
using Cysharp.Threading.Tasks;
|
||||
namespace BITKit.Entities
|
||||
{
|
||||
public class EntityLocomotion : EntityComponent
|
||||
public class EntityLocomotion : EntityBehavior
|
||||
{
|
||||
[Header(Constant.Header.Settings)]
|
||||
|
||||
|
@@ -8,7 +8,7 @@ using UnityEngine;
|
||||
namespace BITKit.Entities
|
||||
{
|
||||
[CustomType(typeof(IEntityPhysics))]
|
||||
public class EntityPhysics : EntityComponent,IEntityPhysics
|
||||
public class EntityPhysics : EntityBehavior,IEntityPhysics
|
||||
{
|
||||
[SerializeField] private Animator animator;
|
||||
[SerializeField] private Rigidbody[] rigidbodies;
|
||||
@@ -29,7 +29,7 @@ namespace BITKit.Entities
|
||||
{
|
||||
_health.OnSetAlive += OnSetAlive;
|
||||
_health.OnSetHealthPoint += OnSetHP;
|
||||
_cancellationToken = entity.Get<CancellationToken>();
|
||||
_cancellationToken = UnityEntity.Get<CancellationToken>();
|
||||
foreach (var x in joints)
|
||||
{
|
||||
switch (x)
|
||||
|
@@ -6,7 +6,7 @@ using UnityEngine;
|
||||
namespace BITKit.Entities.Slot
|
||||
{
|
||||
[CustomType(typeof(IEntitySlot<Transform>))]
|
||||
public sealed class UnityEntitySlot : EntityComponent, IEntitySlot<Transform>
|
||||
public sealed class UnityEntitySlot : EntityBehavior, IEntitySlot<Transform>
|
||||
{
|
||||
[SerializeField] private SerializedDictionary<string,Transform> dictionary = new();
|
||||
public IDictionary<string, Transform> Slots => dictionary;
|
||||
|
@@ -5,7 +5,7 @@ using UnityEngine;
|
||||
|
||||
namespace BITKit.Entities
|
||||
{
|
||||
public class SlotComponent : EntityComponent
|
||||
public class SlotBehavior : EntityBehavior
|
||||
{
|
||||
public SerializedDictionary<string,Transform> slots;
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ using UnityEngine;
|
||||
|
||||
namespace BITKit.Entities.VFX
|
||||
{
|
||||
public class EntityVFXPlayer : EntityComponent
|
||||
public class EntityVFXPlayer : EntityBehavior
|
||||
{
|
||||
[SerializeReference,SubclassSelector] private IReference[] vfxReferences;
|
||||
[SerializeField] private VFXPlayer vfxPlayer;
|
||||
@@ -14,7 +14,7 @@ namespace BITKit.Entities.VFX
|
||||
{
|
||||
base.OnAwake();
|
||||
keyWords.AddRange(vfxReferences.Select(x=>x.Value));
|
||||
entity.AddListener<string>(Constant.Animation.Play, Play);
|
||||
UnityEntity.AddListener<string>(Constant.Animation.Play, Play);
|
||||
}
|
||||
|
||||
private void Play(string animationName)
|
||||
|
Reference in New Issue
Block a user