Пример #1
0
    private void UpdatePollCrossMatrixRelationships()
    {
        //used in update manager when there is a cross matrix relationship
        //that this registertile is the leader for. Checks the relationship and switches it
        //over to same matrix if they both end up on the same matrix

        if (crossMatrixRelationships != null)
        {
            //keeping null to avoid GC unless a switch happens, which should be rare
            List <BaseSpatialRelationship> toSwitch = null;
            List <BaseSpatialRelationship> toCancel = null;
            foreach (var crossMatrixRelationship in crossMatrixRelationships)
            {
                var cancelled = crossMatrixRelationship.ShouldRelationshipEnd();
                if (cancelled)
                {
                    if (toCancel == null)
                    {
                        toCancel = new List <BaseSpatialRelationship>();
                    }

                    toCancel.Add(crossMatrixRelationship);
                }
                else
                {
                    //not cancelled, check if we moved to same matrix
                    if (crossMatrixRelationship.Other(this).Matrix == this.Matrix)
                    {
                        if (toSwitch == null)
                        {
                            toSwitch = new List <BaseSpatialRelationship>();
                        }

                        toSwitch.Add(crossMatrixRelationship);
                    }
                }
            }

            if (toCancel != null)
            {
                foreach (var cancelled in toCancel)
                {
                    Logger.LogTraceFormat("Cancelling spatial relationship {0} because OnRelationshipChanged" +
                                          " returned true.", Category.SpatialRelationship, cancelled);
                    SpatialRelationship.ServerEnd(cancelled);
                }
            }

            if (toSwitch != null)
            {
                foreach (var switched in toSwitch)
                {
                    Logger.LogTraceFormat("Switching spatial relationship {0} to same matrix because" +
                                          " objects moved to the same matrix.", Category.SpatialRelationship, switched);
                    RemoveCrossMatrixRelationship(switched);
                    AddSameMatrixRelationship(switched);
                }
            }
        }
    }
 private void OnCuffChangeServer(bool wasCuffed, bool nowCuffed)
 {
     if (!CanPlayerStillBeObserved())
     {
         SpatialRelationship.ServerEnd(this);
     }
 }
Пример #3
0
    public virtual void OnDespawnServer(DespawnInfo info)
    {
        //cancel all relationships
        if (sameMatrixRelationships != null)
        {
            for (int i = sameMatrixRelationships.Count - 1; i >= 0; i--)
            {
                var relationship = sameMatrixRelationships[i];
                Logger.LogTraceFormat("Cancelling spatial relationship {0} because {1} is despawning.",
                                      Category.SpatialRelationship, relationship, this);
                SpatialRelationship.ServerEnd(relationship);
            }
        }

        if (crossMatrixRelationships != null)
        {
            for (int i = crossMatrixRelationships.Count - 1; i >= 0; i--)
            {
                var relationship = crossMatrixRelationships[i];
                Logger.LogTraceFormat("Cancelling spatial relationship {0} because {1} is despawning.",
                                      Category.SpatialRelationship, relationship, this);
                SpatialRelationship.ServerEnd(relationship);
            }
        }

        OnDespawnedServer.Invoke();
    }
 private void OnConsciousStateChangeServer(ConsciousState oldState, ConsciousState newState)
 {
     if (!CanPlayerStillBeObserved())
     {
         SpatialRelationship.ServerEnd(this);
     }
 }
Пример #5
0
    private void CheckSameMatrixRelationships()
    {
        //fires hooks for these relationships and checks if they should be switched to cross-matrix
        if (sameMatrixRelationships != null)
        {
            //keeping null to avoid GC unless a switch happens, which should be rare
            List <BaseSpatialRelationship> toSwitch = null;
            List <BaseSpatialRelationship> toCancel = null;
            foreach (var sameMatrixRelationship in sameMatrixRelationships)
            {
                var cancelled = sameMatrixRelationship.ShouldRelationshipEnd();
                if (cancelled)
                {
                    if (toCancel == null)
                    {
                        toCancel = new List <BaseSpatialRelationship>();
                    }

                    toCancel.Add(sameMatrixRelationship);
                }
                else
                {
                    //not cancelled, check if we moved cross-matrix
                    if (sameMatrixRelationship.Other(this).Matrix != this.Matrix)
                    {
                        if (toSwitch == null)
                        {
                            toSwitch = new List <BaseSpatialRelationship>();
                        }

                        toSwitch.Add(sameMatrixRelationship);
                    }
                }
            }

            if (toCancel != null)
            {
                foreach (var cancelled in toCancel)
                {
                    Logger.LogTraceFormat("Cancelling spatial relationship {0} because OnRelationshipChanged" +
                                          " returned true.", Category.SpatialRelationship, cancelled);
                    SpatialRelationship.ServerEnd(cancelled);
                }
            }

            if (toSwitch != null)
            {
                foreach (var switched in toSwitch)
                {
                    Logger.LogTraceFormat("Switching spatial relationship {0} to cross matrix because" +
                                          " objects moved to different matrices.", Category.SpatialRelationship,
                                          switched);
                    RemoveSameMatrixRelationship(switched);
                    AddCrossMatrixRelationship(switched);
                }
            }
        }
    }