Exemplo n.º 1
0
        protected override void CustomProcessRequest(HttpContext context)
        {
            UpdateFactory   factory        = new UpdateFactory(context);
            IUpdateBehavior updateBehavior = factory.Create();

            updateBehavior.Update();
        }
        /// <inheritdoc />
        public void Tick()
        {
            using (LockingPolicy.ReaderLock(null, CancellationToken.None))
            {
                //For every player we need to do some processing so that we can entity data update values
                foreach (var guid in PlayerGuids)
                {
                    InterestCollection interest = GetEntityInterestCollection(guid);

                    //Even if we only know ourselves we should do this anyway
                    //so that the client can receieve entity data changes about itself

                    //TODO: We probably won't send an update about ALL entites, so this is some wasted allocations and time
                    List <EntityAssociatedData <FieldValueUpdate> > updates = new List <EntityAssociatedData <FieldValueUpdate> >(interest.ContainedEntities.Count);

                    foreach (var interestingEntityGuid in interest.ContainedEntities)
                    {
                        //Don't build an update for entities that don't have any changes
                        if (!ChangeTrackerHasChangesForEntity(interestingEntityGuid))
                        {
                            continue;
                        }

                        //TODO: We should cache this update value so we don't need to recompute it for ALL players who are interested
                        //This is the update collection for the particular Entity with guid interestingEntityGuid
                        //We want to use the CHANGE TRACKING bitarray for updates. If this was initial discovery we'd use the SIT bitarray to send all set values.
                        FieldValueUpdate update = UpdateFactory.Create(new EntityFieldUpdateCreationContext(ChangeTrackingCollections[interestingEntityGuid], ChangeTrackingCollections[interestingEntityGuid].ChangeTrackingArray));

                        updates.Add(new EntityAssociatedData <FieldValueUpdate>(interestingEntityGuid, update));
                    }

                    //It's possible no entity had updates, so we should not send a packet update
                    if (updates.Count != 0)
                    {
                        SendUpdate(guid, updates);
                    }
                }

                foreach (var dataEntityCollection in ChangeTrackingCollections.Values)
                {
                    dataEntityCollection.ClearTrackedChanges();
                }
            }
        }
Exemplo n.º 3
0
        /// <inheritdoc />
        public void Tick()
        {
            foreach (var entry in GuidToInterestCollectionMappable.EnumerateWithGuid(KnownEntities, EntityType.Player))
            {
                InterestCollection interest = entry.ComponentValue;

                //Even if we only know ourselves we should do this anyway
                //so that the client can receieve entity data changes about itself

                //TODO: We probably won't send an update about ALL entites, so this is some wasted allocations and time
                List <EntityAssociatedData <FieldValueUpdate> > updates = new List <EntityAssociatedData <FieldValueUpdate> >(interest.ContainedEntities.Count);

                foreach (var interestingEntityGuid in interest.ContainedEntities)
                {
                    //Don't build an update for entities that don't have any changes
                    if (!ChangeTrackerHasChangesForEntity(interestingEntityGuid))
                    {
                        continue;
                    }

                    //TODO: We should cache this update value so we don't need to recompute it for ALL players who are interested
                    //This is the update collection for the particular Entity with guid interestingEntityGuid
                    //We want to use the CHANGE TRACKING bitarray for updates. If this was initial discovery we'd use the SIT bitarray to send all set values.
                    FieldValueUpdate update = UpdateFactory.Create(new EntityFieldUpdateCreationContext(ChangeTrackingCollections.RetrieveEntity(interestingEntityGuid), ChangeTrackingCollections.RetrieveEntity(interestingEntityGuid).ChangeTrackingArray));

                    updates.Add(new EntityAssociatedData <FieldValueUpdate>(interestingEntityGuid, update));
                }

                //It's possible no entity had updates, so we should not send a packet update
                if (updates.Count != 0)
                {
                    SendUpdate(entry.EntityGuid, updates);
                }
            }

            foreach (var dataEntityCollection in ChangeTrackingCollections.Enumerate(KnownEntities))
            {
                dataEntityCollection.ClearTrackedChanges();
            }
        }