This commit is contained in:
CortexCore 2025-03-03 18:43:55 +08:00
parent 54f40090c9
commit 4402ae533b
32 changed files with 337 additions and 73 deletions

8
Src/Bullet.meta Normal file
View File

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

24
Src/Bullet/Bullet.cs Normal file
View File

@ -0,0 +1,24 @@
using System;
using System.Collections;
using System.Collections.Generic;
using BITKit;
using Unity.Mathematics;
using System.IO;
namespace BITFALL
{
public record BulletData
{
public uint Token;
public int Initiator;
public float3 Position;
public quaternion Rotation;
public float3 Forward;
public float CreateTime;
public int InitialForce;
public int StartSpeed;
public int MaxDamage;
public int InitialDamage;
public ulong AddressId;
}
}

11
Src/Bullet/Bullet.cs.meta Normal file
View File

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

View File

@ -0,0 +1,7 @@
namespace BITFALL.Bullet
{
public interface IBulletService
{
void Spawn(BulletData bulletData);
}
}

View File

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

View File

@ -0,0 +1,17 @@
{
"name": "Project.B.Bullet",
"rootNamespace": "",
"references": [
"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: fa168fa3b467b4245bd3ceb2dac420b4
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,6 +1,8 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Threading;
using Cysharp.Threading.Tasks;
namespace Net.Project.B.Dialogue namespace Net.Project.B.Dialogue
{ {
@ -33,7 +35,15 @@ namespace Net.Project.B.Dialogue
/// 等待对话完成 /// 等待对话完成
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
TaskAwaiter GetAwaiter(); CancellationTokenAwaitable.Awaiter GetAwaiter();
/// <summary>
/// 跳过对话
/// </summary>
public CancellationTokenSource CancellationTokenSource { get; set; }
/// <summary>
/// 元对象
/// </summary>
public object MetaObject { get; set; }
} }
/// <summary> /// <summary>
/// 对话选择 /// 对话选择
@ -64,10 +74,9 @@ namespace Net.Project.B.Dialogue
public int ActorIdentity { get; set; } public int ActorIdentity { get; set; }
public string Text { get; set; } public string Text { get; set; }
public string VoicePath { get; set; } public string VoicePath { get; set; }
public TaskAwaiter GetAwaiter() public CancellationTokenAwaitable.Awaiter GetAwaiter() => CancellationTokenSource.Token.WaitUntilCanceled().GetAwaiter();
{ public CancellationTokenSource CancellationTokenSource { get; set; }
throw new System.NotImplementedException(); public object MetaObject { get; set; }
}
} }
public struct DialogueChoice:IDialogueChoice public struct DialogueChoice:IDialogueChoice
{ {

View File

@ -4,6 +4,7 @@ using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Linq; using System.Linq;
using System.Threading;
using BITKit; using BITKit;
using Cysharp.Threading.Tasks; using Cysharp.Threading.Tasks;
@ -57,9 +58,10 @@ namespace Net.Project.B.Dialogue
public event Action<IDialogueData> OnDialogueEnd; public event Action<IDialogueData> OnDialogueEnd;
public event Func<IDialogueData, IReadOnlyCollection<IDialogueChoice>, UniTask<int>> OnDialogueChoose; public event Func<IDialogueData, IReadOnlyCollection<IDialogueChoice>, UniTask<int>> OnDialogueChoose;
public event Action<IDialogueData, IDialogueChoice> OnDialogueChose; public event Action<IDialogueData, IDialogueChoice> OnDialogueChose;
public async UniTask CreateDialogue(IDialogueData dialogueData) public async UniTask CreateDialogue(IDialogueData dialogueData)
{ {
dialogueData.CancellationTokenSource ??= new CancellationTokenSource();
if (_dialogues.TryAdd(dialogueData.Identity, dialogueData) is false) if (_dialogues.TryAdd(dialogueData.Identity, dialogueData) is false)
{ {
dialogueData.Identity = _dialogues.Keys.Max() + 1; dialogueData.Identity = _dialogues.Keys.Max() + 1;
@ -68,7 +70,8 @@ namespace Net.Project.B.Dialogue
try try
{ {
await OnDialogueStart.UniTaskFunc(dialogueData); await OnDialogueStart.UniTaskFunc(dialogueData)
.AttachExternalCancellation(dialogueData.CancellationTokenSource.Token);
} }
catch (OperationCanceledException) catch (OperationCanceledException)
{ {
@ -78,10 +81,13 @@ namespace Net.Project.B.Dialogue
{ {
} }
finally
{
dialogueData.CancellationTokenSource.Cancel();
OnDialogueEnd?.Invoke(dialogueData); OnDialogueEnd?.Invoke(dialogueData);
} }
}
public async UniTask<int> CreateDialogue(IDialogueData dialogueData, public async UniTask<int> CreateDialogue(IDialogueData dialogueData,
IReadOnlyCollection<IDialogueChoice> dialogueChoices) IReadOnlyCollection<IDialogueChoice> dialogueChoices)

View File

@ -1,7 +1,9 @@
{ {
"name": "Com.Project.B.Interaction", "name": "Com.Project.B.Interaction",
"rootNamespace": "", "rootNamespace": "",
"references": [], "references": [
"GUID:d750d221812bb1d48baff92e6ef73e28"
],
"includePlatforms": [], "includePlatforms": [],
"excludePlatforms": [], "excludePlatforms": [],
"allowUnsafeCode": false, "allowUnsafeCode": false,
@ -10,5 +12,5 @@
"autoReferenced": true, "autoReferenced": true,
"defineConstraints": [], "defineConstraints": [],
"versionDefines": [], "versionDefines": [],
"noEngineReferences": true "noEngineReferences": false
} }

View File

@ -13,6 +13,7 @@ namespace Net.Project.B.Interaction
Tap, Tap,
Hold, Hold,
Performed, Performed,
System,
} }
/// <summary> /// <summary>
/// 可互动类型 /// 可互动类型

View File

@ -0,0 +1,25 @@
using System;
using System.Collections;
using System.Collections.Generic;
using BITKit.WorldNode;
using UnityEngine;
#if UNITY_5_3_OR_NEWER
namespace Net.Project.B.Interaction
{
[Serializable]
public class WorldInteractable : IWorldInteractable,IWorldNode
{
public GameObject gameObject;
public int Id => gameObject.GetInstanceID();
public IWorldInteractable Root => this;
public IWorldInteractionType InteractionType => null;
public object WorldObject
{
get => gameObject;
set => throw new NotImplementedException("Can do that");
}
}
}
#endif

View File

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

View File

@ -0,0 +1,11 @@
using System.Collections.Generic;
namespace Project.B.Player
{
public interface ICarKeyMap<T>:IKeyMap
{
public T VerticalKey { get; }
public T HorizontalKey { get; }
public T HandBrakeKey { get; }
}
}

View File

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

View File

@ -13,7 +13,16 @@ namespace Net.Project.B.UX
public interface IUXControlMode:IUXPanel{} public interface IUXControlMode:IUXPanel{}
public interface IUXCosmetics:IUXPanel{} public interface IUXCosmetics:IUXPanel{}
public interface IUXDialogue:IUXPanel{} public interface IUXDialogue:IUXPanel{}
public interface IUXInventory:IUXPanel{}
public interface IUXInventory : IUXPanel
{
public ItemQuality AutoInspect { get; set; }
}
public interface IUXInventoryPrompt : IUXPanel
{
}
public interface IUXItemInspector : IUXPanel public interface IUXItemInspector : IUXPanel
{ {
@ -27,4 +36,6 @@ namespace Net.Project.B.UX
void Open(SpotterScopeData scopeData); void Open(SpotterScopeData scopeData);
} }
public interface IUXSnapshot:IUXPanel{} public interface IUXSnapshot:IUXPanel{}
public interface IUXInventorySwap:IUXPanel{}
public interface IUXMap:IUXPanel{}
} }

View File

@ -0,0 +1,20 @@
using System;
using System.Collections;
using System.Collections.Generic;
using BITKit.Entities;
using Net.Project.B.WorldNode;
using UnityEngine;
namespace Net.Project.B.World
{
public interface IWorldSeatService
{
IReadOnlyDictionary<int, UnitySeatNode> SeatNodes { get; }
IReadOnlyDictionary<int,IEntity> SeatEntities { get; }
public bool TryGetOccupyingEntity(int id,out UnitySeatNode seatNode, out IEntity entity);
public event Action<UnitySeatNode,IEntity,IEntity> OnSeatOccupied;
public bool OccupySeat(int seatId, IEntity entity);
public bool UnOccupySeat(int seatId,out IEntity entity);
}
}

View File

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

View File

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

View File

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

View File

@ -6,10 +6,8 @@ using BITKit.WorldNode;
namespace Net.Project.B.WorldNode namespace Net.Project.B.WorldNode
{ {
[Serializable] [Serializable]
public struct UnityBuyStationNode : IWorldNode public class UnityBuyStationNode : IWorldNode
{ {
public int Id { get; set; }
public object WorldObject { get; set; }
} }
} }

View File

@ -0,0 +1,23 @@
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 struct UnityContainerNode :IWorldNode
{
/// <summary>
/// 添加物品
/// </summary>
public bool AllowAdd { get; set; }
/// <summary>
/// 移除物品
/// </summary>
public bool AllowRemove { get; set; }
}
}

View File

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

View File

@ -2,6 +2,7 @@ using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using BITKit.WorldNode; using BITKit.WorldNode;
using Net.Project.B.Interaction;
#if UNITY_5_3_OR_NEWER #if UNITY_5_3_OR_NEWER
using UnityEngine; using UnityEngine;
#endif #endif
@ -17,12 +18,14 @@ namespace Net.Project.B.WorldNode
Locked, Locked,
} }
[Serializable] [Serializable]
public struct UnityDoorNode:IWorldNode public class UnityDoorNode:IWorldNode
{ {
public int Id { get; set; } public int Id { get; set; }
public object WorldObject { get; set; } public object WorldObject { get; set; }
public UnityDoorState State; public UnityDoorState State;
public WorldInteractionProcess InteractionType;
#if UNITY_5_3_OR_NEWER #if UNITY_5_3_OR_NEWER
public Transform DoorTransform;
public Vector3 OpenPosition; public Vector3 OpenPosition;
public Vector3 ClosePosition; public Vector3 ClosePosition;
public Vector3 OpenEulerAngles; public Vector3 OpenEulerAngles;

View File

@ -12,8 +12,6 @@ namespace Net.Project.B.WorldNode
[Serializable] [Serializable]
public class UnityElevatorNode : IWorldNode public class UnityElevatorNode : IWorldNode
{ {
public int Id { get; set; }
public object WorldObject { get; set; }
#if UNITY_5_3_OR_NEWER #if UNITY_5_3_OR_NEWER
[SerializeField] private GameObject[] floors; [SerializeField] private GameObject[] floors;
[SerializeField] private GameObject[] floorButtons; [SerializeField] private GameObject[] floorButtons;

View File

@ -8,7 +8,7 @@ using UnityEngine;
namespace Net.Project.B.WorldNode namespace Net.Project.B.WorldNode
{ {
[Serializable] [Serializable]
public struct UnityEntityFactoryNode : IWorldNode public class UnityEntityFactoryNode : IWorldNode
{ {
public int Id { get; set; } public int Id { get; set; }
public object WorldObject { get; set; } public object WorldObject { get; set; }

View File

@ -14,20 +14,13 @@ namespace Net.Project.B.WorldNode
private void OnEnable() private void OnEnable()
{ {
if(Application.isEditor)return; if(Application.isEditor)return;
foreach (var staticGameObject in staticGameObjects) Execute();
{
staticGameObject.isStatic = true;
}
Debug.Log($"已设置{staticGameObjects.Length}个物体为isStatic");
Destroy(this); Destroy(this);
} }
private void Start() private void Start()
{ {
foreach (var staticGameObject in staticGameObjects) Execute();
{ Destroy(this);
staticGameObject.isStatic = true;
}
Debug.Log($"已设置{staticGameObjects.Length}个物体为isStatic");
} }
[ContextMenu("Build Index")] [ContextMenu("Build Index")]
@ -36,6 +29,22 @@ namespace Net.Project.B.WorldNode
staticGameObjects = GetComponentsInChildren<Transform>().Where(x=>x.gameObject.isStatic).Select(x=>x.gameObject).ToArray(); staticGameObjects = GetComponentsInChildren<Transform>().Where(x=>x.gameObject.isStatic).Select(x=>x.gameObject).ToArray();
Debug.Log($"已获取到{staticGameObjects.Length}个物体"); Debug.Log($"已获取到{staticGameObjects.Length}个物体");
} }
private void Execute()
{
var lost = 0;
foreach (var staticGameObject in staticGameObjects)
{
if (staticGameObject)
{
staticGameObject.isStatic = true;
continue;
}
lost++;
}
Debug.Log($"已设置{staticGameObjects.Length}个物体为isStatic,丢失了:{lost}个");
}
} }
} }

View File

@ -9,10 +9,8 @@ using UnityEngine;
namespace Net.Project.B.WorldNode namespace Net.Project.B.WorldNode
{ {
[Serializable] [Serializable]
public struct UnityItemNode : IWorldNode public class UnityItemNode : IWorldNode
{ {
public int Id { get; set; }
public object WorldObject { get; set; }
#if UNITY_5_3_OR_NEWER #if UNITY_5_3_OR_NEWER
[SerializeReference, SubclassSelector] [SerializeReference, SubclassSelector]
#endif #endif

View File

@ -6,9 +6,8 @@ using BITKit.WorldNode;
namespace Net.Project.B.WorldNode namespace Net.Project.B.WorldNode
{ {
[Serializable] [Serializable]
public struct UnityMinimapNode : IWorldNode public class UnityMinimapNode : IWorldNode
{ {
public int Id { get; set; }
public object WorldObject { get; set; }
} }
} }

View File

@ -3,9 +3,7 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using BITKit.WorldNode; using BITKit.WorldNode;
#if UNITY_5_3_OR_NEWER #if UNITY_5_3_OR_NEWER
using BITKit.Entities;
using UnityEngine; using UnityEngine;
using UnityEngine.Events;
#endif #endif
namespace Net.Project.B.WorldNode namespace Net.Project.B.WorldNode
@ -14,43 +12,13 @@ namespace Net.Project.B.WorldNode
public class UnitySeatNode :IWorldNode public class UnitySeatNode :IWorldNode
{ {
public int Id { get; set; } public int Id { get; set; }
public object WorldObject { get; set; }
#if UNITY_5_3_OR_NEWER #if UNITY_5_3_OR_NEWER
[SerializeField]private float cameraDistance= 2; public float cameraDistance= 2;
public Rigidbody Rigidbody; public Rigidbody Rigidbody;
public Transform SeatObject; public Transform SeatObject;
public Transform CameraObject; public Transform CameraObject;
public Transform ExitObject; 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; public float CameraDistance => cameraDistance;
#endif #endif
} }

View File

@ -0,0 +1,41 @@
using System;
using System.Collections;
using System.Collections.Generic;
using BITKit.WorldNode;
using UnityEngine;
namespace Net.Project.B.WorldNode
{
[Serializable]
public class UnityVehicleNode : IWorldNode
{
public Rigidbody rigidbody;
public GameObject seatObject;
public WheelCollider[] steeringWheelColliders;
public WheelCollider[] driveWheelColliders;
public WheelCollider[] handBrakeWheelColliders;
public WheelCollider[] wheels;
public Transform[] wheelMeshes;
public Transform steeringWheel;
public bool allowAckermannSteering;
public float maxForwardSpeed = 100f; // 100f default
public float maxReverseSpeed = 30f; // 30f default
public float horsePower = 1000f; // 100f0 default
public float brakePower = 2000f; // 2000f default
public float handbrakeForce = 3000f; // 3000f default
public float maxSteerAngle = 30f; // 30f default
public float steeringSpeed = 5f; // 0.5f default
public float stopThreshold = 1f; // 1f default. At what speed car will make a full stop
public float decelerationSpeed = 0.5f; // 0.5f default
public int Id { get; set; }
public object WorldObject { get; set; }
}
}

View File

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