mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交
This commit is contained in:
@@ -38,7 +38,7 @@ namespace Pathfinding.Examples {
|
||||
// Rotate character to face the correct direction
|
||||
while (true) {
|
||||
var origRotation = ai.rotation;
|
||||
var finalRotation = ai.SimulateRotationTowards(rs.first.forward, ai.rotationSpeed * Time.deltaTime);
|
||||
var finalRotation = ai.SimulateRotationTowards(rs.first.forward, ai.rotationSpeed * GetSync().Time.deltaTime);
|
||||
// Rotate until the rotation does not change anymore
|
||||
if (origRotation == finalRotation) break;
|
||||
ai.FinalizeMovement(ai.position, finalRotation);
|
||||
|
@@ -42,7 +42,7 @@ namespace Pathfinding {
|
||||
/// If AstarPath.batchGraphUpdates is enabled, it is not beneficial to have a checkTime much lower
|
||||
/// than AstarPath.graphUpdateBatchingInterval because that will just add extra unnecessary graph updates.
|
||||
///
|
||||
/// In real time seconds (based on Time.realtimeSinceStartup).
|
||||
/// In real time seconds (based on GetSync().Time.realtimeSinceStartup).
|
||||
/// </summary>
|
||||
public float checkTime = 0.2F;
|
||||
|
||||
@@ -105,7 +105,9 @@ namespace Pathfinding {
|
||||
if (coll != null) prevEnabled = colliderEnabled;
|
||||
}
|
||||
|
||||
void Update () {
|
||||
public override void OnSyncUpdate(int dt, JNFrameInfo frame, Object input)
|
||||
{
|
||||
base.OnSyncUpdate(dt, frame, input);
|
||||
if (!Application.isPlaying) return;
|
||||
|
||||
if (coll == null && coll2D == null) {
|
||||
@@ -121,11 +123,11 @@ namespace Pathfinding {
|
||||
pendingGraphUpdates.Dequeue();
|
||||
}
|
||||
|
||||
if (AstarPath.active == null || AstarPath.active.isScanning || Time.realtimeSinceStartup - lastCheckTime < checkTime || !Application.isPlaying || pendingGraphUpdates.Count > 0) {
|
||||
if (AstarPath.active == null || AstarPath.active.isScanning || GetSync().Time.realtimeSinceStartup - lastCheckTime < checkTime || !Application.isPlaying || pendingGraphUpdates.Count > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
lastCheckTime = Time.realtimeSinceStartup;
|
||||
lastCheckTime = GetSync().Time.realtimeSinceStartup;
|
||||
if (colliderEnabled) {
|
||||
// The current bounds of the collider
|
||||
Bounds newBounds = bounds;
|
||||
@@ -141,7 +143,7 @@ namespace Pathfinding {
|
||||
|
||||
// If the difference between the previous bounds and the new bounds is greater than some value, update the graphs
|
||||
if (minDiff.sqrMagnitude > updateError*updateError || maxDiff.sqrMagnitude > updateError*updateError ||
|
||||
errorFromRotation > updateError || !prevEnabled) {
|
||||
errorFromRotation > updateError || !prevEnabled) {
|
||||
// Update the graphs as soon as possible
|
||||
DoUpdateGraphs();
|
||||
}
|
||||
@@ -225,7 +227,7 @@ namespace Pathfinding {
|
||||
prevRotation = tr.rotation;
|
||||
|
||||
// Set this here as well since the DoUpdateGraphs method can be called from other scripts
|
||||
lastCheckTime = Time.realtimeSinceStartup;
|
||||
lastCheckTime = GetSync().Time.realtimeSinceStartup;
|
||||
}
|
||||
|
||||
/// <summary>Volume of a Bounds object. X*Y*Z</summary>
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using Pathfinding.Util;
|
||||
using System.Collections.Generic;
|
||||
using Game.Plugins.App.Util;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Pathfinding {
|
||||
@@ -434,7 +435,7 @@ namespace Pathfinding {
|
||||
// the chances next time
|
||||
clearanceRadius *= 0.9f;
|
||||
// This will pick points in 2D closer to the edge of the circle with a higher probability
|
||||
dir = Random.onUnitSphere * Mathf.Lerp(newMagn, radius, tests / 5);
|
||||
dir = JNRandom.onUnitSphere * Mathf.Lerp(newMagn, radius, tests / 5);
|
||||
dir.y = 0;
|
||||
tests++;
|
||||
}
|
||||
@@ -500,7 +501,7 @@ namespace Pathfinding {
|
||||
}
|
||||
|
||||
// Pick a random node among the ones in the list weighted by their area
|
||||
float tg = Random.value*tot;
|
||||
float tg = JNRandom.value*tot;
|
||||
int v = accs.BinarySearch(tg);
|
||||
if (v < 0) v = ~v;
|
||||
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using Plugins.JNGame.Sync.Frame.Entity;
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
using UnityEngine.Profiling;
|
||||
#endif
|
||||
@@ -244,7 +245,7 @@ namespace Pathfinding.Util {
|
||||
public GraphGizmoHelper GetSingleFrameGizmoHelper (AstarPath active) {
|
||||
var uniqHash = new RetainedGizmos.Hasher();
|
||||
|
||||
uniqHash.AddHash(Time.realtimeSinceStartup.GetHashCode());
|
||||
uniqHash.AddHash(JNTime.Time.realtimeSinceStartup.GetHashCode());
|
||||
Draw(uniqHash);
|
||||
return GetGizmoHelper(active, uniqHash);
|
||||
}
|
||||
|
Reference in New Issue
Block a user