更改文件架构
This commit is contained in:
8
Packages/Common~/Scripts/Entity/Components/Animator.meta
Normal file
8
Packages/Common~/Scripts/Entity/Components/Animator.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b4fde328ab58e8b47a0ce6bf1a6975ec
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,69 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Sirenix.OdinInspector;
|
||||
using Sirenix.Serialization;
|
||||
using UnityEngine.Events;
|
||||
using System.Linq;
|
||||
namespace BITKit.Entities
|
||||
{
|
||||
|
||||
public class EntityAnimator : EntityComponent
|
||||
{
|
||||
public Animator[] animators;
|
||||
[SerializeReference, SubclassSelector] public References[] animationKeyWords;
|
||||
[SerializeReference, SubclassSelector] public References _rootVelocity;
|
||||
[SerializeReference, SubclassSelector] public References[] boolParameters;
|
||||
[SerializeReference, SubclassSelector] public References[] floatParameters;
|
||||
List<string> keyWords;
|
||||
public override void OnAwake()
|
||||
{
|
||||
keyWords = animationKeyWords.Select(x => x.Get()).ToList();
|
||||
}
|
||||
public override void OnStart()
|
||||
{
|
||||
entity.AddListener<string>(Constant.Animation.Play, Play);
|
||||
}
|
||||
protected virtual void Play(string name)
|
||||
{
|
||||
if (animationKeyWords.Length is 0 || keyWords.Contains(name))
|
||||
{
|
||||
animators.ForEach(x =>
|
||||
{
|
||||
if (x.isActiveAndEnabled)
|
||||
{
|
||||
name = name.Replace(".", "_");
|
||||
x.SetTrigger(name);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
public override void OnFixedUpdate(float deltaTime)
|
||||
{
|
||||
foreach (var boolPar in boolParameters)
|
||||
{
|
||||
animators.ForEach(x =>
|
||||
{
|
||||
if (x.isActiveAndEnabled)
|
||||
x.SetBool(boolPar, entity.Get<bool>(boolPar));
|
||||
});
|
||||
}
|
||||
foreach (var floatPar in floatParameters)
|
||||
{
|
||||
animators.ForEach(x =>
|
||||
{
|
||||
if (x.isActiveAndEnabled)
|
||||
x.SetFloat(floatPar, entity.Get<float>(floatPar));
|
||||
});
|
||||
}
|
||||
}
|
||||
void OnAnimatorMove()
|
||||
{
|
||||
entity.Set(_rootVelocity, animators[0].velocity);
|
||||
}
|
||||
void AnimationEvent(string name)
|
||||
{
|
||||
entity.Invoke(Constant.Animation.OnEvent, name);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ac2d465b526bc94fa8ecba1c434c884
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9bec9df3bf214a347a6c126c8c1c60f7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,28 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using BITKit.Sensors;
|
||||
namespace BITKit.Entities
|
||||
{
|
||||
public class EntityAudioObject : EntityComponent, IAudioObject
|
||||
{
|
||||
float volume;
|
||||
public override void OnStart()
|
||||
{
|
||||
entity.AddListener<AudioSO>(OnAuioSO);
|
||||
}
|
||||
public override void OnFixedUpdate(float deltaTime)
|
||||
{
|
||||
volume = Mathf.Lerp(volume, 0, deltaTime);
|
||||
}
|
||||
public float GetVolume()
|
||||
{
|
||||
return volume;
|
||||
}
|
||||
void OnAuioSO(AudioSO so)
|
||||
{
|
||||
if (so.distance > volume)
|
||||
volume = so.distance;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d6c28a6107497be44bfecb5e31b960c5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "Entity.Component",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:a209c53514018594f9f482516f2a6781",
|
||||
"GUID:709caf8d7fb6ef24bbba0ab9962a3ad0",
|
||||
"GUID:677cd05ca06c46b4395470200b1acdad",
|
||||
"GUID:75469ad4d38634e559750d17036d5f7c",
|
||||
"GUID:66d2ae14764cc7d49aad4b16930747c0",
|
||||
"GUID:508392158bd966c4d9c21e19661a441d",
|
||||
"GUID:f51ebe6a0ceec4240a699833d6309b23",
|
||||
"GUID:99a47d73d3ad3374b9d12c982228df71",
|
||||
"GUID:49b49c76ee64f6b41bf28ef951cb0e50",
|
||||
"GUID:274d4ecae4648e94c8b2cee7218378a0",
|
||||
"GUID:1491147abca9d7d4bb7105af628b223e",
|
||||
"GUID:28c2d6a6727d47442a24a353f0d37846",
|
||||
"GUID:be17a8778dbfe454890ed8279279e153",
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:9400d40641bab5b4a9702f65bf5c6eb5"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [
|
||||
"RH_SerializedDictionary"
|
||||
],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7efac18f239530141802fb139776f333
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Packages/Common~/Scripts/Entity/Components/Camera.meta
Normal file
8
Packages/Common~/Scripts/Entity/Components/Camera.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 883da760381ed614e99f02f2d26c028a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,31 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
namespace BITKit.Entities
|
||||
{
|
||||
public class EntityCamera : EntityComponent
|
||||
{
|
||||
[Header(Constant.Header.Components)]
|
||||
public Behaviour aliveCamera;
|
||||
public Behaviour deathCamera;
|
||||
[Header(Constant.Header.Reference)]
|
||||
[SerializeReference, SubclassSelector] public IReference _onSetAlive;
|
||||
public override void OnSpawn()
|
||||
{
|
||||
if (isLocalPlayer)
|
||||
{
|
||||
OnSetAlive(true);
|
||||
}
|
||||
}
|
||||
public override void OnDespawn()
|
||||
{
|
||||
aliveCamera.enabled = deathCamera.enabled = false;
|
||||
}
|
||||
void OnSetAlive(bool alive)
|
||||
{
|
||||
aliveCamera.enabled = alive;
|
||||
deathCamera.enabled = alive is false;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f365362d94a8f5e4bb2db35408e7eec5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80d35d9e6778dc84b88662124834dd35
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,61 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using Sirenix.OdinInspector;
|
||||
using DG.Tweening;
|
||||
namespace BITKit.Entities
|
||||
{
|
||||
public class EntityCharacter : EntityComponent
|
||||
{
|
||||
[Header(Constant.Header.Components)]
|
||||
public List<Renderer> fpvRenderer = new();
|
||||
public List<Renderer> tpvRenderer = new();
|
||||
[Header(Constant.Header.Reference)]
|
||||
[SerializeReference, SubclassSelector] public References _isAlive;
|
||||
[SerializeReference, SubclassSelector] public References _getDamage;
|
||||
|
||||
public override void OnStart()
|
||||
{
|
||||
entity.AddListener<bool>(nameof(OnSetAlive), OnSetAlive);
|
||||
entity.AddListener<int>(nameof(OnSetHP), OnSetHP);
|
||||
}
|
||||
public override void OnSpawn()
|
||||
{
|
||||
if (isLocalPlayer)
|
||||
{
|
||||
OnSetAlive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetFPV(false);
|
||||
}
|
||||
}
|
||||
public override void OnDespawn()
|
||||
{
|
||||
SetFPV(false);
|
||||
}
|
||||
void OnSetAlive(bool alive)
|
||||
{
|
||||
SetFPV(isLocalPlayer ? alive : false);
|
||||
}
|
||||
void OnSetHP(int hp)
|
||||
{
|
||||
entity.Invoke<string>(Constant.Animation.Play, _getDamage);
|
||||
}
|
||||
void SetFPV(bool isFpv)
|
||||
{
|
||||
var shadowMode = isFpv ?
|
||||
ShadowCastingMode.ShadowsOnly :
|
||||
ShadowCastingMode.On;
|
||||
foreach (var x in fpvRenderer)
|
||||
{
|
||||
x.enabled = isFpv;
|
||||
}
|
||||
foreach (var x in tpvRenderer)
|
||||
{
|
||||
x.shadowCastingMode = shadowMode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c8cf20e38c0584247ab1573e085274d4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Packages/Common~/Scripts/Entity/Components/Data.meta
Normal file
8
Packages/Common~/Scripts/Entity/Components/Data.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de6a534eab93cbd4cacc9e47267c621b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94fb6a438f7165740b571fca593b3a44
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,69 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace BITKit.Entities
|
||||
{
|
||||
[System.Serializable]
|
||||
public struct ExpectState<T>
|
||||
{
|
||||
public T shouldBe;
|
||||
public T being;
|
||||
public T force;
|
||||
public static implicit operator T(ExpectState<T> value)
|
||||
{
|
||||
return value.being;
|
||||
}
|
||||
public void Reset()
|
||||
{
|
||||
shouldBe = being = force = default;
|
||||
}
|
||||
public void Release()
|
||||
{
|
||||
being = shouldBe;
|
||||
}
|
||||
public void Release(T value)
|
||||
{
|
||||
force = default;
|
||||
being = shouldBe = value;
|
||||
}
|
||||
}
|
||||
public interface IEntityMovement
|
||||
{
|
||||
void SyncMovement(Vector3 velocity, Vector3 position,Quaternion rotation,bool isGrounded);
|
||||
}
|
||||
public class EntityMovement : EntityInputComponent, IEntityMovement
|
||||
{
|
||||
Vector2 inputVector;
|
||||
public override void OnMovement(InputAction.CallbackContext context)
|
||||
{
|
||||
inputVector = context.ReadValue<Vector2>();
|
||||
inputVector = Vector2.ClampMagnitude(inputVector, 1);
|
||||
}
|
||||
public override void OnFixedUpdate(float deltaTime)
|
||||
{
|
||||
transform.position += (Vector3)inputVector * deltaTime;
|
||||
}
|
||||
|
||||
public void SyncMovement(Vector3 velocity, Vector3 position, Quaternion rotation, bool isGrounded)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public interface IMovementCallback { }
|
||||
public record MovementCallback : IMovementCallback
|
||||
{
|
||||
public bool started;
|
||||
public bool updated;
|
||||
public bool canceled;
|
||||
}
|
||||
public record OnRunCallback : MovementCallback { }
|
||||
public record OnClimbCallback : MovementCallback { }
|
||||
|
||||
public interface IMovementCancelAction { }
|
||||
public record MovementCancelAction : IMovementCancelAction { }
|
||||
public record CancelMovement : MovementCancelAction { }
|
||||
public record CancelMovementAction : MovementCancelAction { }
|
||||
public record CancelRunOrSprint : MovementCancelAction { }
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82b7931901a86634a9ab2067830bed0d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,12 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using BITKit.Entities;
|
||||
using BITKit.StateMachine;
|
||||
namespace BITKit
|
||||
{
|
||||
public interface IEntityMovementState : IState
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 40a4ded154ef74d4283c8f4d78424f44
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 632d0b190624f7f46971923e4fedffcb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,61 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using BITKit;
|
||||
using BITKit.Animations;
|
||||
using BITKit.StateMachine;
|
||||
using System.Linq;
|
||||
namespace BITKit.Entities
|
||||
{
|
||||
public interface IEquipBase : IEntryElement, IAwake, IStart, IUpdate
|
||||
{
|
||||
public const string _Equip = "Equip";
|
||||
string AddressablePath { get; }
|
||||
IEntity Entity { get; set; }
|
||||
void PlayAudio(string name);
|
||||
}
|
||||
public abstract class BITEquipBase<T> : MonoBehaviour, IEquipBase where T : IState
|
||||
{
|
||||
[Header(Constant.Header.Components)]
|
||||
public UnityAnimator animator;
|
||||
[Header(Constant.Header.InternalVariables)]
|
||||
protected IEntity entity;
|
||||
public IEntity Entity { get => entity; set => entity = value; }
|
||||
public virtual string AddressablePath => throw new System.NotImplementedException();
|
||||
public virtual void Entry() { }
|
||||
public virtual void Exit() { }
|
||||
public virtual void OnAwake() { }
|
||||
public virtual void OnStart() { }
|
||||
public virtual void OnUpdate(float deltaTime) { }
|
||||
public virtual void PlayAudio(string name) { }
|
||||
}
|
||||
public class EntityEquipment : EntityComponent
|
||||
{
|
||||
public EntryGroup<IEquipBase> equips = new();
|
||||
IEquipBase entrid;
|
||||
public override void OnStart()
|
||||
{
|
||||
base.OnStart();
|
||||
equips.list = GetComponentsInChildren<IEquipBase>(true).ToList();
|
||||
foreach (var x in equips.list)
|
||||
{
|
||||
x.Entity = entity;
|
||||
x.OnAwake();
|
||||
}
|
||||
foreach (var x in equips.list)
|
||||
{
|
||||
x.OnStart();
|
||||
}
|
||||
}
|
||||
public override void OnUpdate(float deltaTime)
|
||||
{
|
||||
if (isLocalPlayer)
|
||||
{
|
||||
if (equips.TryGetEntried(out entrid))
|
||||
{
|
||||
entrid.OnUpdate(deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d61f8d5d7b83b1941831e20da974aa54
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Packages/Common~/Scripts/Entity/Components/Health.meta
Normal file
8
Packages/Common~/Scripts/Entity/Components/Health.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36df5b126840e4d48b000257a409f700
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,78 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
namespace BITKit.Entities
|
||||
{
|
||||
public interface IHealthCallback
|
||||
{
|
||||
void OnSetAlive(bool alive);
|
||||
void OnSetHP(int hp);
|
||||
}
|
||||
public class EntityHealth : EntityComponent
|
||||
{
|
||||
[Header(Constant.Header.Settings)]
|
||||
public int healthPoint = 100;
|
||||
[Header(Constant.Header.Events)]
|
||||
public UnityEvent<bool> onSetAlive = new();
|
||||
[Header(Constant.Header.InternalVariables)]
|
||||
bool isAlive;
|
||||
public override void OnAwake()
|
||||
{
|
||||
entity.AddListener<DamageMessage>(OnDamage);
|
||||
}
|
||||
public override void OnStart()
|
||||
{
|
||||
isAlive = healthPoint >= 0;
|
||||
OnSetAlive(isAlive);
|
||||
OnHealthPointChanged(0, healthPoint);
|
||||
}
|
||||
void OnHealthPointChanged(int old, int newHP)
|
||||
{
|
||||
var _isAlive = newHP >= 0;
|
||||
if (_isAlive != isAlive)
|
||||
{
|
||||
OnSetAlive(isAlive = _isAlive);
|
||||
}
|
||||
//entity.Invoke<int>(_onSetHP, newHP);
|
||||
//entity.Set<int>("HP", newHP);
|
||||
foreach (var x in entity.GetCallbacks<IHealthCallback>())
|
||||
{
|
||||
x.OnSetHP(newHP);
|
||||
}
|
||||
}
|
||||
void OnSetAlive(bool alive)
|
||||
{
|
||||
foreach (var x in entity.GetCallbacks<IHealthCallback>())
|
||||
{
|
||||
x.OnSetAlive(alive);
|
||||
}
|
||||
//entity.Invoke<bool>(_onSetAlive, alive);
|
||||
//entity.Set<bool>(_isAlive, alive);
|
||||
onSetAlive.Invoke(alive);
|
||||
}
|
||||
void AddHP(int hp)
|
||||
{
|
||||
OnHealthPointChanged(healthPoint, healthPoint += hp);
|
||||
}
|
||||
void OnDamage(DamageMessage damageMessage)
|
||||
{
|
||||
if (damageMessage.target == entity)
|
||||
AddHP(-damageMessage.damage);
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
[BIT]
|
||||
public void SetAlive()
|
||||
{
|
||||
BITAppForUnity.ThrowIfNotPlaying();
|
||||
OnHealthPointChanged(-1, 100);
|
||||
}
|
||||
[BIT]
|
||||
public void SetDead()
|
||||
{
|
||||
BITAppForUnity.ThrowIfNotPlaying();
|
||||
OnHealthPointChanged(100, -1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 085a82cd092152541adfdf24c9f42394
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Packages/Common~/Scripts/Entity/Components/Hitbox.meta
Normal file
8
Packages/Common~/Scripts/Entity/Components/Hitbox.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e17d164170f8304a92ced6bf8582ae4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,19 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using BITKit;
|
||||
namespace BITKit.Entities
|
||||
{
|
||||
public class EntityHitbox : EntityComponent, IDamagable
|
||||
{
|
||||
public IEntity Entity => entity;
|
||||
|
||||
public Rigidbody Rigidbody => m_rigidbody;
|
||||
|
||||
public Rigidbody m_rigidbody;
|
||||
public void GiveDamage(DamageMessage message)
|
||||
{
|
||||
entity.Invoke<DamageMessage>(message);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 06d0b06a318b6bb47b8704dd2d138598
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Packages/Common~/Scripts/Entity/Components/HotFix.meta
Normal file
8
Packages/Common~/Scripts/Entity/Components/HotFix.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3614fcbb2ebe14e418eadf82d1c67870
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,43 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using BITKit;
|
||||
namespace BITKit.Entities
|
||||
{
|
||||
public class EntityLocalPlayer : EntityComponent
|
||||
{
|
||||
public override void OnStart()
|
||||
{
|
||||
base.OnStart();
|
||||
entity.Set<bool>(nameof(EntityComponent.isLocalPlayer), true);
|
||||
if (isSpawned is false)
|
||||
{
|
||||
foreach (var x in GetComponentsInChildren<IEntityComponent>(true))
|
||||
{
|
||||
x.OnSpawn();
|
||||
}
|
||||
entity.Set<bool>(nameof(isSpawned), true);
|
||||
}
|
||||
IEntity.LocalPlayer = entity;
|
||||
IEntity.OnSpawnLocalPlayer.Invoke(entity);
|
||||
}
|
||||
public override void OnDestroyComponent()
|
||||
{
|
||||
base.OnDestroyComponent();
|
||||
if (isSpawned)
|
||||
{
|
||||
foreach (var x in GetComponentsInChildren<IEntityComponent>(true))
|
||||
{
|
||||
x.OnDespawn();
|
||||
}
|
||||
entity.Set<bool>(nameof(isSpawned), false);
|
||||
}
|
||||
IEntity.LocalPlayer = null;
|
||||
}
|
||||
public override void OnSpawn()
|
||||
{
|
||||
BIT4Log.Log<EntityLocalPlayer>("已创建本地玩家");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d2434312d3046294b8c91f033e26d294
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Packages/Common~/Scripts/Entity/Components/Impact.meta
Normal file
8
Packages/Common~/Scripts/Entity/Components/Impact.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5abcbda5d8b2bed448fd38fed4acf912
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit.Entities
|
||||
{
|
||||
public class EntityImpact : EntityComponent, IPhysicsImpact
|
||||
{
|
||||
public void AddImpact(Vector3 force)
|
||||
{
|
||||
var damage = (int)(-force.sqrMagnitude);
|
||||
entity.Invoke<int>("AddHP", damage);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b0de804778e2b44f89439d8721623e1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd17148b1ccd451409b7de09986a1805
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,116 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.InputSystem.Interactions;
|
||||
using BITKit;
|
||||
namespace BITKit.Entities
|
||||
{
|
||||
public class EntityInteractive : EntityInputComponent
|
||||
{
|
||||
[Header(Constant.Header.Settings)]
|
||||
public float distance;
|
||||
public LayerMask layerMask;
|
||||
[Header(Constant.Header.Input)]
|
||||
public InputActionReference interactiveAction;
|
||||
InputActionGroup inputActionGroup = new();
|
||||
[Header(Constant.Header.InternalVariables)]
|
||||
ISelectable selected;
|
||||
IntervalUpdate cd = new(0.08f);
|
||||
public override void OnStart()
|
||||
{
|
||||
base.OnStart();
|
||||
}
|
||||
public override void OnSpawn()
|
||||
{
|
||||
base.OnSpawn();
|
||||
if (isLocalPlayer)
|
||||
{
|
||||
inputActionGroup.RegisterCallback(interactiveAction, OnInteractive);
|
||||
}
|
||||
}
|
||||
public override void OnDespawn()
|
||||
{
|
||||
base.OnDespawn();
|
||||
if (isLocalPlayer)
|
||||
{
|
||||
inputActionGroup.UnRegisterCallback(interactiveAction, OnInteractive);
|
||||
}
|
||||
}
|
||||
public override void OnUpdate(float deltaTime)
|
||||
{
|
||||
if (isLocalPlayer)
|
||||
{
|
||||
var ray = Camera.main.ScreenPointToRay(Mouse.current.position.ReadValue());
|
||||
if (Physics.Raycast(ray, out var raycastHit, distance, layerMask))
|
||||
{
|
||||
if (raycastHit.transform.TryGetComponentAny<ISelectable>(out var _detected))
|
||||
{
|
||||
if (_detected == selected)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
TryDeSelected();
|
||||
|
||||
Detected(_detected);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TryDeSelected();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TryDeSelected();
|
||||
}
|
||||
}
|
||||
}
|
||||
void TryDeSelected()
|
||||
{
|
||||
if (selected is not null)
|
||||
{
|
||||
selected.SetSelectionState(SelectionState.None);
|
||||
foreach (var x in entity.GetCallbacks<ISelectableCallback>())
|
||||
{
|
||||
x.OnInactive(selected);
|
||||
}
|
||||
selected = null;
|
||||
}
|
||||
}
|
||||
void Detected(ISelectable detected)
|
||||
{
|
||||
selected = detected;
|
||||
detected.SetSelectionState(SelectionState.Hover);
|
||||
foreach (var x in entity.GetCallbacks<ISelectableCallback>())
|
||||
{
|
||||
x.OnHover(selected);
|
||||
}
|
||||
}
|
||||
public override void OnInteractive(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.interaction is TapInteraction && context.performed)
|
||||
{
|
||||
var selected = this.selected;
|
||||
if (selected is not null)
|
||||
{
|
||||
|
||||
if (selected is MonoBehaviour monoBehaviour)
|
||||
{
|
||||
if (monoBehaviour.TryGetComponentAny<IAction>(out var action))
|
||||
{
|
||||
action.Excute();
|
||||
}
|
||||
foreach (var x in entity.GetCallbacks<ISelectableCallback>())
|
||||
{
|
||||
x.OnActive(selected);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8de7270cf1d43f64fafdc3413158cea3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 39922d0b63bb41347b2be6ef442328ab
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Sirenix.OdinInspector;
|
||||
using System.Linq;
|
||||
using UnityEngine.Events;
|
||||
using Cysharp.Threading.Tasks;
|
||||
namespace BITKit.Entities
|
||||
{
|
||||
public class EntityLocomotion : EntityComponent
|
||||
{
|
||||
[Header(Constant.Header.Settings)]
|
||||
|
||||
[Header(Constant.Header.Components)]
|
||||
public Animator animator;
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 35b16d24a5a5203488f21afd0cb7b161
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Packages/Common~/Scripts/Entity/Components/Melee.meta
Normal file
8
Packages/Common~/Scripts/Entity/Components/Melee.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e8173f883ff93344db922487c65da5fa
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,36 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit.Entities
|
||||
{
|
||||
public interface IEntityMelee
|
||||
{
|
||||
void Excute();
|
||||
}
|
||||
public class EntityMelee : EntityComponent
|
||||
{
|
||||
[Header(Constant.Header.Settings)]
|
||||
public int damage=50;
|
||||
public bool singleTarget;
|
||||
public override void OnStart()
|
||||
{
|
||||
entity.AddListener<int>("Melee", Melee);
|
||||
}
|
||||
public virtual void Excute()
|
||||
{
|
||||
Melee(damage);
|
||||
}
|
||||
public virtual void AIAction(string actionName)
|
||||
{
|
||||
switch (actionName)
|
||||
{
|
||||
case "Melee":
|
||||
Excute();
|
||||
break;
|
||||
}
|
||||
}
|
||||
protected virtual void Melee(int damage)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 08c479c2ef329e94aaac1cc920eb8ce1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Packages/Common~/Scripts/Entity/Components/Physics.meta
Normal file
8
Packages/Common~/Scripts/Entity/Components/Physics.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b8ff0f400ff5fd44b5205e0adaa1969
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit.Entities
|
||||
{
|
||||
public class EntityPhysics : EntityComponent, IHealthCallback
|
||||
{
|
||||
public Animator animator;
|
||||
public Rigidbody[] rigidbodies;
|
||||
public Collider[] ragdollColliders;
|
||||
public override void OnStart()
|
||||
{
|
||||
entity.RegisterCallback<IHealthCallback>(this);
|
||||
}
|
||||
void IHealthCallback.OnSetAlive(bool alive)
|
||||
{
|
||||
if(animator)
|
||||
animator.enabled = alive;
|
||||
rigidbodies.ForEach(x =>
|
||||
{
|
||||
x.isKinematic = alive;
|
||||
});
|
||||
ragdollColliders.ForEach(x =>
|
||||
{
|
||||
x.enabled = !alive;
|
||||
});
|
||||
}
|
||||
public void OnSetHP(int hp)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c78fe9fd58f5efc4abdeb6d193bf258b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user