diff --git a/Com.Project.B.7z b/Com.Project.B.7z new file mode 100644 index 0000000..dc90ff6 Binary files /dev/null and b/Com.Project.B.7z differ diff --git a/Src/Damage/IDamageService.cs b/Src/Damage/IDamageService.cs index d112a74..61563e7 100644 --- a/Src/Damage/IDamageService.cs +++ b/Src/Damage/IDamageService.cs @@ -2,7 +2,6 @@ using System; using System.Collections; using System.Collections.Generic; using Cysharp.Threading.Tasks; -using UnityEngine; namespace Net.Project.B.Damage { diff --git a/Src/Entities/IEntitiesFactory.cs b/Src/Entities/IEntitiesFactory.cs index d44bf82..cb4cd2d 100644 --- a/Src/Entities/IEntitiesFactory.cs +++ b/Src/Entities/IEntitiesFactory.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using BITKit.Entities; using Cysharp.Threading.Tasks; -using UnityEngine; namespace Project.B.Entities { @@ -12,7 +11,7 @@ namespace Project.B.Entities public interface IEntitiesFactory:IDisposable { IReadOnlyDictionary Entities { get; } - UniTask CreateAsync(string addressablePath,GameObject model); + UniTask CreateAsync(string addressablePath,object model); public event Func OnEntityCreate; public event Func OnEntityCreated; } diff --git a/Src/Faction/FactionTypes.cs b/Src/Faction/FactionTypes.cs index b10d378..98d51ab 100644 --- a/Src/Faction/FactionTypes.cs +++ b/Src/Faction/FactionTypes.cs @@ -1,6 +1,5 @@ using System.Collections; using System.Collections.Generic; -using UnityEngine; namespace Net.Project.B.Faction { diff --git a/Src/GameService/IGameMapService.cs b/Src/GameService/IGameMapService.cs index 773717b..ea24c24 100644 --- a/Src/GameService/IGameMapService.cs +++ b/Src/GameService/IGameMapService.cs @@ -49,7 +49,10 @@ namespace Project.B.Map /// 切换场景后 /// event Action OnMapChanged; - + /// + /// 切换场景后,加载完成 + /// + event Action OnMapChangeCompleted; /// /// 地图加载进度 /// diff --git a/Src/GameService/ScriptableGameMapData.cs b/Src/GameService/ScriptableGameMapData.cs index 84f6862..c5a4ee1 100644 --- a/Src/GameService/ScriptableGameMapData.cs +++ b/Src/GameService/ScriptableGameMapData.cs @@ -12,11 +12,15 @@ namespace Project.B.Map [SerializeField] private string author; [SerializeField] private string mapAddress; [SerializeField] private Texture overview; + [SerializeField] private Vector2 offset; + [SerializeField] private int size; public string MapName => mapName; public string Author => author; public string Description => description; public object Overview => overview; public string MapAddress => mapAddress; + public Vector2 Offset => offset; + public int Size => size; } } #endif \ No newline at end of file diff --git a/Src/Interaction/WorldInteractable.cs b/Src/Interaction/WorldInteractable.cs index 11f2b4e..aabccd7 100644 --- a/Src/Interaction/WorldInteractable.cs +++ b/Src/Interaction/WorldInteractable.cs @@ -2,9 +2,9 @@ using System; using System.Collections; using System.Collections.Generic; using BITKit.WorldNode; -using UnityEngine; #if UNITY_5_3_OR_NEWER +using UnityEngine; namespace Net.Project.B.Interaction { [Serializable] diff --git a/Src/Inventory/IPlayerEquipmentInventory.cs b/Src/Inventory/IPlayerEquipmentInventory.cs index 0bc02e9..ca3cba4 100644 --- a/Src/Inventory/IPlayerEquipmentInventory.cs +++ b/Src/Inventory/IPlayerEquipmentInventory.cs @@ -3,7 +3,6 @@ using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using BITKit; -using UnityEngine; namespace Net.Project.B.Inventory { diff --git a/Src/PlayerSettings/IPlayerSettings.cs b/Src/PlayerSettings/IPlayerSettings.cs index 7248b9b..5941d3c 100644 --- a/Src/PlayerSettings/IPlayerSettings.cs +++ b/Src/PlayerSettings/IPlayerSettings.cs @@ -29,6 +29,7 @@ namespace Project.B.Player QuarterResolution, EighthResolution, } + #endif public enum Lang { [Description("zh-CN")] @@ -38,7 +39,6 @@ namespace Project.B.Player [Description("ja-JP")] JP, } - #endif /// /// 玩家设置 /// diff --git a/Src/UX/UXDefine.cs b/Src/UX/UXDefine.cs index 76c374a..ef4c10c 100644 --- a/Src/UX/UXDefine.cs +++ b/Src/UX/UXDefine.cs @@ -17,7 +17,7 @@ namespace Net.Project.B.UX public interface IUXDialogue : IUXPanel { event Func OnSubtitle; - public string SubtitleLanguage { get; set; } + public string[] SubtitleLanguages { get; set; } } public interface IUXInventory : IUXPanel diff --git a/Src/World/IWorldSeatService.cs b/Src/World/IWorldSeatService.cs index 23669f8..a7148eb 100644 --- a/Src/World/IWorldSeatService.cs +++ b/Src/World/IWorldSeatService.cs @@ -3,7 +3,9 @@ using System.Collections; using System.Collections.Generic; using BITKit.Entities; using Net.Project.B.WorldNode; +#if UNITY_5_3_OR_NEWER using UnityEngine; +#endif namespace Net.Project.B.World { diff --git a/Src/WorldNode/Net.Project.B.WorldNode.asmdef b/Src/WorldNode/Net.Project.B.WorldNode.asmdef index ce3cf0a..abefec4 100644 --- a/Src/WorldNode/Net.Project.B.WorldNode.asmdef +++ b/Src/WorldNode/Net.Project.B.WorldNode.asmdef @@ -7,7 +7,9 @@ "GUID:49b49c76ee64f6b41bf28ef951cb0e50", "GUID:f51ebe6a0ceec4240a699833d6309b23", "GUID:e527b3ce3106f974585be5134b6200e9", - "GUID:e18d548755c9bc8458ca189e16813742" + "GUID:e18d548755c9bc8458ca189e16813742", + "GUID:d8b63aba1907145bea998dd612889d6b", + "GUID:1193c2664d97cc049a6e4c486c6bce71" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/Src/WorldNode/UnityEntityFactoryNode.cs b/Src/WorldNode/UnityEntityFactoryNode.cs index c0ec185..f622e33 100644 --- a/Src/WorldNode/UnityEntityFactoryNode.cs +++ b/Src/WorldNode/UnityEntityFactoryNode.cs @@ -3,7 +3,6 @@ using System.Collections; using System.Collections.Generic; using BITKit; using BITKit.WorldNode; -using UnityEngine; namespace Net.Project.B.WorldNode { diff --git a/Src/WorldNode/UnityEnvironmentController.cs b/Src/WorldNode/UnityEnvironmentController.cs index 0430c47..499654d 100644 --- a/Src/WorldNode/UnityEnvironmentController.cs +++ b/Src/WorldNode/UnityEnvironmentController.cs @@ -1,32 +1,44 @@ +#if UNITY_5_3_OR_NEWER using System; using System.Collections; using System.Collections.Generic; using System.Linq; using BITKit; using UnityEngine; +using UnityEngine.Events; namespace Net.Project.B.WorldNode { public class UnityEnvironmentController : MonoBehaviour { + [SerializeField] private GameObject[] searchGameObjects; [SerializeField] private GameObject[] staticGameObjects; - - private void OnEnable() - { - if(Application.isEditor)return; - Execute(); - Destroy(this); - } + [SerializeField] private UnityEvent onCompleted; private void Start() { Execute(); + onCompleted?.Invoke(); Destroy(this); } [ContextMenu("Build Index")] public void Rebuild() { - staticGameObjects = GetComponentsInChildren().Where(x=>x.gameObject.isStatic).Select(x=>x.gameObject).ToArray(); + if (searchGameObjects is { Length: > 0 }) + { + var hashSet = new HashSet(); + foreach (var searchGameObject in searchGameObjects) + { + if (!searchGameObject) continue; + hashSet.UnionWith(searchGameObject.GetComponentsInChildren()); + } + staticGameObjects = hashSet.Select(x => x.gameObject).ToArray(); + } + else + { + staticGameObjects = GetComponentsInChildren().Where(x=>x.gameObject.isStatic).Select(x=>x.gameObject).ToArray(); + } + Debug.Log($"已获取到{staticGameObjects.Length}个物体"); } @@ -49,3 +61,4 @@ namespace Net.Project.B.WorldNode } +#endif \ No newline at end of file diff --git a/Src/WorldNode/UnityLootNode.cs b/Src/WorldNode/UnityLootNode.cs index 320f17f..f290818 100644 --- a/Src/WorldNode/UnityLootNode.cs +++ b/Src/WorldNode/UnityLootNode.cs @@ -3,7 +3,9 @@ using System.Collections; using System.Collections.Generic; using BITKit; using BITKit.WorldNode; +#if UNITY_5_3_OR_NEWER using UnityEngine; +#endif namespace Net.Project.B.WorldNode { diff --git a/Src/WorldNode/UnityNpcSpawnAreaNode.cs b/Src/WorldNode/UnityNpcSpawnAreaNode.cs index dc9d603..615fcc7 100644 --- a/Src/WorldNode/UnityNpcSpawnAreaNode.cs +++ b/Src/WorldNode/UnityNpcSpawnAreaNode.cs @@ -2,7 +2,6 @@ using System; using System.Collections; using System.Collections.Generic; using BITKit.WorldNode; -using UnityEngine; namespace Net.Project.B.WorldNode { diff --git a/Src/WorldNode/UnitySeatNode.cs b/Src/WorldNode/UnitySeatNode.cs index 3891fe2..0dd9583 100644 --- a/Src/WorldNode/UnitySeatNode.cs +++ b/Src/WorldNode/UnitySeatNode.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using BITKit.WorldNode; #if UNITY_5_3_OR_NEWER using UnityEngine; +using UnityEngine.Experimental.GlobalIllumination; #endif namespace Net.Project.B.WorldNode @@ -12,6 +13,7 @@ namespace Net.Project.B.WorldNode public class UnitySeatNode :IWorldNode { public int Id { get; set; } + public bool hidePlayer; #if UNITY_5_3_OR_NEWER public float cameraDistance= 2; public Rigidbody Rigidbody; @@ -20,6 +22,7 @@ namespace Net.Project.B.WorldNode public Transform ExitObject; public float CameraDistance => cameraDistance; + public bool HidePlayer => hidePlayer; #endif } } diff --git a/Src/WorldNode/UnityVegetationNode.cs b/Src/WorldNode/UnityVegetationNode.cs new file mode 100644 index 0000000..442ba4a --- /dev/null +++ b/Src/WorldNode/UnityVegetationNode.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using BITKit; +using MemoryPack; +using Net.BITKit.Quadtree; +using Unity.Mathematics; +#if UNITY_EDITOR +using UnityEditor; +#endif +#if UNITY_5_3_OR_NEWER +using UnityEngine; +using UnityEngine.SceneManagement; + +namespace Net.Project.B.WorldNode +{ + public class UnityVegetationNode : MonoBehaviour + { + [SerializeField] private float3[] positions; + [SerializeField] private float2 sizeFactor; + + [SerializeField] private GameObject searchPrefab; + + private Mesh _mesh; + private Mesh[] _subMeshes; + private Material[] _materials; + private List _matrix4; + + private readonly Quadtree _quadtree=new(default,new float2(2048,2048)); + private void Start() + { + _mesh = searchPrefab.GetComponentInChildren().sharedMesh; + _materials = searchPrefab.GetComponentInChildren().sharedMaterials; + + _matrix4 = new List(); + for (var i = 0; i < positions.Length; i++) + { + var position = positions[i]; + var matrix = Matrix4x4.TRS(position, Quaternion.identity, Vector3.one); + _matrix4.Add(matrix); + + _quadtree.Insert(i,position.xz); + } + } + private void Update() + { + + for (var i = 0; i < _mesh.subMeshCount; i++) + { + Graphics.DrawMeshInstanced(_mesh,i,_materials[i],_matrix4); + } + } + +#if UNITY_EDITOR + private void OnDrawGizmosSelected() + { + foreach (var position in positions) + { + Gizmos.DrawCube(position,Vector3.one); + } + } + [ContextMenu(nameof(Search))] + private void Search() + { + var positionList = new List(); + + var allObjects = GameObject.FindObjectsOfType(); + + foreach (var obj in allObjects) + { + if (PrefabUtility.GetPrefabAssetType(obj) is not (PrefabAssetType.Regular or PrefabAssetType.Variant)) continue; + if (PrefabUtility.IsAnyPrefabInstanceRoot(obj) is false) continue; + var source = PrefabUtility.GetCorrespondingObjectFromOriginalSource(obj); + if(source!=searchPrefab)continue; + positionList.Add(obj.transform.position); + } + + Debug.Log($"已获取到{positionList.Count}个预制体"); + positions = positionList.ToArray(); + } + #endif + } +} + +#endif \ No newline at end of file diff --git a/Src/WorldNode/UnityVegetationNode.cs.meta b/Src/WorldNode/UnityVegetationNode.cs.meta new file mode 100644 index 0000000..3d85390 --- /dev/null +++ b/Src/WorldNode/UnityVegetationNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9c438cc0299e15c4cb3706d97b11f726 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Src/WorldNode/UnityVehicleNode.cs b/Src/WorldNode/UnityVehicleNode.cs index c5a38da..d361052 100644 --- a/Src/WorldNode/UnityVehicleNode.cs +++ b/Src/WorldNode/UnityVehicleNode.cs @@ -2,13 +2,16 @@ 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 UnityVehicleNode : IWorldNode { +#if UNITY_5_3_OR_NEWER public Rigidbody rigidbody; public GameObject seatObject; @@ -36,6 +39,8 @@ namespace Net.Project.B.WorldNode public int Id { get; set; } public object WorldObject { get; set; } + +#endif } } diff --git a/Src/WorldNode/UnityWorldChunkNode.cs b/Src/WorldNode/UnityWorldChunkNode.cs new file mode 100644 index 0000000..9db493d --- /dev/null +++ b/Src/WorldNode/UnityWorldChunkNode.cs @@ -0,0 +1,22 @@ +#if UNITY_5_3_OR_NEWER +using System; +using System.Collections; +using System.Collections.Generic; +using BITKit.WorldNode; +using UnityEngine; + +namespace Net.Project.B +{ + [Serializable] + public sealed class UnityWorldChunkNode : IWorldNode + { + public string sceneName; + public bool includeColliders; + public GameObject lodGameObject; + public GameObject GameObject { get; set; } + public Bounds Bounds { get; set; } + } +} + + +#endif \ No newline at end of file diff --git a/Src/WorldNode/UnityWorldChunkNode.cs.meta b/Src/WorldNode/UnityWorldChunkNode.cs.meta new file mode 100644 index 0000000..662e53a --- /dev/null +++ b/Src/WorldNode/UnityWorldChunkNode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b0193be905ce2324a9f256a141778218 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: