1
This commit is contained in:
@@ -21,9 +21,15 @@ namespace BITKit.Entities.Animation
|
||||
{
|
||||
base.OnAwake();
|
||||
_entityEquipment.OnEquipAddressable += OnEquip;
|
||||
_entityEquipment.OnUnEquipAddressable += UnEquip;
|
||||
_initialRuntimeAnimatorController = unityAnimator.animator.runtimeAnimatorController;
|
||||
}
|
||||
|
||||
private void UnEquip(string obj)
|
||||
{
|
||||
_runtimeAnimatorControllerBuffer.Release(_initialRuntimeAnimatorController);
|
||||
}
|
||||
|
||||
public override void OnLateUpdate(float deltaTime)
|
||||
{
|
||||
if(_runtimeAnimatorControllerBuffer.TryGetRelease(out var controller))
|
||||
|
@@ -6,18 +6,24 @@ using BITFALL.Entities.Inventory;
|
||||
using BITFALL.Items.Armor;
|
||||
using BITKit;
|
||||
using BITKit.Entities;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace BITFALL.Entities.Armor
|
||||
{
|
||||
[CustomType(typeof(IArmor))]
|
||||
public class EntityArmor : EntityBehavior,IArmor
|
||||
{
|
||||
[SerializeField] private Optional<int> initialArmor;
|
||||
|
||||
[SerializeField,HideInInspector] internal int currentArmor;
|
||||
|
||||
private int _armor;
|
||||
public int Armor
|
||||
{
|
||||
get => _armor;
|
||||
set=>OnArmorChanged?.Invoke(_armor = value);
|
||||
set=>OnArmorChanged?.Invoke(currentArmor = _armor = value);
|
||||
}
|
||||
|
||||
public bool TryGetCurrentArmor(out IBasicItem item)
|
||||
@@ -31,22 +37,38 @@ namespace BITFALL.Entities.Armor
|
||||
public event Action<IBasicItem> OnUnEquipArmor;
|
||||
|
||||
[Inject] private IHealth _health;
|
||||
[Inject] private IPlayerEquipSelector _playerEquipSelector;
|
||||
[Inject] private IEntityInventory _inventory;
|
||||
[Inject] private IEntityEquipmentContainer _equipmentContainer;
|
||||
|
||||
[Inject(true)] private IPlayerEquipSelector _playerEquipSelector;
|
||||
[Inject(true)] private IEntityInventory _inventory;
|
||||
[Inject(true)] private IEntityEquipmentContainer _equipmentContainer;
|
||||
|
||||
private IBasicItem _currentArmor;
|
||||
|
||||
public override void OnAwake()
|
||||
{
|
||||
base.OnAwake();
|
||||
_health.OnDamageFactory += OnDamageFactory;
|
||||
_inventory.OnUsedItem += OnUsedItem;
|
||||
|
||||
_equipmentContainer.OnEquip += OnEquip;
|
||||
_equipmentContainer.OnDeEquip += OnDeEquip;
|
||||
|
||||
_playerEquipSelector.TryEquipFactory += OnTryEquip;
|
||||
|
||||
if (_inventory is not null)
|
||||
_inventory.OnUsedItem += OnUsedItem;
|
||||
|
||||
if (_equipmentContainer is not null)
|
||||
{
|
||||
_equipmentContainer.OnEquip += OnEquip;
|
||||
_equipmentContainer.OnDeEquip += OnDeEquip;
|
||||
}
|
||||
|
||||
if (_playerEquipSelector is not null)
|
||||
_playerEquipSelector.TryEquipFactory += OnTryEquip;
|
||||
|
||||
}
|
||||
|
||||
public override void OnStart()
|
||||
{
|
||||
base.OnStart();
|
||||
if (initialArmor.Allow)
|
||||
{
|
||||
Armor = initialArmor.Value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool OnTryEquip(IBasicItem arg)
|
||||
@@ -91,7 +113,7 @@ namespace BITFALL.Entities.Armor
|
||||
}
|
||||
private int OnDamageFactory(DamageMessage arg1, int damage)
|
||||
{
|
||||
if (_currentArmor is null) return damage;
|
||||
if (_currentArmor is null && initialArmor.Allow is false) return damage;
|
||||
if (Armor is 0) return damage;
|
||||
if (damage > Armor)
|
||||
{
|
||||
@@ -102,5 +124,18 @@ namespace BITFALL.Entities.Armor
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[CustomEditor(typeof(EntityArmor))]
|
||||
public sealed class EntityArmorInspector:BITInspector<EntityArmor>
|
||||
{
|
||||
public override VisualElement CreateInspectorGUI()
|
||||
{
|
||||
FillDefaultInspector();
|
||||
var label = root.Create<Label>();
|
||||
|
||||
label.bindingPath = nameof(EntityArmor.currentArmor);
|
||||
return root;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -19,7 +19,9 @@
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"defineConstraints": [
|
||||
"STEAMWORKS_NET"
|
||||
],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
@@ -8,7 +8,6 @@ using BITKit;
|
||||
using BITKit.Entities;
|
||||
using BITKit.Steamwork;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
namespace BITFALL.Entities.Cosmetic
|
||||
{
|
||||
@@ -22,8 +21,8 @@ namespace BITFALL.Entities.Cosmetic
|
||||
public override async void OnStart()
|
||||
{
|
||||
base.OnStart();var items =await steamService.GetInventoryItemDefsAsync(destroyCancellationToken);
|
||||
Cosmetics = items.Select(itemDef => Addressables.LoadAssetAsync<ICosmetic>(itemDef.AddressablePath).WaitForCompletion()).ToArray();
|
||||
OnCosmeticsChanged?.Invoke();
|
||||
//Cosmetics = items.Select(itemDef => Addressables.LoadAssetAsync<ICosmetic>(itemDef.AddressablePath).WaitForCompletion()).ToArray();
|
||||
//OnCosmeticsChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -18,7 +18,8 @@
|
||||
"GUID:f6155d9ae143f3949ac54e8355593d6c",
|
||||
"GUID:d9ed46adfa0436d42b5f66480c967c74",
|
||||
"GUID:f51ebe6a0ceec4240a699833d6309b23",
|
||||
"GUID:48ef04d98836e2640bf90b524bdff904"
|
||||
"GUID:48ef04d98836e2640bf90b524bdff904",
|
||||
"GUID:96f476e982d6fb945bfc9140ba094b7f"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
@@ -12,6 +12,7 @@ using System.Threading.Tasks;
|
||||
using BITFALL.Entities;
|
||||
using BITFALL.Entities.Improvised;
|
||||
using BITFALL.Entities.Inventory;
|
||||
using BITFALL.Player.Equip;
|
||||
using BITFALL.Player.Inventory;
|
||||
using BITKit.Entities.Player;
|
||||
using Cysharp.Threading.Tasks;
|
||||
@@ -45,6 +46,9 @@ namespace BITFALL.Entities.Equipment
|
||||
private ImprovisedServiceInterface _improvisedService;
|
||||
[Inject]
|
||||
private IEntityEquipmentContainer _equipmentContainer;
|
||||
|
||||
[Inject]
|
||||
private IEquipService _equipService;
|
||||
|
||||
private readonly DoubleBuffer<IBasicItem> _cachedItem=new();
|
||||
|
||||
@@ -58,6 +62,17 @@ namespace BITFALL.Entities.Equipment
|
||||
_knockdown.OnKnockdown +=()=>
|
||||
{
|
||||
Equip(null);
|
||||
if (_equipService is not null)
|
||||
{
|
||||
_equipService.AllowEquip.AddDisableElements(this);
|
||||
}
|
||||
};
|
||||
_knockdown.OnRevive += () =>
|
||||
{
|
||||
if (_equipService is not null)
|
||||
{
|
||||
_equipService.AllowEquip.RemoveDisableElements(this);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -140,6 +155,7 @@ namespace BITFALL.Entities.Equipment
|
||||
}
|
||||
private void OnSetAlive(bool alive)
|
||||
{
|
||||
_equipService.AllowEquip.SetDisableElements(this,!alive);
|
||||
if (alive) return;
|
||||
foreach (var x in equips.ToArray())
|
||||
{
|
||||
@@ -151,6 +167,7 @@ namespace BITFALL.Entities.Equipment
|
||||
}
|
||||
private bool TryEquip(IBasicItem value)
|
||||
{
|
||||
if (_equipService.AllowEquip.Allow is false) return false;
|
||||
if (_knockdown is not null && _knockdown.IsKnockdown) return false;
|
||||
var asset = value.GetAssetable();
|
||||
if (_equipment.IsSupportItem(value) is false) return false;
|
||||
@@ -278,13 +295,14 @@ namespace BITFALL.Entities.Equipment
|
||||
|
||||
private void Equip(IBasicItem item)
|
||||
{
|
||||
|
||||
if (_equipService.AllowEquip.Allow is false) return;
|
||||
_equipment.EntryEquip(item);
|
||||
currentEquip = item;
|
||||
}
|
||||
|
||||
private bool Equip(int index)
|
||||
{
|
||||
if (_equipService.AllowEquip.Allow is false) return false;
|
||||
if (!equips.TryGetValue(index, out var x) && index is not -1) return false;
|
||||
if (_knockdown is not null && _knockdown.IsKnockdown) return false;
|
||||
currentEquip = x;
|
||||
@@ -301,5 +319,6 @@ namespace BITFALL.Entities.Equipment
|
||||
Equip(item.Value);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -80,6 +80,10 @@ namespace BITKit.Entities
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public virtual void Entered()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void Exit()
|
||||
{
|
||||
if (entityAnimator)
|
||||
@@ -93,15 +97,22 @@ namespace BITKit.Entities
|
||||
public virtual UniTask ExitAsync()
|
||||
{
|
||||
AllowRendering.RemoveElement(this);
|
||||
if (cameraTransform is not null)
|
||||
|
||||
if (animator)
|
||||
animator.enabled = false;
|
||||
|
||||
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public virtual async void Exited()
|
||||
{
|
||||
if (cameraTransform)
|
||||
{
|
||||
await UniTask.NextFrame(destroyCancellationToken);
|
||||
cameraTransform.localPosition = default;
|
||||
cameraTransform.localRotation = _initialCameraRotation;
|
||||
}
|
||||
|
||||
if (animator)
|
||||
animator.enabled = false;
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public virtual void OnAwake()
|
||||
@@ -110,7 +121,7 @@ namespace BITKit.Entities
|
||||
if (animator)
|
||||
animator.enabled = false;
|
||||
AllowRendering.Invoke();
|
||||
if (cameraTransform is not null)
|
||||
if (cameraTransform)
|
||||
_initialCameraRotation = cameraTransform.localRotation;
|
||||
Initialize();
|
||||
inputActionGroup.allowInput.Invoke();
|
||||
@@ -137,6 +148,7 @@ namespace BITKit.Entities
|
||||
case "Attack":
|
||||
meleeService.Melee(new MeleeCommand
|
||||
{
|
||||
|
||||
PlayerId = Entity.Id,
|
||||
Position = Transform.position,
|
||||
Force = meleeForce * equip.MeleeForce,
|
||||
@@ -185,6 +197,7 @@ namespace BITKit.Entities
|
||||
private IBasicItem _currentItem;
|
||||
|
||||
[Inject(true)] private IHealth _health;
|
||||
public IValidHandle AllowEquip { get; } =new ValidHandle();
|
||||
public override void OnAwake()
|
||||
{
|
||||
base.OnAwake();
|
||||
@@ -192,13 +205,19 @@ namespace BITKit.Entities
|
||||
|
||||
equips.OnEntry += OnEntry;
|
||||
equips.OnExit += OnExit;
|
||||
|
||||
|
||||
AllowEquip.AddListener(OnAllowEquip);
|
||||
|
||||
if (_health is not null)
|
||||
{
|
||||
_health.OnSetAlive += x =>
|
||||
{
|
||||
AllowEquip.SetElements(this,x);
|
||||
if (x is false)
|
||||
{
|
||||
_currentItem = null;
|
||||
EntryEquip(-1);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -209,7 +228,17 @@ namespace BITKit.Entities
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void OnAllowEquip(bool allow)
|
||||
{
|
||||
if (allow)
|
||||
{
|
||||
EntryEquip(_currentItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
EntryEquip(-1);
|
||||
}
|
||||
}
|
||||
public override void OnStart()
|
||||
{
|
||||
base.OnStart();
|
||||
@@ -217,8 +246,11 @@ namespace BITKit.Entities
|
||||
{
|
||||
x.OnStart();
|
||||
}
|
||||
if (overrideIndex.Allow && (_health?.IsAlive ?? true))
|
||||
{
|
||||
EntryEquip(overrideIndex.Value);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnExit(IEquipBase obj)
|
||||
{
|
||||
OnUnEquipAddressable?.Invoke(obj.AddressablePath);
|
||||
@@ -264,10 +296,7 @@ namespace BITKit.Entities
|
||||
optionalScope.Value.SetActive(AllowScope);
|
||||
}
|
||||
|
||||
if (overrideIndex.Allow && (_health?.IsAlive ?? true))
|
||||
{
|
||||
EntryEquip(overrideIndex.Value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public bool IsSupportItem(IBasicItem item)=> equips.list.Any(x => x.IsSupportItem(item));
|
||||
|
@@ -8,8 +8,6 @@ using BITFALL.Player.Inventory;
|
||||
using UnityEngine;
|
||||
using BITKit;
|
||||
using BITKit.Entities;
|
||||
using Unity.IO.LowLevel.Unsafe;
|
||||
using UnityEditor.Graphs;
|
||||
|
||||
namespace BITFALL
|
||||
{
|
||||
|
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "BITFALL.Entities.GameMode.Runtime",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:709caf8d7fb6ef24bbba0ab9962a3ad0",
|
||||
"GUID:e253a2890fcb65b44ab070f88710dbe8",
|
||||
"GUID:d525ad6bd40672747bde77962f1c401e",
|
||||
"GUID:49b49c76ee64f6b41bf28ef951cb0e50",
|
||||
"GUID:be8fc6f1c44f14943887ab6381170c28",
|
||||
"GUID:7efac18f239530141802fb139776f333",
|
||||
"GUID:d8b63aba1907145bea998dd612889d6b"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
33
Assets/Artists/Scripts/Entities/GameMode/EntitySpawnPoint.cs
Normal file
33
Assets/Artists/Scripts/Entities/GameMode/EntitySpawnPoint.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITFALL.Scene;
|
||||
using BITKit;
|
||||
using BITKit.Entities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITFALL.Entities.GameMode
|
||||
{
|
||||
public class EntitySpawnPoint : EntityBehavior
|
||||
{
|
||||
[SerializeReference, SubclassSelector, Inject]
|
||||
private ISpawnPointService _spawnPointService;
|
||||
|
||||
[Inject] private IEntityMovement _movement;
|
||||
public override void OnStart()
|
||||
{
|
||||
base.OnStart();
|
||||
try
|
||||
{
|
||||
Matrix4x4 spawnPoint = _spawnPointService.RequestSpawnPoint();
|
||||
_movement.Position = spawnPoint.GetPosition();
|
||||
_movement.Rotation = spawnPoint.rotation;
|
||||
}
|
||||
catch (ArgumentOutOfRangeException)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -10,7 +10,6 @@ using AYellowpaper.SerializedCollections;
|
||||
using BITFALL.Entities.Inventory;
|
||||
using BITKit.Entities.Slot;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
namespace BITFALL
|
||||
{
|
||||
@@ -157,7 +156,7 @@ namespace BITFALL
|
||||
protected void Drop(IBasicItem item)
|
||||
{
|
||||
OnDrop?.Invoke(item);
|
||||
var prefab = Addressables.LoadAssetAsync<AssetableItem>(item.AddressablePath).WaitForCompletion();
|
||||
var prefab = item.GetAssetable();
|
||||
var _transform = transform;
|
||||
var position = _transform.position;
|
||||
var rotation = _transform.rotation;
|
||||
|
@@ -39,7 +39,7 @@ namespace BITFALL
|
||||
}
|
||||
private void OnActive(ISelectable obj)
|
||||
{
|
||||
if (!obj.Transform.TryGetComponentAny<WorldItem>(out var item)) return;
|
||||
if (!obj.Transform.TryGetComponent<WorldItem>(out var item)) return;
|
||||
var _item = item.Pick();
|
||||
if(item.GetAssetable().IsImprovised)
|
||||
{
|
||||
|
@@ -15,6 +15,8 @@ namespace BITFALL.Entities
|
||||
{
|
||||
[SerializeField] private int knockedHealth;
|
||||
[SerializeField] private int initialKnockedHealth;
|
||||
|
||||
[SerializeField] private Optional<float> invincibilityTimes;
|
||||
|
||||
public int KnockedHealth=>knockedHealth;
|
||||
public int InitialKnockedHealth
|
||||
@@ -26,6 +28,7 @@ namespace BITFALL.Entities
|
||||
public event Action OnRevive;
|
||||
public bool IsKnockdown { get;private set; }
|
||||
private readonly Optional<int> knockedHeal=new();
|
||||
private readonly IntervalUpdate invincibilityInterval = new();
|
||||
|
||||
[Inject]
|
||||
private IHealth _health;
|
||||
@@ -64,8 +67,17 @@ namespace BITFALL.Entities
|
||||
|
||||
private int OnDamageFactory(DamageMessage arg,int currentDamage)
|
||||
{
|
||||
if (invincibilityTimes.Allow && invincibilityInterval.AllowUpdateWithoutReset is false)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (IsKnockdown || _health.HealthPoint - currentDamage >=0 ) return currentDamage;
|
||||
IsKnockdown = true;
|
||||
if (invincibilityTimes.Allow)
|
||||
{
|
||||
invincibilityInterval.Interval = invincibilityTimes.Value;
|
||||
invincibilityInterval.Reset();
|
||||
}
|
||||
OnKnockdown?.Invoke();
|
||||
_health.HealthPoint = 0;
|
||||
return 0;
|
||||
|
@@ -15,16 +15,27 @@ namespace BITKit.Entities
|
||||
|
||||
[Header(Constant.Header.Settings)]
|
||||
[SerializeField] private int damage=50;
|
||||
[SerializeField] private string[] ignoreTags;
|
||||
|
||||
|
||||
[SerializeReference, SubclassSelector, Inject(true)] private IMeleeService meleeService;
|
||||
[Inject(true)] private IEntityOverride entityOverride;
|
||||
private readonly IntervalUpdate disableMelee = new(0.64f);
|
||||
public override void OnStart()
|
||||
{
|
||||
UnityEntity.AddListener<int>("Melee", Melee);
|
||||
UnityEntity.AddListener<string>(AIAction);
|
||||
|
||||
unityAnimator[0].onStateEnter += OnStateEnter;
|
||||
|
||||
if (entityOverride is not null)
|
||||
{
|
||||
entityOverride.OnOverride += OnOverride;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnOverride(bool obj)
|
||||
{
|
||||
disableMelee.Reset();
|
||||
}
|
||||
|
||||
private void OnStateEnter(string obj)
|
||||
@@ -51,6 +62,8 @@ namespace BITKit.Entities
|
||||
}
|
||||
private void Melee(int _damage)
|
||||
{
|
||||
if (entityOverride.IsOvering) return;
|
||||
if (disableMelee.AllowUpdateWithoutReset is false) return;
|
||||
var forward = Transform.forward;
|
||||
meleeService.Melee(new MeleeCommand()
|
||||
{
|
||||
@@ -59,7 +72,8 @@ namespace BITKit.Entities
|
||||
Force = forward * 128,
|
||||
Range = 1.6f,
|
||||
Damage = _damage,
|
||||
Forward = forward
|
||||
Forward = forward,
|
||||
IgnoreTags = ignoreTags,
|
||||
});
|
||||
unityAnimator.Play("Attack");
|
||||
//entity.Invoke(Constant.Animation.Play, "Melee");
|
||||
|
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "BITFALL.Entities.Movement.Runtime",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:87bea3a21c744b1478660b70494160ba",
|
||||
"GUID:709caf8d7fb6ef24bbba0ab9962a3ad0",
|
||||
"GUID:7efac18f239530141802fb139776f333",
|
||||
"GUID:75469ad4d38634e559750d17036d5f7c"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
141
Assets/Artists/Scripts/Entities/Movement/NavAgentMovement.cs
Normal file
141
Assets/Artists/Scripts/Entities/Movement/NavAgentMovement.cs
Normal file
@@ -0,0 +1,141 @@
|
||||
using System;
|
||||
using BITFALL;
|
||||
using BITKit.Entities;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace BITKit
|
||||
{
|
||||
[CustomType(typeof(IEntityMovement))]
|
||||
public class NavAgentMovement: StateBasedBehavior<IEntityMovementState>,IEntityMovement
|
||||
{
|
||||
#region 属性
|
||||
[SerializeField] private NavMeshAgent agent;
|
||||
[SerializeField] private new Rigidbody rigidbody;
|
||||
|
||||
[Inject] private IHealth _health;
|
||||
|
||||
[Inject(true)] private IEntityOverride _override;
|
||||
#endregion
|
||||
|
||||
public override void OnStart()
|
||||
{
|
||||
if (_override is not null)
|
||||
{
|
||||
_override.OnOverride += (x) =>
|
||||
{
|
||||
agent.isStopped = x;
|
||||
};
|
||||
}
|
||||
|
||||
_health.OnSetAlive += OnSetAlive;
|
||||
_health.OnSetHealthPoint += OnSetHP;
|
||||
|
||||
recordRotation = Transform.rotation;
|
||||
recordPosition = Transform.position;
|
||||
|
||||
}
|
||||
|
||||
#region 接口实现
|
||||
|
||||
public Vector3 Position
|
||||
{
|
||||
get=>transform.position;
|
||||
set=>transform.position=value;
|
||||
}
|
||||
|
||||
public Quaternion Rotation
|
||||
{
|
||||
get=>transform.rotation;
|
||||
set=>transform.rotation=value;
|
||||
}
|
||||
|
||||
public Vector3 Forward => transform.forward;
|
||||
public Vector3 ViewCenter => transform.position + Vector3.up;
|
||||
public Quaternion ViewRotation => transform.rotation;
|
||||
public Vector3 LocomotionBasedVelocity { get; private set; }
|
||||
public Vector3 Velocity { get; private set; }
|
||||
public Vector3 GroundVelocity { get; private set; }
|
||||
public Vector3 AngularVelocity { get; private set; }
|
||||
public bool IsGrounded { get; private set; }
|
||||
private bool isDead;
|
||||
private Vector3 recordPosition;
|
||||
private Quaternion recordRotation;
|
||||
private IEntityMovement _entityMovementImplementation;
|
||||
#endregion
|
||||
public override void OnUpdate(float deltaTime)
|
||||
{
|
||||
Velocity = agent.velocity;
|
||||
var _groundVelocity = Velocity;
|
||||
_groundVelocity.y = 0;
|
||||
GroundVelocity = _groundVelocity;
|
||||
IsGrounded = agent.isOnOffMeshLink is false;
|
||||
|
||||
//UnityEntity.Set<bool>("IsMoving",Velocity.sqrMagnitude>=0.16f);
|
||||
//UnityEntity.Set<float>("SqrMagnitude",Velocity.sqrMagnitude);
|
||||
|
||||
UnityEntity.SetDirect(BITHash.Player.IsMoving,Velocity.sqrMagnitude>=0.16f);
|
||||
UnityEntity.SetDirect(BITHash.Player.SqrMagnitude,Velocity.sqrMagnitude);
|
||||
|
||||
if (!isDead) return;
|
||||
|
||||
recordPosition = rigidbody.position;
|
||||
recordRotation = rigidbody.rotation * transform.rotation;
|
||||
}
|
||||
public void SyncMovement(Vector3 velocity, Vector3 position, Quaternion rotation, bool isGrounded)
|
||||
{
|
||||
|
||||
}
|
||||
public void Movement(Vector3 relativeVector)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Movement(InputAction.CallbackContext context)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void ExecuteCommand<T>(T command)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public event Action<object> OnCommand;
|
||||
|
||||
public void OnSetAlive(bool alive)
|
||||
{
|
||||
switch (alive)
|
||||
{
|
||||
case false:
|
||||
isDead = true;
|
||||
break;
|
||||
case true when isDead:
|
||||
{
|
||||
var _transform = transform;
|
||||
_transform.position = new Vector3()
|
||||
{
|
||||
x=recordPosition.x,
|
||||
y=0,
|
||||
z=recordPosition.x,
|
||||
};
|
||||
rigidbody.position = recordPosition;
|
||||
|
||||
_transform.rotation *= recordRotation;
|
||||
|
||||
rigidbody.rotation = recordRotation;
|
||||
|
||||
isDead = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnSetHP(int hp)
|
||||
{
|
||||
}
|
||||
public void FootStep(){}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "BITFALL.Entities.Placement.Runtime",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:87bea3a21c744b1478660b70494160ba",
|
||||
"GUID:d525ad6bd40672747bde77962f1c401e",
|
||||
"GUID:49b49c76ee64f6b41bf28ef951cb0e50",
|
||||
"GUID:a83bfc00a1ad8e74981b456e6c50ed4e",
|
||||
"GUID:709caf8d7fb6ef24bbba0ab9962a3ad0"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITFALL.Placement;
|
||||
using BITKit;
|
||||
using BITKit.Entities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITFALL.Entities.Placement
|
||||
{
|
||||
[CustomType(typeof(IPlacementService))]
|
||||
public class EntityPlacementService : EntityBehavior,IPlacementService
|
||||
{
|
||||
[SerializeReference, SubclassSelector] private IPlacementService _placementService;
|
||||
public IPlacementObject[] PlacementObjects { get; private set; }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user