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

View File

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

View File

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

View File

@@ -12,8 +12,6 @@ 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;

View File

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

View File

@@ -14,20 +14,13 @@ namespace Net.Project.B.WorldNode
private void OnEnable()
{
if(Application.isEditor)return;
foreach (var staticGameObject in staticGameObjects)
{
staticGameObject.isStatic = true;
}
Debug.Log($"已设置{staticGameObjects.Length}个物体为isStatic");
Execute();
Destroy(this);
}
private void Start()
{
foreach (var staticGameObject in staticGameObjects)
{
staticGameObject.isStatic = true;
}
Debug.Log($"已设置{staticGameObjects.Length}个物体为isStatic");
Execute();
Destroy(this);
}
[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();
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
{
[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
[SerializeReference, SubclassSelector]
#endif

View File

@@ -6,9 +6,8 @@ using BITKit.WorldNode;
namespace Net.Project.B.WorldNode
{
[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 BITKit.WorldNode;
#if UNITY_5_3_OR_NEWER
using BITKit.Entities;
using UnityEngine;
using UnityEngine.Events;
#endif
namespace Net.Project.B.WorldNode
@@ -14,43 +12,13 @@ namespace Net.Project.B.WorldNode
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 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,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: