This commit is contained in:
CortexCore
2023-10-29 15:27:13 +08:00
parent c5f638d9d2
commit c7b6ddbf70
73 changed files with 2158 additions and 494 deletions

View File

@@ -18,8 +18,8 @@ namespace BITFALL
public record InstanceBullet : SpawnBullet
{
public Vector3 currentPos;
public float InitialForce;
public float currentSpeed = 64;
public float ElapsedTime;
public BITBullet model;
}
[Serializable]
@@ -43,7 +43,7 @@ namespace BITFALL
private IDamageService damageService;
[Header(Constant.Header.Settings)]
public UnityPool<BITBullet> pool = new();
[SerializeField] private UnityPool<BITBullet> pool = new();
[Header(Constant.Header.InternalVariables)]
private readonly List<InstanceBullet> instances = new();
@@ -77,9 +77,15 @@ namespace BITFALL
}
else
{
// 计算子弹的下坠距离
float distance = 0.5f * Physics.gravity.y * bullet.ElapsedTime * bullet.ElapsedTime;
bullet.currentSpeed -= bullet.startSpeed * Time.fixedDeltaTime;
bullet.currentPos += (Vector3)bullet.forward * (bullet.currentSpeed * Time.fixedDeltaTime);
bullet.currentPos += Vector3.up * distance;
bullet.model.transform.position = bullet.currentPos;
bullet.ElapsedTime += Time.fixedDeltaTime;
}
}
}
@@ -131,7 +137,7 @@ namespace BITFALL
(null, null) => null,
(null, not null) => damagable?.Rigidbody,
(not null, null) => raycastHit.rigidbody,
(not null, not null) => raycastHit.rigidbody,
(not null, not null) => damagable?.Rigidbody,
};
if (_rigidbody is not null && _rigidbody.gameObject.layer is not 0)
{
@@ -154,8 +160,12 @@ namespace BITFALL
forward = raycastHit.normal,
};
var vfx = DI.Get<VFXService>().Spawn(location, tags.ToArray());
var constraint = vfx.gameObject.AddComponent<ParentConstraint>();
var constraint = vfx.gameObject.GetOrAddComponent<ParentConstraint>();
var sourceTransform = raycastHit.transform;
while (constraint.sourceCount>0)
{
constraint.RemoveSource(0);
}
constraint.AddSource(new ConstraintSource()
{
sourceTransform = sourceTransform,

View File

@@ -0,0 +1,21 @@
{
"name": "BITFALL.Entities.Animation",
"rootNamespace": "",
"references": [
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
"GUID:709caf8d7fb6ef24bbba0ab9962a3ad0",
"GUID:84d565da37ad40546a118cfb3c3509f3",
"GUID:d525ad6bd40672747bde77962f1c401e",
"GUID:49b49c76ee64f6b41bf28ef951cb0e50",
"GUID:677cd05ca06c46b4395470200b1acdad"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -1,18 +1,48 @@
using System.Collections;
using System.Collections.Generic;
using AYellowpaper.SerializedCollections;
using BITFALL.Entities.Equipment;
using BITKit.Animations;
using UnityEngine;
public class EntitiesAnimationController : MonoBehaviour
namespace BITKit.Entities.Animation
{
// Start is called before the first frame update
void Start()
{
}
public sealed class EntitiesAnimationController : EntityComponent
{
[SerializeField] private UnityAnimator unityAnimator;
[SerializeField] private SerializedDictionary<string, RuntimeAnimatorController> animatorControllers;
[Inject]
private IEntityEquipment _entityEquipment;
private RuntimeAnimatorController _initialRuntimeAnimatorController;
private readonly DoubleBuffer<RuntimeAnimatorController> _runtimeAnimatorControllerBuffer = new();
public override void OnAwake()
{
base.OnAwake();
_entityEquipment.OnEquip += OnEquip;
_initialRuntimeAnimatorController = unityAnimator.animator.runtimeAnimatorController;
}
public override void OnLateUpdate(float deltaTime)
{
if(_runtimeAnimatorControllerBuffer.TryGetRelease(out var controller))
{
unityAnimator.animator.runtimeAnimatorController = controller;
}
}
private void OnEquip(IBasicItem obj)
{
if(animatorControllers.TryGetValue(obj.AddressablePath, out var controller))
{
_runtimeAnimatorControllerBuffer.Release(controller);
}
else
{
_runtimeAnimatorControllerBuffer.Release(_initialRuntimeAnimatorController);
}
}
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -278,6 +278,7 @@ namespace BITFALL.Entities.Equipment
private void Equip(IBasicItem item)
{
_equipment.EntryEquip(item);
currentEquip = item;
}
@@ -296,6 +297,7 @@ namespace BITFALL.Entities.Equipment
{
if (!_equipmentContainer.Equipment.TryGetAny(x => x.Key is T, out var item)) return false;
//if (!_inventory.TryUseItem(item.Value)) return false;
_improvisedService.TryUnEquipImprovised(out _);
Equip(item.Value);
return true;
}

View File

@@ -16,7 +16,9 @@
"GUID:30cdc242b1ac6a944a460f4ab0b77b88",
"GUID:7efac18f239530141802fb139776f333",
"GUID:ef0bb553b58b90b488bdbe8672e3be0b",
"GUID:48ef04d98836e2640bf90b524bdff904"
"GUID:48ef04d98836e2640bf90b524bdff904",
"GUID:1eb13dc7c3cb5a444877a995967ed591",
"GUID:ea5474181b324dd49a5976cd68f44f18"
],
"includePlatforms": [],
"excludePlatforms": [],

View File

@@ -6,10 +6,12 @@ using BITKit;
using BITKit.Animations;
using BITKit.StateMachine;
using System.Linq;
using System.Security.Permissions;
using BITFALL;
using BITFALL.Entities.Equipment;
using BITFALL.Player.Equip;
using BITKit.Entities.Melee;
using BITKit.Entities.VFX;
using Cinemachine;
using Cysharp.Threading.Tasks;
@@ -22,7 +24,9 @@ namespace BITKit.Entities
[SerializeField] protected AssetableItem item;
[Header(Constant.Header.Components)]
public UnityAnimator animator;
[SerializeField] public UnityAnimator animator;
[SerializeField] protected EntityVFXPlayer vfxPlayer;
[SerializeField] protected EntityAnimator entityAnimator;
[SerializeField] private Renderer[] renderers;
[SerializeField] protected Transform cameraTransform;
@@ -30,6 +34,7 @@ namespace BITKit.Entities
[SerializeReference,SubclassSelector] protected IMeleeService meleeService;
public Core.Entites.IEntity Entity { get; set; }
public Entity UnityEntity=>Entity as Entity;
public IBasicItem Item { get; set; }
public readonly InputActionGroup inputActionGroup = new()
@@ -46,14 +51,29 @@ namespace BITKit.Entities
{
AllowRendering.AddElement(this);
inputActionGroup.allowInput.AddElement(this);
if (entityAnimator)
entityAnimator.enabled = true;
if (vfxPlayer)
vfxPlayer.enabled = true;
var animName = animator.animator.GetCurrentAnimatorStateInfo(0).shortNameHash;
animator.animator.Play(animName, -1, 0);
}
public virtual UniTask EntryAsync()
{
return UniTask.CompletedTask;
}
public virtual void Exit()
{
if (entityAnimator)
entityAnimator.enabled = false;
if (vfxPlayer)
vfxPlayer.enabled = false;
inputActionGroup.allowInput.RemoveElement(this);
}
public virtual UniTask ExitAsync()
@@ -126,33 +146,54 @@ namespace BITKit.Entities
[CustomType(typeof(IEntityEquipment))]
public class EntityEquipment : EntityComponent,IEquipService,IEntityEquipment
{
public EntryGroup<IEquipBase> equips = new();
public IOptional<float> Zoom { get; } = new Optional<float>(){Value = 1};
public float InitialFov;
[SerializeField] private CinemachineVirtualCamera virtualCamera;
[SerializeField] private Optional<int> overrideIndex;
public event Action<IBasicItem> OnEquip;
public event Action<IBasicItem> OnDeEquip;
public event Action<IBasicItem> OnUnEquip;
public event Action<string> OnEquipAddressable;
public event Action<string> OnUnEquipAddressable;
private readonly EntryGroup<IEquipBase> equips = new();
protected IEquipBase entryComplete;
private PlayerConfig playerConfig;
private IBasicItem _currentItem;
public override void OnStart()
[Inject(true)] private IHealth _health;
public override void OnAwake()
{
base.OnStart();
base.OnAwake();
equips.list = GetComponentsInChildren<IEquipBase>(true).ToList();
equips.OnEntry += OnEntry;
equips.OnExit += OnExit;
if (_health is not null)
{
_health.OnSetAlive += x =>
{
if (x is false)
EntryEquip(-1);
};
}
foreach (var x in equips.list)
{
x.Entity = entity;
x.OnAwake();
}
}
public override void OnStart()
{
base.OnStart();
foreach (var x in equips.list)
{
x.OnStart();
@@ -161,14 +202,18 @@ namespace BITKit.Entities
private void OnExit(IEquipBase obj)
{
OnUnEquipAddressable?.Invoke(obj.AddressablePath);
OnUnEquip?.Invoke(obj.Item);
//Debug.Log($"已退出:{obj.Item.Name}");
obj.Item = null;
OnDeEquip?.Invoke(obj.Item);
}
private void OnEntry(IEquipBase obj)
{
OnEquipAddressable?.Invoke(obj.AddressablePath);
obj.Item = _currentItem;
OnEquip?.Invoke(obj.Item);
//Debug.Log($"已进入:{obj.Item.Name}");
}
public override void OnUpdate(float deltaTime)
@@ -185,6 +230,11 @@ namespace BITKit.Entities
current = Mathf.Clamp(current, 10, PlayerConfig.Singleton.Fov);
virtualCamera.m_Lens.FieldOfView = current;
}
if (overrideIndex.Allow && (_health?.IsAlive ?? true))
{
EntryEquip(overrideIndex.Value);
}
}
public bool IsSupportItem(IBasicItem item)=> equips.list.Any(x => x.IsSupportItem(item));

View File

@@ -53,6 +53,10 @@ namespace BITFALL.Entities.Improvised
{
return false;
}
if (TryGetImprovisedItem(out var current))
{
TryUnEquipImprovised(out _);
}
_improvisedItem = weapon;
OnEquipImprovisedItem?.Invoke(weapon);
return true;

View File

@@ -16,7 +16,7 @@ namespace BITFALL
{
[CustomType(typeof(IEntityInventory))]
[CustomType(typeof(IBasicItemContainer))]
public abstract class EntityInventory : EntityComponent, IEntityInventory,IBasicItemContainer
public class EntityInventory : EntityComponent, IEntityInventory
{
/// <summary>
/// 数据字典

View File

@@ -41,7 +41,7 @@ namespace BITFALL
{
if (!obj.Transform.TryGetComponentAny<WorldItem>(out var item)) return;
var _item = item.Pick();
if(item.GetAssetable().TryGetProperty<Improvisable>(out _))
if(item.GetAssetable().IsImprovised)
{
if (_knockdown is not null && _knockdown.IsKnockdown)
{

View File

@@ -9,72 +9,104 @@ namespace BITFALL
{
public class EntityPropsDisplay : EntityComponent
{
[SerializeField] private SerializedDictionary<string, GameObject> equipments = new();
[SerializeField] private SerializedDictionary<string, GameObject> unEquipDictionary = new();
[SerializeField] private SerializedDictionary<string, GameObject> equipDictionary = new();
[SerializeField] private SerializedDictionary<string, GameObject> equipped = new();
[SerializeField] private SerializedDictionary<string, GameObject> bodyEquips = new();
[SerializeField] private SerializedDictionary<string, GameObject> holsteredEquips = new();
[Inject] private IEntityEquipment _entityEquipment;
[Inject] private IEntityEquipmentContainer _playerEquipContainer;
[Inject] private IPlayerEquipSelector _playerEquipSelector;
[Inject(true)] private IEntityEquipment _entityEquipment;
[Inject(true)] private IEntityEquipmentContainer _playerEquipContainer;
[Inject(true)] private IPlayerEquipSelector _playerEquipSelector;
public override void OnStart()
{
_playerEquipContainer.OnEquip += OnEquip;
_playerEquipContainer.OnDeEquip += OnDeEquip;
if (_entityEquipment is not null)
{
_entityEquipment.OnEquip += OnEquippedEquip;
_entityEquipment.OnUnEquip += OnEquippedUnEquip;
_entityEquipment.OnEquipAddressable+=OnEquippedEquipAddressable;
_entityEquipment.OnUnEquipAddressable+=OnUnEquippedEquipAddressable;
}
if (_playerEquipSelector is not null)
{
_playerEquipSelector.OnUpdateEquip += OnUpdateHolsteredEquip;
}
_entityEquipment.OnEquip += OnEquip;
_entityEquipment.OnDeEquip += OnDeEquip;
_playerEquipSelector.OnUpdateEquip += OnUpdateEquip;
if (_playerEquipContainer is not null)
{
_playerEquipContainer.OnEquip += OnEquipBodyEquip;
_playerEquipContainer.OnDeEquip += OnUnEquipBodyEquip;
}
foreach (var x in equipments)
foreach (var x in equipped)
{
x.Value.SetActive(false);
}
foreach (var x in unEquipDictionary)
foreach (var x in bodyEquips)
{
x.Value.SetActive(false);
}
foreach (var x in equipDictionary)
foreach (var x in holsteredEquips)
{
x.Value.SetActive(false);
}
}
private void OnDeEquip(IEquipmentSlot slot, IBasicItem item)
private void OnUnEquippedEquipAddressable(string obj)
{
var asset = item.GetAssetable();
if (equipments.TryGetValue(asset.AddressablePath, out GameObject prop))
if (string.IsNullOrEmpty(obj) is false && equipped.TryGetValue(obj, out var go))
{
prop.SetActive(false);
go.SetActive(false);
}
}
private void OnEquip(IEquipmentSlot slot, IBasicItem item)
private void OnEquippedEquipAddressable(string obj)
{
var asset = item.GetAssetable();
if(equipments.TryGetValue(asset.AddressablePath, out GameObject prop)) {
prop.SetActive(true);
if (string.IsNullOrEmpty(obj) is false && equipped.TryGetValue(obj, out var go))
{
go.SetActive(true);
}
}
private void OnEquip(IBasicItem item)
private void OnUnEquipBodyEquip(IEquipmentSlot arg1, IBasicItem arg2)
{
if(item is null) return;
if (equipDictionary.TryGetValue(item.AddressablePath, out var model))
if (bodyEquips.TryGetValue(arg2.AddressablePath, out var go))
{
model.SetActive(true);
go.SetActive(false);
}
}
private void OnDeEquip(IBasicItem item)
private void OnEquipBodyEquip(IEquipmentSlot arg1, IBasicItem arg2)
{
foreach (var x in equipDictionary)
if (bodyEquips.TryGetValue(arg2.AddressablePath, out var go))
{
x.Value.gameObject.SetActive(false);
go.SetActive(true);
}
}
private void OnUpdateEquip(IDictionary<int, IBasicItem> maps)
private void OnUpdateHolsteredEquip(IDictionary<int, IBasicItem> obj)
{
foreach (var x in holsteredEquips)
{
x.Value.SetActive(false);
}
foreach (var x in obj)
{
if (holsteredEquips.TryGetValue(x.Value.AddressablePath, out var go))
{
go.SetActive(true);
}
}
}
private void OnEquippedUnEquip(IBasicItem obj)
{
OnUnEquippedEquipAddressable(obj?.AddressablePath);
}
private void OnEquippedEquip(IBasicItem obj)
{
OnEquippedEquipAddressable(obj?.AddressablePath);
}
}
}

View File

@@ -0,0 +1,58 @@
using System.Collections;
using System.Collections.Generic;using BITFALL.Entities.Equipment;
using BITKit;
using BITKit.Entities;
using Cysharp.Threading.Tasks;
using UnityEngine;
using IEntity = BITKit.Core.Entites.IEntity;
namespace BITFALL.Entities.Equipment
{
public class AIEquipController : MonoBehaviour,IEquipBase
{
[SerializeField] protected AssetableItem assetableItem;
public bool IsEntered { get; set; }
public virtual void Entry()
{
}
public virtual UniTask EntryAsync()
{
return UniTask.CompletedTask;
}
public virtual void Exit()
{
}
public virtual UniTask ExitAsync()
{
return UniTask.CompletedTask;
}
public virtual void OnAwake()
{
}
public virtual void OnStart()
{
}
public virtual void OnUpdate(float deltaTime)
{
}
public string AddressablePath => assetableItem.AddressablePath;
public IEntity Entity { get; set; }
public Entity UnityEntity=>Entity as Entity;
public IBasicItem Item { get; set; }
public bool IsSupportItem(IBasicItem item) => item?.AddressablePath == AddressablePath;
public void PlayAudio(string name)
{
}
}
}

View File

@@ -0,0 +1,59 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using BITFALL.Bullet;
using BITFALL.Entities.Equipment;
using BITKit;
using BITKit.Entities;
using BITKit.StateMachine;
using UnityEngine;
namespace BITFALL.Guns
{
public class AIGunController : AIEquipController
{
[SerializeField] private Transform firePoint;
[SerializeReference,SubclassSelector] private IBulletService bulletService;
[SerializeField] private bool forceFire;
private AssetableGun _gun=>assetableItem as AssetableGun;
private readonly IntervalUpdate fireInterval = new();
public override void Entry()
{
base.Entry();
fireInterval.Interval = _gun.FireMode.FireRate is 0 ? 1 : 1f/_gun.FireMode.FireRate;
UnityEntity.AddListener<BITConstant.Command.AttackCommand>(OnAttack);
}
public override void Exit()
{
base.Exit();
UnityEntity.RemoveListener<BITConstant.Command.AttackCommand>(OnAttack);
}
public override void OnUpdate(float deltaTime)
{
if (forceFire && fireInterval.AllowUpdate)
{
OnAttack(new BITConstant.Command.AttackCommand());
}
}
private void OnAttack(BITConstant.Command.AttackCommand obj)
{
bulletService.Spawn(new SpawnBullet()
{
forward = firePoint.forward,
initialDamage = _gun.InitialDamage,
initiator = Entity.Id,
pos = firePoint.position,
rot = firePoint.rotation,
startSpeed = _gun.InitialBulletSpeed,
InitialForce = _gun.InitialBulletForce,
});
UnityEntity.Invoke(Constant.Animation.Play, BITConstant.Player.Fire);
}
}
}

View File

@@ -0,0 +1,42 @@
using System.Collections;
using System.Collections.Generic;
using BITFALL.Bullet;
using BITFALL.Guns;
using BITKit;
using BITKit.Entities.Melee;
using UnityEngine;
namespace BITFALL.Entities.Equipment
{
public class AIMeleeController : AIEquipController
{
[SerializeReference,SubclassSelector] private IMeleeService meleeService;
[SerializeField] private bool forceAttack;
private readonly IntervalUpdate interval = new(1);
public override void Entry()
{
base.Entry();
UnityEntity.AddListener<BITConstant.Command.AttackCommand>(OnAttack);
}
public override void Exit()
{
base.Exit();
UnityEntity.RemoveListener<BITConstant.Command.AttackCommand>(OnAttack);
}
public override void OnUpdate(float deltaTime)
{
if (forceAttack && interval.AllowUpdate)
{
OnAttack(new BITConstant.Command.AttackCommand());
}
}
private void OnAttack(BITConstant.Command.AttackCommand obj)
{
UnityEntity.Invoke(Constant.Animation.Play, BITConstant.Player.Melee);
}
}
}

View File

@@ -26,7 +26,8 @@
"GUID:42a9827d94e00374aa52e51f0a1b035c",
"GUID:87bea3a21c744b1478660b70494160ba",
"GUID:ef0bb553b58b90b488bdbe8672e3be0b",
"GUID:48ef04d98836e2640bf90b524bdff904"
"GUID:48ef04d98836e2640bf90b524bdff904",
"GUID:1eb13dc7c3cb5a444877a995967ed591"
],
"includePlatforms": [],
"excludePlatforms": [],

View File

@@ -74,7 +74,6 @@ namespace BITFALL.Guns
[SerializeField] private Transform cameraView;
// 引用组件
[Header(Constant.Header.Components)]
[SerializeField] private VFXPlayer vfxPlayer;
[SerializeField] private LocationAdditive locationAdditive;
// 引用预制体
@@ -163,8 +162,6 @@ namespace BITFALL.Guns
base.EntryAsync();
isHolstered = false;
var animName = animator.animator.GetCurrentAnimatorStateInfo(0).shortNameHash;
animator.animator.Play(animName,-1,0);
inputActionGroup.allowInput.AddElement(this);
expectFiring.Reset();
Enabled = true;
@@ -260,7 +257,7 @@ namespace BITFALL.Guns
}
//播放射击动画
animator.Play(BITConstant.Player.Fire);
UnityEntity.Invoke(Constant.Animation.Play, BITConstant.Player.Fire);
//调用BulletManager生成子弹
var _transform = transform;
@@ -275,9 +272,6 @@ namespace BITFALL.Guns
InitialForce = _gun.InitialBulletForce,
});
//播放枪口MuzzleFlash
vfxPlayer.Execute();
//开火模式逻辑判断
switch (assetable.FireMode)
{

View File

@@ -260,7 +260,8 @@ namespace BITFALL.Guns.States
base.OnStateEntry(old);
_entityMovement.ExecuteCommand<PlayerCancelRunCommand>();
root.animator.Play(BITConstant.Player.Reload);
root.UnityEntity.Invoke(Constant.Animation.Play, BITConstant.Player.Reload);
}
public override void OnMovementStateChanged(IEntityMovementState old, IEntityMovementState newState)
{

View File

@@ -58,16 +58,27 @@ namespace BITFALL.Entities.Equipment.Melee
[Inject]
private IEntityMovement _movement;
[Inject]
[Inject(true)]
private IPlayerMovement _playerMovement;
[Inject] private IHealth _health;
public override void OnAwake()
{
base.OnAwake();
inputActionGroup.RegisterCallback(attackAction, OnAttack);
inputActionGroup.RegisterCallback(blockAction, OnBlock);
_health.OnDamageFactory += OnDamageFactory;
if (attackAction is not null)
{
inputActionGroup.RegisterCallback(attackAction, OnAttack);
}
if (blockAction is not null)
{
inputActionGroup.RegisterCallback(blockAction, OnBlock);
}
if (_playerMovement is not null)
_health.OnDamageFactory += OnDamageFactory;
_movement.OnStateChanged += OnMovementStateChanged;
}

View File

@@ -24,7 +24,7 @@ namespace BITFALL.Player.Equip
public void OnAwake()
{
_entityEquipment.OnEquip += OnEquip;
_entityEquipment.OnDeEquip += OnDeEquip;
_entityEquipment.OnUnEquip += OnUnEquip;
}
public void OnStart()
{
@@ -58,7 +58,7 @@ namespace BITFALL.Player.Equip
{
return UniTask.CompletedTask;
}
private void OnDeEquip(IBasicItem obj)
private void OnUnEquip(IBasicItem obj)
{
foreach (var x in modelDictionary.Values)
{

View File

@@ -80,10 +80,10 @@ namespace BITFALL.Throws
if (IsEntered is false) return;
if (eventName is not BITConstant.Player.Throw) return;
if (!_equipmentContainer.TryUseEquip<EquipmentAsThrow>()) return;
var instance = _assetableThrow.GetInstance();
var instance =Instantiate(_assetableThrow.Prefab,
throwPoint.position + throwPoint.forward * 0.016f,
throwPoint.rotation) ;
if (!instance.TryGetComponent<Rigidbody>(out var _rigidbody)) return;
_rigidbody.rotation = throwPoint.rotation;
_rigidbody.position = throwPoint.position;
_rigidbody.AddForce(throwPoint.forward * throwForce, ForceMode.VelocityChange);
}
}

View File

@@ -77,12 +77,12 @@ namespace BITFALL.Guns
{
[Header(nameof(AssetableGun))]
[SerializeReference, SubclassSelector] protected IFireMode fireMode;
[SerializeField] private int initialDamage;
[SerializeField] private int initialBulletForce;
[SerializeField] private int initialBulletSpeed = 128;
public IFireMode FireMode => fireMode;
public int InitialBulletForce => initialBulletForce;
public int InitialDamage => initialDamage;
public int InitialBulletSpeed => initialBulletSpeed;
}
}

View File

@@ -39,12 +39,14 @@ namespace BITFALL
[SerializeField] private Texture2D squareIcon;
[SerializeField] private Texture2D rectangleIcon;
[SerializeField] private ItemQuality quality;
[SerializeField] private bool isImprovised;
[Header(Constant.Header.Property)]
[SerializeReference, SubclassSelector] public IProperty[] factoryProperties;
private Property property => new(factoryProperties);
#endregion
#region
public int Id => -1;
public bool IsImprovised => isImprovised;
public ItemQuality Quality => quality;
public string Name => displayName;
public string Description => description;

View File

@@ -8,6 +8,7 @@ namespace BITFALL.Items
{
[SerializeField] private Transform instance;
public Transform Prefab => instance;
public Transform GetInstance()
{
return Instantiate(instance);

View File

@@ -15,8 +15,6 @@ namespace BITFALL
#region
[Header(Constant.Header.Settings)]
[SerializeField]private AssetableItem asset;
private new Rigidbody _rigidbody;
#endregion
#region
public int Id => GetInstanceID();
@@ -61,30 +59,16 @@ namespace BITFALL
#endregion
#region
public AssetableItem Assetable => asset;
private void Start()
{
_rigidbody = GetComponent<Rigidbody>();
}
private void FixedUpdate()
{
if (!_rigidbody.IsSleeping()) return;
_rigidbody.isKinematic = true;
enabled = false;
}
public ManagedItem Pick()
{
var newitem = new ManagedItem();
newitem.CopyItemsFrom(this);
return newitem;
var managedItem = new ManagedItem();
managedItem.CopyItemsFrom(this);
return managedItem;
}
public void Picked()
{
Destroy(gameObject);
}
#endregion
}
#if UNITY_EDITOR

View File

@@ -27,15 +27,21 @@ namespace BITFALL.Props
var instance = Instantiate(prefab);
instance.SetPositionAndRotation(_transform.position, _transform.rotation);
if (root is not null)
instance.TryGetComponent<Rigidbody>(out var _rigidbody);
if (root is not null && root.gameObject.isStatic is false)
{
instance.SetParentConstraint(root);
if (instance.TryGetComponent<Rigidbody>(out var _rigidbody))
if (_rigidbody is not null)
{
//_rigidbody.isKinematic = true;
_rigidbody.isKinematic = true;
}
}
else if(_rigidbody is not null)
{
_rigidbody.velocity = rigidbody.velocity;
_rigidbody.angularVelocity = rigidbody.angularVelocity;
}
Destroy(gameObject);
}

View File

@@ -32,7 +32,7 @@ namespace BITFALL
var assets = item.GetAssetable();
currentUXEquip.SetTexture(assets.RectangleIcon);
}
public void OnDeEquip(IBasicItem item)
public void OnUnEquip(IBasicItem item)
{
currentUXEquip.SetTexture(null);
}
@@ -56,7 +56,7 @@ namespace BITFALL
private void Start()
{
playerService.OnPlayerInitialized += OnStartLocalPlayer;
OnDeEquip(null);
OnUnEquip(null);
foreach (var x in dictionary)
{
x.Value.visualElement.RegisterCallback<MouseDownEvent>(evt =>
@@ -80,7 +80,7 @@ namespace BITFALL
entity.Inject(this);
_entityEquipment.OnEquip += OnEquip;
_entityEquipment.OnDeEquip += OnDeEquip;
_entityEquipment.OnUnEquip += OnUnEquip;
_equipSelector.OnUpdateEquip += OnUpdateEquip;
}
}