Move docking target selection into daemon operations
This commit is contained in:
parent
0682bbe158
commit
c6f8b95317
7 changed files with 153 additions and 40 deletions
|
|
@ -3883,21 +3883,14 @@ public class ActionGameManager : MonoBehaviour
|
|||
private bool TryRequestDaemonDock()
|
||||
{
|
||||
var observer = ResolveDaemonObserver();
|
||||
if (observer == null || !observer.HasAuthoritativeState || CurrentEntity == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var target = FindDaemonDockTarget();
|
||||
var targetKey = ResolveEntityRecordKey(target);
|
||||
if (string.IsNullOrWhiteSpace(targetKey))
|
||||
if (observer == null || !observer.HasAuthoritativeState)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
observer.Operations.Dock(targetKey);
|
||||
observer.Operations.DockNearest(Settings.GameplaySettings.DockingDistance);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -3907,36 +3900,6 @@ public class ActionGameManager : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
private Entity FindDaemonDockTarget()
|
||||
{
|
||||
if (CurrentEntity == null || Zone == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var dockingDistanceSq = Settings.GameplaySettings.DockingDistance * Settings.GameplaySettings.DockingDistance;
|
||||
Entity closest = null;
|
||||
var closestDistanceSq = float.MaxValue;
|
||||
foreach (var entity in Zone.Entities)
|
||||
{
|
||||
if (entity == null || entity == CurrentEntity)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var distanceSq = CultMath.math.lengthsq(entity.CultPositionXZ - CurrentEntity.CultPositionXZ);
|
||||
if (distanceSq >= dockingDistanceSq || distanceSq >= closestDistanceSq)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
closest = entity;
|
||||
closestDistanceSq = distanceSq;
|
||||
}
|
||||
|
||||
return closest;
|
||||
}
|
||||
|
||||
public void RequestUndock()
|
||||
{
|
||||
TryRequestDaemonUndock();
|
||||
|
|
|
|||
|
|
@ -180,6 +180,11 @@ public sealed class AetheriaDaemonOperations
|
|||
return Send((client, observed) => client.Dock(observed, targetEntityKey));
|
||||
}
|
||||
|
||||
public AetheriaRuntimeDaemonCommandEnvelope DockNearest(double maxDistance)
|
||||
{
|
||||
return Send((client, observed) => client.DockNearest(observed, maxDistance));
|
||||
}
|
||||
|
||||
public AetheriaRuntimeDaemonCommandEnvelope Undock()
|
||||
{
|
||||
return Send((client, observed) => client.Undock(observed));
|
||||
|
|
|
|||
Loading…
Reference in a new issue