This commit is contained in:
CortexCore
2025-08-03 02:28:22 +08:00
parent 87007c9c24
commit 519c93d651
26 changed files with 427 additions and 5 deletions

8
Src/Ability.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6d720d7d210f68b449d1b8e36be1e64f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4b900b60aa332334ca048f4d2a496b3a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b270929ce6e722f43ae3d4d634eb283f
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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();
}
}

View File

@@ -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)

View File

@@ -7,5 +7,6 @@ namespace BITFALL.Bullet
int LayerMask { get; set; }
void Spawn(BulletData bulletData);
Func<int,int,bool> OnHit { get; set; }
public event Action<BulletData, object> OnBulletHit;
}
}

View File

@@ -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<IProjectileItem> OnProjected;
}
public interface IProjectileService<out T>:IProjectileService where T : IProjectileItem
{
public new event Action<T> 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;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 57d297b340c715346bbf1a7ac9fdec21
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -4,7 +4,7 @@
"references": [
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
"GUID:d8b63aba1907145bea998dd612889d6b",
"GUID:953d83d56b66feb4fa28a9eb2c4d78cb"
"GUID:f51ebe6a0ceec4240a699833d6309b23"
],
"includePlatforms": [],
"excludePlatforms": [],

8
Src/Crafting.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 23ab131e02950b9499f5f38777c1a639
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e73646397d685e24ea49a0c4d45353fb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

57
Src/Crafting/ICrating.cs Normal file
View File

@@ -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<int,int> RequiredItems { get; }
IReadOnlyDictionary<string,int> RequiredTags { get; }
IReadOnlyCollection<ICraftEnvironment> RequiredEnvironments { get; }
}
public class CraftRecipe : ICraftRecipe
{
public int Id { get; set; }
public int CraftItemId { get; set; }
public readonly Dictionary<int, int> RequiredItems = new();
public readonly Dictionary<string,int> RequiredTag = new();
public readonly HashSet<ICraftEnvironment> RequiredEnvironments = new();
IReadOnlyDictionary<int, int> ICraftRecipe.RequiredItems => RequiredItems;
IReadOnlyDictionary<string, int> ICraftRecipe.RequiredTags => RequiredTag;
IReadOnlyCollection<ICraftEnvironment> ICraftRecipe.RequiredEnvironments => RequiredEnvironments;
}
// 合成服务
public interface ICraftingService
{
/// <summary>
/// 获取可合成配方(无 GC 分配),写入调用方传入的缓冲区
/// </summary>
/// <param name="buffer">结果缓冲区</param>
/// <returns>写入的个数</returns>
int GetCraftableRecipesNonGc(
ICraftRecipe[] buffer);
/// <summary>
/// 判断是否可以合成(无 GC
/// </summary>
bool CanCraftNonGc(ICraftRecipe recipe,out ICraftRecipe missing);
/// <summary>
/// 执行合成(不会分配新对象)
/// </summary>
bool TryCraftNonGc(ICraftRecipe recipe);
/// <summary>
/// 获取合成环境
/// </summary>
/// <param name="buffer"></param>
/// <returns></returns>
int QueryCraftEnvironments(ICraftEnvironment[] buffer);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5bb537c45fe82d5499d8ac656a415c6e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 564e9f22877ff6544a2f3c9b209a7752
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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<PlayerEquipmentInventory> _logger;
public IReadOnlyDictionary<int, IRuntimeItem> Items => _items;
private readonly ConcurrentDictionary<int, IRuntimeItem> _items = new();
public PlayerEquipmentInventory(ILogger<PlayerEquipmentInventory> logger)
{
_logger = logger;
}
public event Action<int, IRuntimeItem> OnItemAdded;
public event Action<int, IRuntimeItem> OnItemUpdated;
public event Action<int, IRuntimeItem> 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;
}
}

View File

@@ -11,7 +11,8 @@ namespace Net.Project.B.Inventory
/// </summary>
public interface IPlayerInventory
{
int Size { get; }
int Slots { get; }
int AdditionalSlots { get; set; }
/// <summary>
/// 背包
/// </summary>

View File

@@ -34,7 +34,7 @@ namespace Net.Project.B.Inventory
/// </summary>
/// <param name="itemId"></param>
void Drop(int itemId);
void Draw(int itemId);
bool Draw(int itemId,out IPlayerWeaponController controller);
}
}

View File

@@ -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<IMeleeData,object> OnMeleeHit;
}
}

View File

@@ -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; }
}

View File

@@ -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{}
}

View File

@@ -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<Vector3,Vector3> Fracture;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 51f2067a76e1e37479cc1a1bbdc6138e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: