コード例 #1
0
    private void AddSameMatrixRelationship(BaseSpatialRelationship toAdd)
    {
        if (sameMatrixRelationships == null)
        {
            sameMatrixRelationships = new List <BaseSpatialRelationship>();
        }

        Logger.LogTraceFormat("Adding same matrix relationship {0} on {1}",
                              Category.SpatialRelationship, toAdd, this);
        sameMatrixRelationships.Add(toAdd);
    }
コード例 #2
0
 /// <summary>
 /// Server side only. Activates the relationship, such that both sides will start checking it when they move relative to each other.
 /// This is the main method to use to create and start checking a relationship.
 /// </summary>
 /// <param name="relationship"></param>
 public static void ServerActivate(BaseSpatialRelationship relationship)
 {
     Logger.LogTraceFormat("Activating spatial relationship {0}", Category.SpatialRelationship, relationship);
     relationship.obj1._AddSpatialRelationship(relationship);
     relationship.obj2._AddSpatialRelationship(relationship);
     //check the relationship immediately
     if (relationship.ShouldRelationshipEnd())
     {
         ServerEnd(relationship);
     }
 }
コード例 #3
0
 /// <summary>
 /// For internal use by the relationship system only. Use SpatialRelationship.Activate instead to
 /// activate a relationship between 2 register tiles
 ///
 /// Adds a new spatial relationship which will be checked when this register tile moves relative to the other.
 /// </summary>
 public void _AddSpatialRelationship(BaseSpatialRelationship toAdd)
 {
     //are we across matrices?
     if (toAdd.Other(this).Matrix != Matrix)
     {
         AddCrossMatrixRelationship(toAdd);
     }
     else
     {
         AddSameMatrixRelationship(toAdd);
     }
 }
コード例 #4
0
 private void RemoveSameMatrixRelationship(BaseSpatialRelationship toRemove)
 {
     if (sameMatrixRelationships == null)
     {
         return;
     }
     Logger.LogTraceFormat("Removing same matrix relationship {0} from {1}",
                           Category.SpatialRelationship, toRemove, this);
     sameMatrixRelationships.Remove(toRemove);
     if (sameMatrixRelationships.Count == 0)
     {
         sameMatrixRelationships = null;
     }
 }
コード例 #5
0
 private void RemoveCrossMatrixRelationship(BaseSpatialRelationship toRemove)
 {
     if (crossMatrixRelationships == null)
     {
         return;
     }
     Logger.LogTraceFormat("Removing cross matrix relationship {0} from {1}",
                           Category.SpatialRelationship, toRemove, this);
     crossMatrixRelationships.Remove(toRemove);
     if (crossMatrixRelationships.Count == 0)
     {
         UpdateManager.Remove(CallbackType.UPDATE, UpdatePollCrossMatrixRelationships);
         crossMatrixRelationships = null;
     }
 }
コード例 #6
0
    private void AddCrossMatrixRelationship(BaseSpatialRelationship toAdd)
    {
        //we only check cross matrix relationships if we are the leader, since only
        //one side needs to poll.
        if (!toAdd.IsLeader(this))
        {
            Logger.LogTraceFormat("Not adding cross matrix relationship {0} on {1} because {1} is not the leader",
                                  Category.SpatialRelationship, toAdd, this);
            return;
        }

        Logger.LogTraceFormat("Adding cross matrix relationship {0} on {1}",
                              Category.SpatialRelationship, toAdd, this);

        if (crossMatrixRelationships == null)
        {
            crossMatrixRelationships = new List <BaseSpatialRelationship>();
            UpdateManager.Add(CallbackType.UPDATE, UpdatePollCrossMatrixRelationships);
        }

        crossMatrixRelationships.Add(toAdd);
    }
コード例 #7
0
 /// <summary>
 /// For internal use by the relationship system only. Use SpatialRelationship.Cancel instead to
 /// cancel a pre-existing relationship between 2 register tiles
 ///
 /// removes the spatial relationship such that this registertile will no longer check it
 /// </summary>
 public void _RemoveSpatialRelationship(BaseSpatialRelationship toRemove)
 {
     RemoveSameMatrixRelationship(toRemove);
     RemoveCrossMatrixRelationship(toRemove);
 }
コード例 #8
0
 /// <summary>
 /// Server side only. Ends the relationship, such that it will no longer be checked by either side of the relationship.
 /// Only valid for relationships that have already been activated via SpatialRelationship.Activate.
 /// </summary>
 /// <param name="relationship"></param>
 public static void ServerEnd(BaseSpatialRelationship relationship)
 {
     relationship.OnRelationshipEnded();
     relationship.obj1._RemoveSpatialRelationship(relationship);
     relationship.obj2._RemoveSpatialRelationship(relationship);
 }
コード例 #9
0
 /// <summary>
 /// Server side only. Activates the relationship, such that both sides will start checking it when they move relative to each other.
 /// This is the main method to use to create and start checking a relationship.
 /// </summary>
 /// <param name="relationship"></param>
 public static void ServerActivate(BaseSpatialRelationship relationship)
 {
     Logger.LogTraceFormat("Activating spatial relationship {0}", Category.SpatialRelationship, relationship);
     relationship.obj1._AddSpatialRelationship(relationship);
     relationship.obj2._AddSpatialRelationship(relationship);
 }