/// [0,1] public virtual float GetRelevance(ReplicaView view) { if (!isSceneReplica && Owner == view.Connection) { return(1); } if ((Settings.priorityFlags & ReplicaPriorityFlag.IgnorePosition) == ReplicaPriorityFlag.IgnorePosition) { return(1); } var diff = new Vector2(transform.position.x - view.transform.position.x, transform.position.z - view.transform.position.z); var sqrMagnitude = diff.sqrMagnitude; if (sqrMagnitude > Settings.SqrMaxViewDistance) { return(0); // No costly calculations } var distanceRelevance = 1f - Mathf.Pow(sqrMagnitude / Settings.SqrMaxViewDistance, 0.9f); var viewForward = new Vector2(view.transform.forward.x, view.transform.forward.z).normalized; var dotRelevance = Vector2.Dot(viewForward, diff.normalized); dotRelevance = dotRelevance > 0 ? 1 : 0.5f; return(distanceRelevance * dotRelevance); }
void OnDrawGizmosSelected() { Debug = this; Handles.color = Color.white; for (int i = 1; i < 3; ++i) { Handles.DrawWireDisc(transform.position, Vector3.up, i * 50); } }
public bool IsRelevantFor(ReplicaView view) { Assert.IsTrue(isServer); return(gameObject.activeInHierarchy); }
public void ForceReplicaViewRefresh(ReplicaView view) { Assert.IsTrue(!view.IsLoadingLevel); UpdateRelevantReplicas(view); }