|
|
@ -300,7 +300,7 @@ namespace GWConquest |
|
|
|
|
|
|
|
public void StartMovingOnPath(List<Zone> path, Formation targetFormation = null) |
|
|
|
{ |
|
|
|
if (path.Count > 1 && IsOwner && CanMove) |
|
|
|
if (path.Count > 1 && Player == Player.CurrentPlayer && CanMove) |
|
|
|
{ |
|
|
|
if (!CanMoveTo(path[0], path[1])) |
|
|
|
{ |
|
|
@ -309,12 +309,13 @@ namespace GWConquest |
|
|
|
} |
|
|
|
|
|
|
|
int[] zoneIDs = path.GetRange(1, path.Count - 1).Select(z => Zone.GetZoneId(z)).ToArray(); |
|
|
|
Debug.Log($"[RPC] Sending RPC: Begin Movement Server with zone path {zoneIDs}, target {targetFormation}"); |
|
|
|
BeginMovementServerRpc(zoneIDs, targetFormation); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
Debug.LogFormat("Could not move formation {0} (controlled: {1}, movement state: {2})", |
|
|
|
this, IsOwner, MovementState); |
|
|
|
Debug.LogFormat("Could not move formation {0} (player: {1}, movement state: {2})", |
|
|
|
this, Player, MovementState); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -344,6 +345,8 @@ namespace GWConquest |
|
|
|
|
|
|
|
pathQueue.SetEntries(zoneIDs); |
|
|
|
|
|
|
|
Debug.Log($"First in path queue is now zone {PathQueue.First()}"); |
|
|
|
|
|
|
|
if (targetFormation != null) |
|
|
|
{ |
|
|
|
MovementTargetFormation = targetFormation; |
|
|
@ -358,15 +361,16 @@ namespace GWConquest |
|
|
|
BeginMovementServer(new int[] { Zone.GetZoneId(targetZone) }, targetFormation: targetFormation); |
|
|
|
} |
|
|
|
|
|
|
|
[ServerRpc] |
|
|
|
[ServerRpc(RequireOwnership = false)] |
|
|
|
public void BeginMovementServerRpc(int[] zoneIDs, NullableNetworkBehaviourReference targetFormation) |
|
|
|
{ |
|
|
|
Debug.Log($"[RPC] Recieved RPC: Begin Movement Server with zone path {String.Join(',', zoneIDs)}, target {targetFormation}"); |
|
|
|
BeginMovementServer(zoneIDs, targetFormation: targetFormation.GetBehaviour<Formation>()); |
|
|
|
} |
|
|
|
|
|
|
|
public void MoveToZone(Zone target) |
|
|
|
{ |
|
|
|
if (IsOwner && MovementState == FormationMovementState.PreparingMovement) |
|
|
|
if (MovementState == FormationMovementState.PreparingMovement) |
|
|
|
{ |
|
|
|
if (!CanMoveTo(currentZone, target)) |
|
|
|
{ |
|
|
@ -487,7 +491,7 @@ namespace GWConquest |
|
|
|
|
|
|
|
public void FixedUpdate() |
|
|
|
{ |
|
|
|
if (IsServer) |
|
|
|
if (IsSpawned && IsServer) |
|
|
|
{ |
|
|
|
if (IsEmbarked) |
|
|
|
{ |
|
|
@ -563,7 +567,7 @@ namespace GWConquest |
|
|
|
{ |
|
|
|
if (MovementTargetFormation != null) |
|
|
|
{ |
|
|
|
if (MovementTargetFormation.HasNetworkObject && MovementTargetFormation.currentZone == currentZone) |
|
|
|
if (MovementTargetFormation.IsSpawned && MovementTargetFormation.currentZone == currentZone) |
|
|
|
{ |
|
|
|
MovementTargetFormation.AddSubFormation(this); |
|
|
|
} |
|
|
@ -606,7 +610,7 @@ namespace GWConquest |
|
|
|
|
|
|
|
private void Update() |
|
|
|
{ |
|
|
|
if (HasNetworkObject) |
|
|
|
if (IsSpawned) |
|
|
|
{ |
|
|
|
if (GameManager.EntitiesLoaded) |
|
|
|
{ |
|
|
@ -785,11 +789,11 @@ namespace GWConquest |
|
|
|
|
|
|
|
public float GetFormationStrength() |
|
|
|
{ |
|
|
|
if (HasNetworkObject) |
|
|
|
if (IsSpawned) |
|
|
|
{ |
|
|
|
return Units.Sum(unit => |
|
|
|
{ |
|
|
|
if (unit != null && unit.HasNetworkObject) |
|
|
|
if (unit != null && unit.IsSpawned) |
|
|
|
{ |
|
|
|
return unit.Class.UnitStrength; |
|
|
|
} |
|
|
@ -1057,7 +1061,7 @@ namespace GWConquest |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[ClientRpc] |
|
|
|
[ClientRpc(Delivery = RpcDelivery.Unreliable)] |
|
|
|
public void PlayFormationDemoralizedAnimationClientRpc() |
|
|
|
{ |
|
|
|
if (HeroUnit != null && HeroUnit.CurrentIcon != null) |
|
|
@ -1102,7 +1106,7 @@ namespace GWConquest |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[ServerRpc] |
|
|
|
[ServerRpc(RequireOwnership = false)] |
|
|
|
public void AssignLeaderServerRpc(NullableNetworkBehaviourReference unit) |
|
|
|
{ |
|
|
|
heroUnit.Value = unit; |
|
|
|