From 519c93d6516423a019d57123ca1610d9afb22bf0 Mon Sep 17 00:00:00 2001 From: CortexCore <2630229280@qq.com> Date: Sun, 3 Aug 2025 02:28:22 +0800 Subject: [PATCH] 1 --- Src/Ability.meta | 8 ++ Src/Ability/AbilityComponents.cs | 15 +++ Src/Ability/AbilityComponents.cs.meta | 11 ++ Src/Ability/Net.Project.B.Ability.asmdef | 18 +++ Src/Ability/Net.Project.B.Ability.asmdef.meta | 7 + Src/Buff/IBuff.cs | 10 ++ Src/Buff/IBuffComponent.cs | 13 ++ Src/Bullet/BulletService.cs | 1 + Src/Bullet/IProjectileService.cs | 126 ++++++++++++++++++ Src/Bullet/IProjectileService.cs.meta | 11 ++ Src/Bullet/Project.B.Bullet.asmdef | 2 +- Src/Crafting.meta | 8 ++ Src/Crafting/ICraftingEnvironment.cs | 34 +++++ Src/Crafting/ICraftingEnvironment.cs.meta | 11 ++ Src/Crafting/ICrating.cs | 57 ++++++++ Src/Crafting/ICrating.cs.meta | 11 ++ Src/Crafting/Net.Project.B.Crafting.asmdef | 19 +++ .../Net.Project.B.Crafting.asmdef.meta | 7 + Src/Inventory/IPlayerEquipmentInventory.cs | 23 +++- Src/Inventory/IPlayerInventory.cs | 3 +- Src/Inventory/IPlayerWeaponInventory.cs | 2 +- Src/Melee/IMeleeService.cs | 2 + Src/PlayerSettings/IUXKeyMap.cs | 1 + Src/UX/UXDefine.cs | 2 + Src/WorldNode/UnityPhysicsNode.cs | 19 +++ Src/WorldNode/UnityPhysicsNode.cs.meta | 11 ++ 26 files changed, 427 insertions(+), 5 deletions(-) create mode 100644 Src/Ability.meta create mode 100644 Src/Ability/AbilityComponents.cs create mode 100644 Src/Ability/AbilityComponents.cs.meta create mode 100644 Src/Ability/Net.Project.B.Ability.asmdef create mode 100644 Src/Ability/Net.Project.B.Ability.asmdef.meta create mode 100644 Src/Bullet/IProjectileService.cs create mode 100644 Src/Bullet/IProjectileService.cs.meta create mode 100644 Src/Crafting.meta create mode 100644 Src/Crafting/ICraftingEnvironment.cs create mode 100644 Src/Crafting/ICraftingEnvironment.cs.meta create mode 100644 Src/Crafting/ICrating.cs create mode 100644 Src/Crafting/ICrating.cs.meta create mode 100644 Src/Crafting/Net.Project.B.Crafting.asmdef create mode 100644 Src/Crafting/Net.Project.B.Crafting.asmdef.meta create mode 100644 Src/WorldNode/UnityPhysicsNode.cs create mode 100644 Src/WorldNode/UnityPhysicsNode.cs.meta diff --git a/Src/Ability.meta b/Src/Ability.meta new file mode 100644 index 0000000..8045b57 --- /dev/null +++ b/Src/Ability.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6d720d7d210f68b449d1b8e36be1e64f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Src/Ability/AbilityComponents.cs b/Src/Ability/AbilityComponents.cs new file mode 100644 index 0000000..d089007 --- /dev/null +++ b/Src/Ability/AbilityComponents.cs @@ -0,0 +1,15 @@ +using System.Collections; +using System.Collections.Generic; + +namespace Net.Project.B.Buff +{ + public struct FlashingBuff : IBuff + { + public float Value { get; set; } + public override bool Equals(object obj) => obj?.GetType() == GetType(); + public override int GetHashCode() => GetType().GetHashCode(); + } + + +} + diff --git a/Src/Ability/AbilityComponents.cs.meta b/Src/Ability/AbilityComponents.cs.meta new file mode 100644 index 0000000..ab74b16 --- /dev/null +++ b/Src/Ability/AbilityComponents.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4b900b60aa332334ca048f4d2a496b3a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Src/Ability/Net.Project.B.Ability.asmdef b/Src/Ability/Net.Project.B.Ability.asmdef new file mode 100644 index 0000000..90c40cf --- /dev/null +++ b/Src/Ability/Net.Project.B.Ability.asmdef @@ -0,0 +1,18 @@ +{ + "name": "Net.Project.B.Ability", + "rootNamespace": "", + "references": [ + "GUID:46b59e80b22f9f04dbd080f812276bc4", + "GUID:14fe60d984bf9f84eac55c6ea033a8f4", + "GUID:d8b63aba1907145bea998dd612889d6b" + ], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": true +} \ No newline at end of file diff --git a/Src/Ability/Net.Project.B.Ability.asmdef.meta b/Src/Ability/Net.Project.B.Ability.asmdef.meta new file mode 100644 index 0000000..566a68a --- /dev/null +++ b/Src/Ability/Net.Project.B.Ability.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: b270929ce6e722f43ae3d4d634eb283f +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Src/Buff/IBuff.cs b/Src/Buff/IBuff.cs index 1117081..9dd7608 100644 --- a/Src/Buff/IBuff.cs +++ b/Src/Buff/IBuff.cs @@ -13,27 +13,37 @@ namespace Net.Project.B.Buff public struct AddHp : IBuff { public float Value { get; set; } + public override bool Equals(object obj) => obj?.GetType() == GetType(); + public override int GetHashCode() => GetType().GetHashCode(); } [Serializable] public struct InfiniteAp : IBuff { public float Value { get; set; } + public override bool Equals(object obj) => obj?.GetType() == GetType(); + public override int GetHashCode() => GetType().GetHashCode(); } [Serializable] public struct Hunger : IBuff { public float Value { get; set; } + public override bool Equals(object obj) => obj?.GetType() == GetType(); + public override int GetHashCode() => GetType().GetHashCode(); } [Serializable] public struct Thirsty : IBuff { public float Value { get; set; } + public override bool Equals(object obj) => obj?.GetType() == GetType(); + public override int GetHashCode() => GetType().GetHashCode(); } [Serializable] public struct Bleeding:IBuff { public float Value { get; set; } + public override bool Equals(object obj) => obj?.GetType() == GetType(); + public override int GetHashCode() => GetType().GetHashCode(); } } diff --git a/Src/Buff/IBuffComponent.cs b/Src/Buff/IBuffComponent.cs index b43ca14..1870aa1 100644 --- a/Src/Buff/IBuffComponent.cs +++ b/Src/Buff/IBuffComponent.cs @@ -35,6 +35,19 @@ namespace Net.Project.B.Buff public void AddBuff(IBuff buff, float duration = 0) { + for (var i = 0; i <_count ; i++) + { + ref var x = ref _buff[i]; + if (x.GetType() == buff.GetType()) + { + x.Value += buff.Value; + + _durations[buff] = _durations.GetValueOrDefault(buff) + duration; + + return; + } + } + _buff[_count++] = buff; OnBuffAdded?.Invoke(buff); if (duration > 0) diff --git a/Src/Bullet/BulletService.cs b/Src/Bullet/BulletService.cs index 1941c4f..0f6b895 100644 --- a/Src/Bullet/BulletService.cs +++ b/Src/Bullet/BulletService.cs @@ -7,5 +7,6 @@ namespace BITFALL.Bullet int LayerMask { get; set; } void Spawn(BulletData bulletData); Func OnHit { get; set; } + public event Action OnBulletHit; } } diff --git a/Src/Bullet/IProjectileService.cs b/Src/Bullet/IProjectileService.cs new file mode 100644 index 0000000..55c9771 --- /dev/null +++ b/Src/Bullet/IProjectileService.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using Cysharp.Threading.Tasks; +using Unity.Mathematics; + +namespace Net.Project.B.Projectile +{ + public interface IProjectileItem + { + public int Initiator { get; set; } + public float3 StartPosition { get; set; } + public quaternion StartRotation { get; set; } + public float3 EndPosition { get; set; } + public float3 StartVelocity { get; set; } + public float FuseTime { get; set; } + public float MaxLifetime { get; set; } + public object Model { get; set; } + } + + public interface IProjectileService + { + UniTask Project(IProjectileItem item); + + public event Action OnProjected; + } + + public interface IProjectileService:IProjectileService where T : IProjectileItem + { + public new event Action OnProjected; + } + [Serializable] + public struct FlashbangProjectileItem:IProjectileItem + { + public float maxLifeTime; + public int Initiator { get; set; } + public float3 StartPosition { get; set; } + public quaternion StartRotation { get; set; } + public float3 EndPosition { get; set; } + public float3 StartVelocity { get; set; } + public float FuseTime { get; set; } + + public float MaxLifetime + { + get => maxLifeTime; + set => maxLifeTime = value; + } + public object Model { get; set; } + } + [Serializable] + public struct GrenadeProjectileItem:IProjectileItem + { + public float maxLifeTime; + public float fuseTime; + + public int Initiator { get; set; } + public float3 StartPosition { get; set; } + public quaternion StartRotation { get; set; } + public float3 EndPosition { get; set; } + public float3 StartVelocity { get; set; } + + public float FuseTime + { + get => fuseTime; + set => fuseTime = value; + } + public float MaxLifetime + { + get => maxLifeTime; + set => maxLifeTime = value; + } + public object Model { get; set; } + } + + [Serializable] + public struct IncendiaryGrenadeProjectileItem:IProjectileItem + { + public float fuseTime; + + public int Initiator { get; set; } + public float3 StartPosition { get; set; } + public quaternion StartRotation { get; set; } + public float3 EndPosition { get; set; } + public float3 StartVelocity { get; set; } + + public float FuseTime + { + get => fuseTime; + set => fuseTime = value; + } + public float MaxLifetime { get; set; } + public object Model { get; set; } + } + + [Serializable] + public struct SmokeProjectileItem : IProjectileItem + { + public int Initiator { get; set; } + public float3 StartPosition { get; set; } + public quaternion StartRotation { get; set; } + public float3 EndPosition { get; set; } + public float3 StartVelocity { get; set; } + public float FuseTime { get; set; } + public float MaxLifetime { get; set; } + public object Model { get; set; } + } + + [Serializable] + public struct WeaponProjectileItem : IProjectileItem + { + public int scriptableItemId; + public int Initiator { get; set; } + public float3 StartPosition { get; set; } + public quaternion StartRotation { get; set; } + public float3 EndPosition { get; set; } + public float3 StartVelocity { get; set; } + public float FuseTime { get; set; } + public float MaxLifetime { get; set; } + public object Model { get; set; } + public int ScriptableItemId + { + get => scriptableItemId; + set => scriptableItemId = value; + } + } +} diff --git a/Src/Bullet/IProjectileService.cs.meta b/Src/Bullet/IProjectileService.cs.meta new file mode 100644 index 0000000..90198a6 --- /dev/null +++ b/Src/Bullet/IProjectileService.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 57d297b340c715346bbf1a7ac9fdec21 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Src/Bullet/Project.B.Bullet.asmdef b/Src/Bullet/Project.B.Bullet.asmdef index 5eabd1c..2d85942 100644 --- a/Src/Bullet/Project.B.Bullet.asmdef +++ b/Src/Bullet/Project.B.Bullet.asmdef @@ -4,7 +4,7 @@ "references": [ "GUID:14fe60d984bf9f84eac55c6ea033a8f4", "GUID:d8b63aba1907145bea998dd612889d6b", - "GUID:953d83d56b66feb4fa28a9eb2c4d78cb" + "GUID:f51ebe6a0ceec4240a699833d6309b23" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/Src/Crafting.meta b/Src/Crafting.meta new file mode 100644 index 0000000..56bd369 --- /dev/null +++ b/Src/Crafting.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 23ab131e02950b9499f5f38777c1a639 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Src/Crafting/ICraftingEnvironment.cs b/Src/Crafting/ICraftingEnvironment.cs new file mode 100644 index 0000000..6f11913 --- /dev/null +++ b/Src/Crafting/ICraftingEnvironment.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using BITKit.WorldNode; + +namespace Net.Project.B.Craft +{ + + // 合成环境,例如工作台(制造),篝火(烹饪或温度) + public interface ICraftEnvironment + { + + } + [Serializable] + public class CraftingWorkbench:ICraftEnvironment,IWorldNode + { + public override bool Equals(object obj) => obj is CraftingWorkbench; + + public override int GetHashCode() => GetType().GetHashCode(); + } + [Serializable] + public class CraftingTemperatureSource:ICraftEnvironment,IWorldNode + { + public override bool Equals(object obj) => obj is CraftingTemperatureSource; + + public override int GetHashCode() => GetType().GetHashCode(); + } + [Serializable] + public class CraftingWaterSource:ICraftEnvironment,IWorldNode + { + public override bool Equals(object obj) => obj is CraftingWaterSource; + + public override int GetHashCode() => GetType().GetHashCode(); + } +} \ No newline at end of file diff --git a/Src/Crafting/ICraftingEnvironment.cs.meta b/Src/Crafting/ICraftingEnvironment.cs.meta new file mode 100644 index 0000000..24e09b0 --- /dev/null +++ b/Src/Crafting/ICraftingEnvironment.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e73646397d685e24ea49a0c4d45353fb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Src/Crafting/ICrating.cs b/Src/Crafting/ICrating.cs new file mode 100644 index 0000000..dea1ff4 --- /dev/null +++ b/Src/Crafting/ICrating.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; + +namespace Net.Project.B.Craft +{ + // 合成配方 + public interface ICraftRecipe + { + int Id { get; } + public int CraftItemId { get; } + IReadOnlyDictionary RequiredItems { get; } + IReadOnlyDictionary RequiredTags { get; } + IReadOnlyCollection RequiredEnvironments { get; } + } + + public class CraftRecipe : ICraftRecipe + { + public int Id { get; set; } + public int CraftItemId { get; set; } + public readonly Dictionary RequiredItems = new(); + public readonly Dictionary RequiredTag = new(); + public readonly HashSet RequiredEnvironments = new(); + + IReadOnlyDictionary ICraftRecipe.RequiredItems => RequiredItems; + IReadOnlyDictionary ICraftRecipe.RequiredTags => RequiredTag; + IReadOnlyCollection ICraftRecipe.RequiredEnvironments => RequiredEnvironments; + } + // 合成服务 + public interface ICraftingService + { + /// + /// 获取可合成配方(无 GC 分配),写入调用方传入的缓冲区 + /// + /// 结果缓冲区 + /// 写入的个数 + int GetCraftableRecipesNonGc( + ICraftRecipe[] buffer); + + /// + /// 判断是否可以合成(无 GC) + /// + bool CanCraftNonGc(ICraftRecipe recipe,out ICraftRecipe missing); + + /// + /// 执行合成(不会分配新对象) + /// + bool TryCraftNonGc(ICraftRecipe recipe); + + /// + /// 获取合成环境 + /// + /// + /// + int QueryCraftEnvironments(ICraftEnvironment[] buffer); + } + +} \ No newline at end of file diff --git a/Src/Crafting/ICrating.cs.meta b/Src/Crafting/ICrating.cs.meta new file mode 100644 index 0000000..17605ce --- /dev/null +++ b/Src/Crafting/ICrating.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5bb537c45fe82d5499d8ac656a415c6e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Src/Crafting/Net.Project.B.Crafting.asmdef b/Src/Crafting/Net.Project.B.Crafting.asmdef new file mode 100644 index 0000000..bad6898 --- /dev/null +++ b/Src/Crafting/Net.Project.B.Crafting.asmdef @@ -0,0 +1,19 @@ +{ + "name": "Net.Project.B.Crafting", + "rootNamespace": "", + "references": [ + "GUID:14fe60d984bf9f84eac55c6ea033a8f4", + "GUID:f51ebe6a0ceec4240a699833d6309b23", + "GUID:d8b63aba1907145bea998dd612889d6b", + "GUID:d750d221812bb1d48baff92e6ef73e28" + ], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": true +} \ No newline at end of file diff --git a/Src/Crafting/Net.Project.B.Crafting.asmdef.meta b/Src/Crafting/Net.Project.B.Crafting.asmdef.meta new file mode 100644 index 0000000..1f3d864 --- /dev/null +++ b/Src/Crafting/Net.Project.B.Crafting.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 564e9f22877ff6544a2f3c9b209a7752 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Src/Inventory/IPlayerEquipmentInventory.cs b/Src/Inventory/IPlayerEquipmentInventory.cs index ca3cba4..19230e1 100644 --- a/Src/Inventory/IPlayerEquipmentInventory.cs +++ b/Src/Inventory/IPlayerEquipmentInventory.cs @@ -3,6 +3,7 @@ using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using BITKit; +using Microsoft.Extensions.Logging; namespace Net.Project.B.Inventory { @@ -20,8 +21,16 @@ namespace Net.Project.B.Inventory public class PlayerEquipmentInventory : IPlayerEquipmentInventory { + private readonly ILogger _logger; + public IReadOnlyDictionary Items => _items; private readonly ConcurrentDictionary _items = new(); + + public PlayerEquipmentInventory(ILogger logger) + { + _logger = logger; + } + public event Action OnItemAdded; public event Action OnItemUpdated; public event Action OnItemConsumed; @@ -55,8 +64,18 @@ namespace Net.Project.B.Inventory public virtual bool Consume(int slot) { - if (_items.TryRemove(slot, out _) is false) return false; - OnItemConsumed?.Invoke(slot, null); + if (_items.TryRemove(slot, out var item) is false) return false; + + try + { + OnItemConsumed?.Invoke(slot, item); + } + catch (Exception e) + { + _logger.LogCritical(e,e.Message); + } + + return true; } } diff --git a/Src/Inventory/IPlayerInventory.cs b/Src/Inventory/IPlayerInventory.cs index 55094d6..a0bdfde 100644 --- a/Src/Inventory/IPlayerInventory.cs +++ b/Src/Inventory/IPlayerInventory.cs @@ -11,7 +11,8 @@ namespace Net.Project.B.Inventory /// public interface IPlayerInventory { - int Size { get; } + int Slots { get; } + int AdditionalSlots { get; set; } /// /// 背包 /// diff --git a/Src/Inventory/IPlayerWeaponInventory.cs b/Src/Inventory/IPlayerWeaponInventory.cs index 9552b73..a2e220a 100644 --- a/Src/Inventory/IPlayerWeaponInventory.cs +++ b/Src/Inventory/IPlayerWeaponInventory.cs @@ -34,7 +34,7 @@ namespace Net.Project.B.Inventory /// /// void Drop(int itemId); - void Draw(int itemId); + bool Draw(int itemId,out IPlayerWeaponController controller); } } diff --git a/Src/Melee/IMeleeService.cs b/Src/Melee/IMeleeService.cs index 789cc2f..f69d457 100644 --- a/Src/Melee/IMeleeService.cs +++ b/Src/Melee/IMeleeService.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Diagnostics.Eventing.Reader; using Net.Project.B.Damage; using Unity.Mathematics; @@ -33,6 +34,7 @@ namespace Net.Project.B.Melee public interface IMeleeService { public void Add(IMeleeData meleeData); + public event Action OnMeleeHit; } } diff --git a/Src/PlayerSettings/IUXKeyMap.cs b/Src/PlayerSettings/IUXKeyMap.cs index 2cc1833..16e2689 100644 --- a/Src/PlayerSettings/IUXKeyMap.cs +++ b/Src/PlayerSettings/IUXKeyMap.cs @@ -7,6 +7,7 @@ namespace Project.B.Player { public T CancelKey { get; } public T InventoryKey { get; } + public T MapKey { get; } public T ConfirmKey { get; } public T ChatKey { get; } } diff --git a/Src/UX/UXDefine.cs b/Src/UX/UXDefine.cs index ad97c23..853e907 100644 --- a/Src/UX/UXDefine.cs +++ b/Src/UX/UXDefine.cs @@ -48,6 +48,7 @@ namespace Net.Project.B.UX public interface IUXSnapshot:IUXPanel{} public interface IUXInventorySwap:IUXPanel{} public interface IUXMap:IUXPanel{} + public interface IUXMapStandalone:IUXPanel{} public interface IUXIndicator:IUXPanel{} public interface IUXMark:IUXPanel{} public interface IUXQuest:IUXPanel{} @@ -58,4 +59,5 @@ namespace Net.Project.B.UX } public interface IUXChat:IUXPanel{} public interface IUXLevelUp:IUXPanel{} + public interface IUXCraft:IUXPanel{} } diff --git a/Src/WorldNode/UnityPhysicsNode.cs b/Src/WorldNode/UnityPhysicsNode.cs new file mode 100644 index 0000000..1ce9bf8 --- /dev/null +++ b/Src/WorldNode/UnityPhysicsNode.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using BITKit.WorldNode; +using UnityEngine; + +namespace Net.Project.B.WorldNode +{ + [Serializable] + public class UnityPhysicsNode:IWorldNode + { + public bool activeOnImpact; + public bool activeOnStartProbability; + public bool activeOnDamage; + + public Action Fracture; + } +} + diff --git a/Src/WorldNode/UnityPhysicsNode.cs.meta b/Src/WorldNode/UnityPhysicsNode.cs.meta new file mode 100644 index 0000000..b6e1ef3 --- /dev/null +++ b/Src/WorldNode/UnityPhysicsNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 51f2067a76e1e37479cc1a1bbdc6138e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: