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); }
/// <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); } }
/// <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); } }
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; } }
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; } }
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); }
/// <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); }
/// <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); }
/// <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); }