mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
fix: Misc code smells (#2094)
* fix: code smell - condensed if statement * fix: code smell - dont throw generic Exception
This commit is contained in:
parent
12827f65a9
commit
e4cc85c413
@ -112,14 +112,11 @@ public struct DataPoint
|
||||
void FixedUpdate()
|
||||
{
|
||||
// if server then always sync to others.
|
||||
if (isServer)
|
||||
{
|
||||
// let the clients know that this has moved
|
||||
if (HasEitherMovedRotatedScaled())
|
||||
if (isServer && HasEitherMovedRotatedScaled())
|
||||
{
|
||||
RpcMove(targetTransform.localPosition, targetTransform.localRotation, targetTransform.localScale);
|
||||
}
|
||||
}
|
||||
|
||||
if (isClient)
|
||||
{
|
||||
@ -127,9 +124,7 @@ void FixedUpdate()
|
||||
// -> only if connectionToServer has been initialized yet too
|
||||
if (IsOwnerWithClientAuthority)
|
||||
{
|
||||
if (!isServer)
|
||||
{
|
||||
if (HasEitherMovedRotatedScaled())
|
||||
if (!isServer && HasEitherMovedRotatedScaled())
|
||||
{
|
||||
// serialize
|
||||
// local position/rotation for VR support
|
||||
@ -137,7 +132,6 @@ void FixedUpdate()
|
||||
CmdClientToServerSync(targetTransform.localPosition, targetTransform.localRotation, targetTransform.localScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (goal.isValid)
|
||||
{
|
||||
// teleport or interpolate
|
||||
|
@ -189,9 +189,8 @@ void HandleAnimMsg(int stateHash, float normalizedTime, int layerId, NetworkRead
|
||||
// usually transitions will be triggered by parameters, if not, play anims directly.
|
||||
// NOTE: this plays "animations", not transitions, so any transitions will be skipped.
|
||||
// NOTE: there is no API to play a transition(?)
|
||||
if (stateHash != 0)
|
||||
if (stateHash != 0 && animator.enabled)
|
||||
{
|
||||
if (animator.enabled)
|
||||
animator.Play(stateHash, layerId, normalizedTime);
|
||||
}
|
||||
|
||||
|
@ -66,15 +66,13 @@ void GameReadyCheck()
|
||||
foreach (KeyValuePair<uint, NetworkIdentity> kvp in NetworkIdentity.spawned)
|
||||
{
|
||||
Tank comp = kvp.Value.GetComponent<Tank>();
|
||||
if (comp != null)
|
||||
{
|
||||
if (!players.Contains(comp))
|
||||
{
|
||||
|
||||
//Add if new
|
||||
if (comp != null && !players.Contains(comp))
|
||||
{
|
||||
players.Add(comp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//If minimum connections has been check if they are all ready
|
||||
if (players.Count >= MinimumPlayersForGame)
|
||||
|
@ -425,7 +425,7 @@ void AssignSceneID()
|
||||
// => throw an exception to cancel the build and let the user
|
||||
// know how to fix it!
|
||||
if (BuildPipeline.isBuildingPlayer)
|
||||
throw new Exception("Scene " + gameObject.scene.path + " needs to be opened and resaved before building, because the scene object " + name + " has no valid sceneId yet.");
|
||||
throw new InvalidOperationException("Scene " + gameObject.scene.path + " needs to be opened and resaved before building, because the scene object " + name + " has no valid sceneId yet.");
|
||||
|
||||
// if we generate the sceneId then we MUST be sure to set dirty
|
||||
// in order to save the scene object properly. otherwise it
|
||||
|
@ -80,7 +80,7 @@ public override void ClientConnect(string address)
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new Exception("No transport suitable for this platform");
|
||||
throw new ArgumentException("No transport suitable for this platform");
|
||||
}
|
||||
|
||||
public override void ClientConnect(Uri uri)
|
||||
@ -101,7 +101,7 @@ public override void ClientConnect(Uri uri)
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new Exception("No transport suitable for this platform");
|
||||
throw new ArgumentException("No transport suitable for this platform");
|
||||
}
|
||||
|
||||
public override bool ClientConnected()
|
||||
|
Loading…
Reference in New Issue
Block a user