This commit is contained in:
CortexCore 2025-02-24 23:02:49 +08:00
parent 9775bdd099
commit b07ae4fea7
82 changed files with 1021 additions and 386 deletions

View File

@ -2,7 +2,6 @@
"name": "Com.Project.B.Authorize",
"rootNamespace": "",
"references": [
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
"GUID:f51ebe6a0ceec4240a699833d6309b23"
],
"includePlatforms": [],

View File

@ -1,4 +1,5 @@
using System;
using MemoryPack;
namespace Com.Project.B.Authorize
{
@ -24,8 +25,8 @@ namespace Com.Project.B.Authorize
/// </summary>
DateTime LastUpdateTime { get; }
}
public struct AuthorizeData:IAuthorizeData
[MemoryPackable]
public partial struct AuthorizeData:IAuthorizeData
{
public int ConnectionId { get; set; }
public Guid PlayerId { get; set; }

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: af56161a7c158cb4f97da44de0d64528
guid: 6cac1e3a3113f884c8449ff66f3f1890
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@ -0,0 +1,12 @@
using System.Collections;
using System.Collections.Generic;
namespace Net.Project.B.Inventory
{
public class BuyStationComponent
{
public virtual int GroupId { get; set; }
public virtual int ScriptableId { get; set; }
public virtual int Price { get; set; }
}
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: f0cf21fa72c864844acd31f144d12f86
guid: 98d972e984085ce4a8562e2d7b78eb0b
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -0,0 +1,12 @@
using System.Collections;
using System.Collections.Generic;
using Cysharp.Threading.Tasks;
namespace Net.Project.B.Inventory
{
public interface IBuyStationService
{
public UniTask<IReadOnlyList<BuyStationComponent>> GetAllItemList();
public UniTask<bool> BuyItem(int buyer,BuyStationComponent buyStationComponent);
}
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 93300d0073822a34184faa323300fcfd
guid: a171a0081a5f6e14f89f194acf350a80
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -0,0 +1,19 @@
{
"name": "Net.Project.B.BuyStation",
"rootNamespace": "",
"references": [
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
"GUID:d8b63aba1907145bea998dd612889d6b",
"GUID:f51ebe6a0ceec4240a699833d6309b23",
"GUID:4f0d7989fc8bc01489c1e1f65eedd1c3"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": true
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: a4033552c5c40fa408838a1ce2b1b215
guid: b4a9c9d7a5a5a7140b5b656e4f049be5
AssemblyDefinitionImporter:
externalObjects: {}
userData:

View File

@ -1,12 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using Cysharp.Threading.Tasks;
namespace Project.B.Animation
{
public interface IAnimationFactory
{
public UniTask InitializeAsync();
}
}

View File

@ -1,21 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using BITKit;
using Unity.Mathematics;
namespace Project.B.Animation
{
public interface IHumanoidAnimationFactory: IAnimationFactory
{
IWrapper<float2> CreateIdleAnimation();
IWrapper<float2> CreateWalkAnimation();
IWrapper<float2> CreateCrouchedAnimation();
IWrapper<float2> CreateInAirAnimation();
IWrapper<float> CreateRunAnimation();
IWrapper<float> CreateSprintAnimation();
IWrapper<float2> CreateKnockedAnimation();
object CreateKnockingAnimation();
object CreateDeathAnimation();
}
}

View File

@ -1,14 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using BITKit;
using Unity.Mathematics;
namespace Project.B.Animation
{
public interface IPlayerAnimationFactory : IHumanoidAnimationFactory
{
public object CreateStepUpAnimation();
public object CreateSlidingAnimation();
public object CreateClimbAnimation();
}
}

View File

@ -1,8 +0,0 @@
namespace Project.B.CharacterController
{
public interface IBotCharacterController
{
ICharacterController CharacterController { get; }
}
}

View File

@ -1,19 +0,0 @@
using BITKit.StateMachine;
using Unity.Mathematics;
namespace Project.B.CharacterController
{
/// <summary>
/// 角色控制器
/// </summary>
public interface ICharacterController:IStateMachine<ICharacterState>
{
float3 Center { get; }
float3 Position { get; set; }
float3 Velocity { get; set; }
float3 AngularVelocity { get; }
quaternion Rotation { get; set; }
float3 SelfVelocity { get; set; }
}
}

View File

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

View File

@ -1,12 +0,0 @@
using System.Collections.Generic;
namespace Project.B.CharacterController
{
/// <summary>
/// 角色服务
/// </summary>
public interface ICharacterService
{
IDictionary<int, ICharacterController> Dictionary { get; }
}
}

View File

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

View File

@ -1,81 +0,0 @@
using BITKit.StateMachine;
using Unity.Mathematics;
namespace Project.B.CharacterController
{
/// <summary>
/// 角色状态
/// </summary>
public interface ICharacterState : IState
{
public void UpdateVelocity(ref float3 currentVelocity, float deltaTime);
public void UpdateRotation(ref float3 localPosition, ref quaternion currentRotation,
ref quaternion viewRotation, float deltaTime);
public void BeforeUpdateVelocity(float deltaTime);
public void AfterUpdateVelocity(float deltaTime);
}
/// <summary>
/// 角色状态数据
/// </summary>
public interface ICharacterStateData
{
public float BaseHeight { get; }
public float BaseSpeed { get; }
public float2 ViewOffset { get; }
}
/// <summary>
/// 空状态
/// </summary>
public interface ICharacterStateEmpty:ICharacterState{}
/// <summary>
/// 静止
/// </summary>
public interface ICharacterStateIdle:ICharacterState{}
/// <summary>
/// 行走
/// </summary>
public interface ICharacterStateWalk:ICharacterState{}
/// <summary>
/// 蹲下
/// </summary>
public interface ICharacterStateCrouched:ICharacterState{}
/// <summary>
/// 奔跑
/// </summary>
public interface ICharacterStateRun:ICharacterState{}
/// <summary>
/// 战术跑
/// </summary>
public interface ICharacterSprint:ICharacterState{}
/// <summary>
/// 在空中,包括跳跃、下落、飞行等
/// </summary>
public interface ICharacterStateInAir:ICharacterState{}
/// <summary>
/// 爬上低障碍物
/// </summary>
public interface ICharacterStateStepUp:ICharacterState{}
/// <summary>
/// 翻阅障碍物
/// </summary>
public interface ICharacterStateVault:ICharacterState{}
/// <summary>
/// 攀爬
/// </summary>
public interface ICharacterStateClimb:ICharacterState{}
/// <summary>
/// 被击倒
/// </summary>
public interface ICharacterKnocked:ICharacterState{}
/// <summary>
/// 滑铲
/// </summary>
public interface ICharacterSliding:ICharacterState{}
/// <summary>
/// 游泳
/// </summary>
public interface ICharacterSwimming:ICharacterState{}
}

View File

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

View File

@ -1,20 +0,0 @@
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using BITKit;
using Unity.Mathematics;
namespace Project.B.CharacterController
{
public interface IPlayerCharacterController
{
ICharacterController CharacterController { get; }
IDictionary<int,quaternion> AdditiveCameraQuaternion { get; }
IDictionary<int,float> ZoomFactor { get; }
ValidHandle AllowTpsCamera { get; }
ValidHandle AllowRun { get; }
ValidHandle AllowSprint { get; }
void CancelRun();
void CancelSprint();
}
}

View File

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

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 0b88cd3c8eae9724caabbf566ba0e879
guid: 016b9ce0e3fdaf443812b51e03038607
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@ -0,0 +1,36 @@
using System;
using System.Collections;
using System.Collections.Generic;
using BITKit.Modification;
using Cysharp.Threading.Tasks;
namespace Net.Project.B.Cosmetics
{
public interface ICosmeticsClass
{
}
[Serializable]
public struct CosmeticsHand:ICosmeticsClass
{
}
[Serializable]
public struct CosmeticsModel:ICosmeticsClass
{
}
[Serializable]
public struct CosmeticsHat:ICosmeticsClass
{
}
public class CosmeticsCustomizeComponent
{
public virtual HashSet<int> ComponentIds { get; set; } = new();
}
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 9ed442d9b01567644b3ba71d2290f15d
guid: edfb262a318e99448ad62c27505d1f9a
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -1,8 +1,10 @@
{
"name": "Com.Project.B.Net",
"name": "Net.Project.B.Cosmetics",
"rootNamespace": "",
"references": [
"GUID:14fe60d984bf9f84eac55c6ea033a8f4"
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
"GUID:d8b63aba1907145bea998dd612889d6b",
"GUID:f51ebe6a0ceec4240a699833d6309b23"
],
"includePlatforms": [],
"excludePlatforms": [],

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 6bf9bfd639affa44788ad1d79942746b
guid: 44495f3f3cb105748baf59ecacd464c6
AssemblyDefinitionImporter:
externalObjects: {}
userData:

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 781f78b6186d76441831eb8d0f3c6854
guid: fe91bbcf397f48146b426e3e2307465b
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@ -0,0 +1,79 @@
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
namespace Net.Project.B.Dialogue
{
/// <summary>
/// 对话数据
/// </summary>
public interface IDialogueData
{
/// <summary>
/// 唯一对话ID
/// </summary>
public int Identity { get; set; }
/// <summary>
/// 通道ID,用于区分不同的对话
/// </summary>
public int Channel { get; }
/// <summary>
/// 演员ID,谁是说话的人
/// </summary>
public int ActorIdentity { get; }
/// <summary>
/// 文本
/// </summary>
public string Text { get; }
/// <summary>
/// 语音路径
/// </summary>
public string VoicePath { get; }
/// <summary>
/// 等待对话完成
/// </summary>
/// <returns></returns>
TaskAwaiter GetAwaiter();
}
/// <summary>
/// 对话选择
/// </summary>
public interface IDialogueChoice
{
/// <summary>
/// 索引
/// </summary>
public int Index { get; }
/// <summary>
/// 文本
/// </summary>
public string Text { get; }
/// <summary>
/// 是否可选
/// </summary>
public bool Enabled { get; }
/// <summary>
/// 备注,例如:选择这个选项会触发什么事件,不可选的原因等
/// </summary>
public string Remark { get; }
}
public struct DialogueData:IDialogueData
{
public int Identity { get; set; }
public int Channel { get; set; }
public int ActorIdentity { get; set; }
public string Text { get; set; }
public string VoicePath { get; set; }
public TaskAwaiter GetAwaiter()
{
throw new System.NotImplementedException();
}
}
public struct DialogueChoice:IDialogueChoice
{
public int Index { get; set; }
public string Text { get; set; }
public bool Enabled { get; set; }
public string Remark { get; set; }
}
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 85e6ac8c46e30404cbd8d8cffc15f319
guid: ebb9eb40cce574a44b3419bd4d58411f
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -0,0 +1,104 @@
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using BITKit;
using Cysharp.Threading.Tasks;
namespace Net.Project.B.Dialogue
{
/// <summary>
/// 对话服务
/// </summary>
public interface IDialogueService
{
/// <summary>
/// 所有对话
/// </summary>
IReadOnlyDictionary<int, IDialogueData> Dialogues { get; }
/// <summary>
/// 对话开始
/// </summary>
public event Func<IDialogueData, UniTask> OnDialogueStart;
/// <summary>
/// 对话结束
/// </summary>
public event Action<IDialogueData> OnDialogueEnd;
/// <summary>
/// 对话选择
/// </summary>
public event Func<IDialogueData, IReadOnlyCollection<IDialogueChoice>, UniTask<int>> OnDialogueChoose;
/// <summary>
/// 对话选择回调
/// </summary>
public event Action<IDialogueData, IDialogueChoice> OnDialogueChose;
/// <summary>
/// 开启对话
/// </summary>
/// <param name="dialogueData">对话</param>
/// <returns></returns>
UniTask CreateDialogue(IDialogueData dialogueData);
UniTask<int> CreateDialogue(IDialogueData dialogueData, IReadOnlyCollection<IDialogueChoice> dialogueChoices);
}
public class DialogueService : IDialogueService
{
public IReadOnlyDictionary<int, IDialogueData> Dialogues => _dialogues;
public event Func<IDialogueData, UniTask> OnDialogueStart;
public event Action<IDialogueData> OnDialogueEnd;
public event Func<IDialogueData, IReadOnlyCollection<IDialogueChoice>, UniTask<int>> OnDialogueChoose;
public event Action<IDialogueData, IDialogueChoice> OnDialogueChose;
public async UniTask CreateDialogue(IDialogueData dialogueData)
{
if (_dialogues.TryAdd(dialogueData.Identity, dialogueData) is false)
{
dialogueData.Identity = _dialogues.Keys.Max() + 1;
_dialogues.TryAdd(dialogueData.Identity, dialogueData);
}
try
{
await OnDialogueStart.UniTaskFunc(dialogueData);
}
catch (OperationCanceledException)
{
}
catch (OperationAbortedException)
{
}
OnDialogueEnd?.Invoke(dialogueData);
}
public async UniTask<int> CreateDialogue(IDialogueData dialogueData,
IReadOnlyCollection<IDialogueChoice> dialogueChoices)
{
if (OnDialogueChoose is null)
{
throw new NullReferenceException("OnDialogueChoose is null,unable to create dialogue");
}
var task = OnDialogueChoose.Invoke(dialogueData, dialogueChoices);
var index = await task;
OnDialogueChose?.Invoke(dialogueData, dialogueChoices.ElementAt(index));
return index;
}
private readonly ConcurrentDictionary<int, IDialogueData> _dialogues = new();
}
}

View File

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

View File

@ -1,9 +1,9 @@
{
"name": "Com.Project.B.CharacterController",
"name": "Net.Project.B.Dialogue",
"rootNamespace": "",
"references": [
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
"GUID:d8b63aba1907145bea998dd612889d6b"
"GUID:f51ebe6a0ceec4240a699833d6309b23"
],
"includePlatforms": [],
"excludePlatforms": [],

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: ecc5a2501a2c44d4cb8366674714f3d9
guid: ba8323a5a01afc24188ded7f4b05db8a
AssemblyDefinitionImporter:
externalObjects: {}
userData:

8
Src/Emoji.meta Normal file
View File

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

27
Src/Emoji/IEmojiData.cs Normal file
View File

@ -0,0 +1,27 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using BITKit;
using Cysharp.Threading.Tasks;
namespace Net.Project.B.Emoji
{
public interface IEmojiData<T>:IDescription
{
public T Clip { get; }
}
public struct EmojiData<T>:IEmojiData<T>
{
public string Name { get; set; }
public string Description { get; set; }
public T Clip { get; set; }
}
public interface IEmojiService<T>
{
public event Func<IEmojiData<T>, CancellationToken, UniTask> OnPlayAsync;
public UniTask<IReadOnlyCollection<IEmojiData<T>>> GetAllEmojis();
public UniTask Play(IEmojiData<T> emojiData,CancellationToken cancellationToken=default);
}
}

View File

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

View File

@ -1,10 +1,9 @@
{
"name": "Com.Project.B.CharacterAnimation",
"name": "Net.Project.B.Emoji",
"rootNamespace": "",
"references": [
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
"GUID:ecc5a2501a2c44d4cb8366674714f3d9",
"GUID:f51ebe6a0ceec4240a699833d6309b23",
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
"GUID:d8b63aba1907145bea998dd612889d6b"
],
"includePlatforms": [],

View File

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

View File

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using BITKit.Entities;
using Cysharp.Threading.Tasks;
using UnityEngine;
namespace Project.B.Entities
{
@ -11,7 +12,7 @@ namespace Project.B.Entities
public interface IEntitiesFactory:IDisposable
{
IReadOnlyDictionary<int,IEntity> Entities { get; }
UniTask<IEntity> CreateAsync(string addressablePath);
UniTask<IEntity> CreateAsync(string addressablePath,GameObject model);
public event Func<string, IEntity,UniTask> OnEntityCreate;
public event Func<string, IEntity,UniTask> OnEntityCreated;
}

View File

@ -2,8 +2,6 @@
"name": "Com.Project.B.GameService",
"rootNamespace": "",
"references": [
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
"GUID:a4033552c5c40fa408838a1ce2b1b215",
"GUID:f51ebe6a0ceec4240a699833d6309b23"
],
"includePlatforms": [],
@ -14,5 +12,5 @@
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": true
"noEngineReferences": false
}

View File

@ -0,0 +1,14 @@
using System.Collections;
using System.Collections.Generic;
namespace Project.B.Map
{
public interface IGameMapData
{
public string MapName { get; }
public string Author { get; }
public string Description { get; }
public object Overview { get; }
public string MapAddress { get; }
}
}

View File

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

View File

@ -1,7 +1,8 @@
using System;
using System.Collections;
using System.Collections.Generic;
using BITKit;
using System.Data;
using System.Threading.Tasks;
using Cysharp.Threading.Tasks;
namespace Project.B.Map
@ -14,7 +15,7 @@ namespace Project.B.Map
/// <summary>
/// 初始化状态
/// </summary>
InitializationState InitializationState { get; }
TaskStatus TaskStatus { get; }
/// <summary>
/// 当前已加载或正在加载的地图
/// </summary>
@ -38,7 +39,7 @@ namespace Project.B.Map
/// <summary>
/// 当加载状态发生变化时
/// </summary>
event Action<InitializationState> OnInitializationStateChanged;
event Action<TaskStatus,TaskStatus> OnTaskStatusChanged;
/// <summary>
/// 切换场景前
/// </summary>

View File

@ -0,0 +1,22 @@
#if UNITY_5_3_OR_NEWER
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Project.B.Map
{
public class ScriptableGameMapData : ScriptableObject,IGameMapData
{
[SerializeField] private string mapName;
[SerializeField] private string description;
[SerializeField] private string author;
[SerializeField] private string mapAddress;
[SerializeField] private Texture overview;
public string MapName => mapName;
public string Author => author;
public string Description => description;
public object Overview => overview;
public string MapAddress => mapAddress;
}
}
#endif

View File

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

View File

@ -0,0 +1,64 @@
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using BITKit;
using UnityEngine;
namespace Net.Project.B.Inventory
{
public interface IPlayerEquipmentInventory
{
IReadOnlyDictionary<int, IRuntimeItem> Items { get; }
public event Action<int, IRuntimeItem> OnItemAdded;
public event Action<int, IRuntimeItem> OnItemUpdated;
public event Action<int, IRuntimeItem> OnItemConsumed;
public event Action<int, IRuntimeItem> OnItemRemoved;
bool AddOrUpdate(int slot, IRuntimeItem item);
bool Remove(int slot);
bool Consume(int slot);
}
public class PlayerEquipmentInventory : IPlayerEquipmentInventory
{
public IReadOnlyDictionary<int, IRuntimeItem> Items => _items;
private readonly ConcurrentDictionary<int, IRuntimeItem> _items = new();
public event Action<int, IRuntimeItem> OnItemAdded;
public event Action<int, IRuntimeItem> OnItemUpdated;
public event Action<int, IRuntimeItem> OnItemConsumed;
public event Action<int, IRuntimeItem> OnItemRemoved;
public virtual bool AddOrUpdate(int slot, IRuntimeItem item)
{
if (_items.TryGetValue(slot, out var current))
{
if (current.Id != item.Id) return false;
_items[slot] = item;
OnItemUpdated?.Invoke(slot, item);
}
else
{
_items.TryAdd(slot, item);
OnItemAdded?.Invoke(slot, item);
}
return true;
}
public virtual bool Remove(int slot)
{
if (!_items.TryRemove(slot, out var item)) return false;
OnItemRemoved?.Invoke(slot, item);
return true;
}
public virtual bool Consume(int slot)
{
if (_items.TryRemove(slot, out _) is false) return false;
OnItemConsumed?.Invoke(slot, null);
return true;
}
}
}

View File

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

View File

@ -6,76 +6,35 @@ using BITKit.StateMachine;
namespace Net.Project.B.Inventory
{
/// <summary>
/// 玩家武器槽
/// </summary>
public enum PlayerWeaponSlot
{
/// <summary>
/// 主武器
/// </summary>
Primary,
/// <summary>
/// 主武器2
/// </summary>
Secondary,
/// <summary>
/// 副武器,例如手枪,近战武器等
/// </summary>
Sidearm,
/// <summary>
/// 消耗品,通常是护甲,医疗包等
/// </summary>
Supplies,
/// <summary>
/// 战术道具
/// </summary>
Tactics,
/// <summary>
/// 致命道具
/// </summary>
Lethal,
/// <summary>
/// 连杀奖励,特别的武器
/// </summary>
KillStreak
}
/// <summary>
/// 玩家武器控制器
/// 玩家控制器
/// </summary>
public interface IPlayerWeaponController:IStateAsync{}
/// <summary>
/// 玩家枪支控制器
/// 玩家泛型控制器
/// </summary>
public interface IPlayerGunController:IPlayerWeaponController{}
/// <summary>
/// 玩家近战武器控制器
/// </summary>
public interface IPlayerMeleeController:IPlayerWeaponController{}
/// <typeparam name="T"></typeparam>
public interface IPlayerWeaponController<T>:IPlayerWeaponController{}
/// <summary>
/// 玩家武器库存,与背包不是一个东西
/// </summary>
public interface IPlayerWeaponInventory
{
/// <summary>
/// 武器
/// 允许使用武器
/// </summary>
public IReadOnlyDictionary<PlayerWeaponSlot,int> WeaponSlots { get; }
public ValidHandle AllowWeapon { get; }
/// <summary>
/// 武器控制器状态机
/// </summary>
public IStateMachine<IPlayerWeaponController> StateMachine { get; }
/// <summary>
/// 武器槽更新回调,参数为:slot,ItemId,IsAdd
/// </summary>
public event Action<PlayerWeaponSlot, int, bool> OnWeaponSlotChanged;
/// <summary>
/// 丢下武器
/// </summary>
/// <param name="slot"></param>
void Drop(PlayerWeaponSlot slot);
void Use(PlayerWeaponSlot slot);
void Use(int id);
/// <param name="itemId"></param>
void Drop(int itemId);
void Draw(int itemId);
}
}

View File

@ -12,7 +12,7 @@ namespace Net.Project.B.Item
{
public IReadOnlyDictionary<int,IRuntimeItem> Items { get; }
public void AddOrUpdateItem(IRuntimeItem item);
public void InstanceItem(float3 position, quaternion rotation, IRuntimeItem item);
public UniTask<object> InstanceItem(float3 position, quaternion rotation, IRuntimeItem item);
public void DisposeItem(IRuntimeItem item);
public void DisposeWorldObject(IRuntimeItem item);
public UniTask ReloadAsync();

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using MemoryPack;
using Newtonsoft.Json;
namespace Com.Project.B.Lobby
@ -66,7 +67,8 @@ namespace Com.Project.B.Lobby
public bool Contain(Guid player);
}
public sealed class LobbyData:ILobbyData
[MemoryPackable]
public sealed partial class LobbyData:ILobbyData
{
public Guid Id { get; set; }
public LobbyAccessMode LobbyAccess { get; set; } = LobbyAccessMode.Public;

View File

@ -1,5 +1,4 @@
using System;
using BITKit;
using Cysharp.Threading.Tasks;
namespace Com.Project.B.Lobby
@ -14,7 +13,7 @@ namespace Com.Project.B.Lobby
/// </summary>
/// <param name="playerId"></param>
/// <returns></returns>
UniTask<ContextModel> GetPlayerLobbyAsync(Guid playerId);
UniTask<ILobbyData> GetPlayerLobbyAsync(Guid playerId);
/// <summary>
/// 获取所有大厅
/// </summary>

View File

@ -1,24 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using BITKit;
using BITKit.StateMachine;
namespace Project.B.Net
{
public interface IGameNetState:IState{}
public interface IGameNetOffline:IGameNetState{}
public interface IGameNetAsHost : IGameNetState
{
}
public interface IGameNetAsClient : IGameNetState
{
}
public interface IGameNetService:IStateMachine<IGameNetState>,IDisposable
{
public INetServer Server { get; }
public INetClient Client { get; }
public INetClient LobbyClient { get; }
}
}

View File

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

View File

@ -0,0 +1,40 @@
using System;
using System.Collections;
using System.Collections.Generic;
using BITKit.StateMachine;
namespace Project.B.Player
{
public interface IPlayerControlMode
{
}
public struct PlayerEmptyMode : IPlayerControlMode
{
}
public struct PlayerWalkMode : IPlayerControlMode
{
}
public struct PlayerCarMode : IPlayerControlMode
{
}
public struct PlayerTankMode : IPlayerControlMode
{
}
public struct PlayerPlaneMode : IPlayerControlMode
{
}
public struct PlayerHelicopterMode : IPlayerControlMode
{
}
public struct PlayerSpotterScopeMode : IPlayerControlMode
{
}
}

View File

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

View File

@ -33,7 +33,7 @@ namespace Project.B.Player
int LicenseLevel { get; }
}
[MemoryPackable]
public partial struct PlayerData:IPlayerData
public partial record PlayerData:IPlayerData
{
public Guid PlayerId { get; set; }
public bool IsBot { get; set; }

View File

@ -13,5 +13,5 @@
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": true
"noEngineReferences": false
}

View File

@ -5,88 +5,92 @@ namespace Project.B.Player
/// <summary>
/// 玩家键位
/// </summary>
public interface IPlayerKeyMap:IKeyMap
public interface IPlayerKeyMap<T>:IKeyMap
{
/// <summary>
/// 移动
/// </summary>
public string MovementKey { get; set; }
public T MovementKey { get; }
/// <summary>
/// 视角
/// </summary>
public string ViewKey { get; set; }
public T ViewKey { get; }
/// <summary>
/// 跳跃
/// </summary>
public string JumpKey { get; set; }
public T JumpKey { get; }
/// <summary>
/// 奔跑
/// </summary>
public string RunKey{ get; set; }
public T RunKey{ get; }
/// <summary>
/// 蹲下
/// </summary>
public string CrouchKey { get; set; }
public T CrouchKey{ get; }
/// <summary>
/// 切换第三人称相机
/// </summary>
public string ToggleCameraKey { get; set; }
public T ToggleCameraKey{ get; }
/// <summary>
/// 互动
/// </summary>
public string InteractiveKey { get; }
public T InteractiveKey { get; }
/// <summary>
/// 收起武器
/// </summary>
public string HolsterKey { get; }
public T HolsterKey { get; }
/// <summary>
/// 主武器
/// </summary>
public string PrimaryWeaponKey { get; }
public T PrimaryWeaponKey { get; }
/// <summary>
/// 副武器
/// </summary>
public string SecondaryWeaponKey { get; }
public T SecondaryWeaponKey{ get; }
/// <summary>
/// 随身武器
/// </summary>
public string SidearmKey { get; }
public T SidearmKey { get; }
/// <summary>
/// 消耗品
/// </summary>
public string SuppliesKey { get; }
public T SuppliesKey { get; }
/// <summary>
/// 战术道具
/// </summary>
public string TacticalKey { get; }
public T TacticalKey { get; }
/// <summary>
/// 致命道具
/// </summary>
public string LethalKey { get; }
public T LethalKey { get; }
/// <summary>
/// 连杀道具
/// </summary>
public string KillStreakKey { get; }
public T KillStreakKey { get; }
/// <summary>
/// 滚轮缩放,在不同状态下有不同的表现
/// </summary>
public string ScrollKey { get; }
public T ScrollKey { get; }
/// <summary>
/// 近战
/// </summary>
public string MeleeKey { get; }
public T MeleeKey { get; }
/// <summary>
/// 重装
/// </summary>
public string ReloadKey { get; }
public T ReloadKey { get; }
/// <summary>
/// 瞄准
/// </summary>
public string AimKey { get; }
public T AimKey { get; }
/// <summary>
/// 开火
/// </summary>
public string FireKey { get; }
public T FireKey { get; }
/// <summary>
/// 检视
/// </summary>
public T InspectKey { get; }
}
}

View File

@ -1,33 +1,85 @@
using System;
using System.ComponentModel;
using MemoryPack;
using Unity.Mathematics;
#if UNITY_5_3_OR_NEWER
using UnityEngine;
#endif
namespace Project.B.Player
{
#if UNITY_5_3_OR_NEWER
public enum VSyncCount
{
DontSync,
EveryVBlank,
EverySecondVBlank
}
public enum RealtimeGICPUUsage
{
Low,
Medium,
High,
Unlimited
}
public enum GlobalMipmapLimit
{
FullResolution,
HalfResolution,
QuarterResolution,
EighthResolution,
}
#endif
/// <summary>
/// 玩家设置
/// </summary>
public interface IPlayerSettings
public class PlayerSettings
{
/// <summary>
/// 灵敏度
/// </summary>
public float Sensitivity { get; set; }
public float GamePadSensitivity { get; set; }
[Category("控制")]
[DisplayName("鼠标灵敏度")]
public float Sensitivity { get; set; } = 1.81f;
[DisplayName("手柄灵敏度")] public float GamePadSensitivity { get; set; } = 1;
[DisplayName("触屏灵敏度")] public float TouchSensitivity { get; set; } = 0.32f;
/// <summary>
/// 视野
/// </summary>
public int Fov { get; set; }
[Category("画面")]
[DisplayName("FOV")]
public int Fov { get; set; } = 90;
/// <summary>
/// 刷新率
/// 第三人称视野
/// </summary>
public int Freq { get; }
[DisplayName("TPS FOV")]
public int TpsFov { get; set; } = 75;
/// <summary>
/// 分辨率
/// </summary>
public int2 Resolution { get; set; }
[DisplayName("分辨率")] public int2 Resolution { get; set; }
/// <summary>
/// 是否全屏
/// </summary>
public bool IsFullScreen { get; set; }
[DisplayName("全屏")] public bool IsFullScreen { get; set; }
[Category("质量")]
[DisplayName("实时反射Cubemap")]public bool RealtimeReflectionProbes { get; set; }
[DisplayName("纹理串流")] public bool TextureStreaming { get; set; }
#if UNITY_5_3_OR_NEWER
[DisplayName("垂直同步")]
public VSyncCount VSyncCount { get; set; }
[DisplayName("实时GI使用率")]
public RealtimeGICPUUsage RealtimeGICPUUsage { get; set; }
[DisplayName("纹理质量")]
public GlobalMipmapLimit GlobalMipmapLimit { get; set; }
[DisplayName("各向异性")] public AnisotropicFiltering AnisotropicFiltering { get; set; }
[DisplayName("阴影模式")] public ShadowmaskMode ShadowmaskMode { get; set; }
[DisplayName("蒙皮权重")] public SkinWeights SkinWeights { get; set; }
#endif
}
}

View File

@ -3,10 +3,10 @@ using System.Collections.Generic;
namespace Project.B.Player
{
public interface IUXKeyMap : IKeyMap
public interface IUXKeyMap<T> : IKeyMap
{
public string CancelKey { get; set; }
public string InventoryKey { get; set; }
public string ConfirmKey { get; set; }
public T CancelKey { get; }
public T InventoryKey { get; }
public T ConfirmKey { get; }
}
}

8
Src/SpotterScope.meta Normal file
View File

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

View File

@ -0,0 +1,28 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Cysharp.Threading.Tasks;
using MemoryPack;
using Unity.Mathematics;
namespace Net.Project.B.World
{
[MemoryPackable]
public partial record SpotterScopeData
{
public string FileName { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public DateTime CreateTime { get; set; }
public float3 Position { get; set; }
public quaternion Rotation { get; set; }
}
public interface ISpotterScopeService
{
public string Directory { get; }
public UniTask<SpotterScopeData> Snapshot(float3 position, quaternion rotation, int fov);
UniTask<IReadOnlyList<SpotterScopeData>> GetSnapshots();
public event Action<SpotterScopeData> OnSnapshot;
}
}

View File

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

View File

@ -0,0 +1,18 @@
{
"name": "Net.Project.B.SpotterScope",
"rootNamespace": "",
"references": [
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
"GUID:d8b63aba1907145bea998dd612889d6b",
"GUID:f51ebe6a0ceec4240a699833d6309b23"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": true
}

View File

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

8
Src/UX.meta Normal file
View File

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

View File

@ -0,0 +1,19 @@
{
"name": "Net.Project.B.UX",
"rootNamespace": "",
"references": [
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
"GUID:f51ebe6a0ceec4240a699833d6309b23",
"GUID:677cd05ca06c46b4395470200b1acdad",
"GUID:5087931ed5612e84ca166071da8e35a4"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": true
}

View File

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

30
Src/UX/UXDefine.cs Normal file
View File

@ -0,0 +1,30 @@
using System.Collections;
using System.Collections.Generic;
using BITKit;
using BITKit.UX;
using Microsoft.Extensions.Logging;
using Net.Project.B.World;
namespace Net.Project.B.UX
{
public interface IUXHud:IUXPanel{}
public interface IUXInitialize:IUXPanel,ILogger<IUXInitialize> {}
public interface IUXBuyStation:IUXPanel{}
public interface IUXControlMode:IUXPanel{}
public interface IUXCosmetics:IUXPanel{}
public interface IUXDialogue:IUXPanel{}
public interface IUXInventory:IUXPanel{}
public interface IUXItemInspector : IUXPanel
{
public void Inspect(IRuntimeItem item);
}
public interface IUXLoadingMap:IUXPanel{}
public interface IUXLobby:IUXPanel{}
public interface IUXMapSelector:IUXPanel{}
public interface IUXSnapshotWindow:IUXPanel
{
void Open(SpotterScopeData scopeData);
}
public interface IUXSnapshot:IUXPanel{}
}

11
Src/UX/UXDefine.cs.meta Normal file
View File

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

View File

@ -4,7 +4,8 @@
"references": [
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
"GUID:d750d221812bb1d48baff92e6ef73e28",
"GUID:49b49c76ee64f6b41bf28ef951cb0e50"
"GUID:49b49c76ee64f6b41bf28ef951cb0e50",
"GUID:f51ebe6a0ceec4240a699833d6309b23"
],
"includePlatforms": [],
"excludePlatforms": [],

View File

@ -0,0 +1,15 @@
using System;
using System.Collections;
using System.Collections.Generic;
using BITKit.WorldNode;
namespace Net.Project.B.WorldNode
{
[Serializable]
public struct UnityBuyStationNode : IWorldNode
{
public int Id { get; set; }
public object WorldObject { get; set; }
}
}

View File

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

View File

@ -0,0 +1,33 @@
using System;
using System.Collections;
using System.Collections.Generic;
using BITKit.WorldNode;
#if UNITY_5_3_OR_NEWER
using UnityEngine;
#endif
namespace Net.Project.B.WorldNode
{
[Serializable]
public class UnityElevatorNode : IWorldNode
{
public int Id { get; set; }
public object WorldObject { get; set; }
#if UNITY_5_3_OR_NEWER
[SerializeField] private GameObject[] floors;
[SerializeField] private GameObject[] floorButtons;
[SerializeField] private Rigidbody platform;
public Rigidbody Platform => platform;
public readonly Dictionary<int, (GameObject floor, GameObject button)> Floors = new();
public void Initialize()
{
for (var index = 0; index < floors.Length; index++)
{
var floor = floors[index];
}
}
#endif
}
}

View File

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

View File

@ -0,0 +1,19 @@
using System;
using System.Collections;
using System.Collections.Generic;
using BITKit;
using BITKit.WorldNode;
using UnityEngine;
namespace Net.Project.B.WorldNode
{
[Serializable]
public struct UnityEntityFactoryNode : IWorldNode
{
public int Id { get; set; }
public object WorldObject { get; set; }
public string address;
public string Address => address;
}
}

View File

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

View File

@ -0,0 +1,42 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using BITKit;
using UnityEngine;
namespace Net.Project.B.WorldNode
{
public class UnityEnvironmentController : MonoBehaviour
{
[SerializeField] private GameObject[] staticGameObjects;
private void OnEnable()
{
if(Application.isEditor)return;
foreach (var staticGameObject in staticGameObjects)
{
staticGameObject.isStatic = true;
}
Debug.Log($"已设置{staticGameObjects.Length}个物体为isStatic");
Destroy(this);
}
private void Start()
{
foreach (var staticGameObject in staticGameObjects)
{
staticGameObject.isStatic = true;
}
Debug.Log($"已设置{staticGameObjects.Length}个物体为isStatic");
}
[ContextMenu("Build Index")]
public void Rebuild()
{
staticGameObjects = GetComponentsInChildren<Transform>().Where(x=>x.gameObject.isStatic).Select(x=>x.gameObject).ToArray();
Debug.Log($"已获取到{staticGameObjects.Length}个物体");
}
}
}

View File

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

View File

@ -17,6 +17,11 @@ namespace Net.Project.B.WorldNode
[SerializeReference, SubclassSelector]
#endif
private IReference itemPath;
public string ItemPath => itemPath.Value;
public string ItemPath
{
get => itemPath.Value;
set => itemPath = new Reference(value);
}
}
}

View File

@ -0,0 +1,57 @@
using System;
using System.Collections;
using System.Collections.Generic;
using BITKit.WorldNode;
#if UNITY_5_3_OR_NEWER
using BITKit.Entities;
using UnityEngine;
using UnityEngine.Events;
#endif
namespace Net.Project.B.WorldNode
{
[Serializable]
public class UnitySeatNode :IWorldNode
{
public int Id { get; set; }
public object WorldObject { get; set; }
#if UNITY_5_3_OR_NEWER
[SerializeField]private float cameraDistance= 2;
public Rigidbody Rigidbody;
public Transform SeatObject;
public Transform CameraObject;
public Transform ExitObject;
public IEntity Occupant
{
get => _occupant;
set
{
if(Equals(_occupant,value))return;
_occupant = value;
onOccupantChanged.Invoke(_occupant);
onOccupantArrived.Invoke(_occupant!=null);
}
}
private IEntity _occupant;
[SerializeField]private UnityEvent<bool> onOccupantArrived;
[SerializeField]private UnityEvent<IEntity> onOccupantChanged;
public event Action<bool> OnOccupantArrived
{
add => onOccupantArrived.AddListener(value.Invoke);
remove => onOccupantArrived.RemoveListener(value.Invoke);
}
public event Action<IEntity> OnOccupantChanged
{
add => onOccupantChanged.AddListener(value.Invoke);
remove => onOccupantChanged.RemoveListener(value.Invoke);
}
public float CameraDistance => cameraDistance;
#endif
}
}

View File

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