예제 #1
0
        public void Test_DequeueCommand_Handles_Leaving_Entities()
        {
            //arrange
            //InterestDequeueSetCommand
            InterestCollection interestCollection = new InterestCollection();

            interestCollection.Add(new NetworkEntityGuid(1));
            interestCollection.Add(new NetworkEntityGuid(2));

            interestCollection.Unregister(new NetworkEntityGuid(1));
            interestCollection.Unregister(new NetworkEntityGuid(2));

            //act
            Assert.AreEqual(2, interestCollection.ContainedEntities.Count, "Has no contained entites.");
            InterestDequeueSetCommand dequeue = new InterestDequeueSetCommand(interestCollection, interestCollection);

            dequeue.Execute();

            //assert
            Assert.AreEqual(0, interestCollection.ContainedEntities.Count, "Expected the contained entities to be removed, but some remained.");
            Assert.True(interestCollection.LeavingDequeueable.isEmpty);
        }
        /// <inheritdoc />
        public GameObject Create(PlayerEntityCreationContext context)
        {
            GameObject gameObject = DecoratedFactory.Create(context);

            GuidToSessionMappable.Add(context.EntityGuid, context.SessionContext.ZoneSession);
            ConnectionIdToControllingEntityMap.Add(context.SessionContext.ConnectionId, context.EntityGuid);

            InterestCollection playerInterestCollection = new InterestCollection();

            //directly add ourselves so we don't become interest in ourselves after spawning
            playerInterestCollection.Add(context.EntityGuid);

            //We just create our own manaul interest collection here.
            GuidToInterestCollectionMappable.Add(context.EntityGuid, playerInterestCollection);

            //We don't need to touch the gameobject, we can just return it.
            return(gameObject);
        }