Esempio n. 1
0
 protected MmoActor(PeerBase peer, World world)
 {
     this.peer = peer;
     this.world = world;
     this.interestAreas = new Dictionary<byte, InterestArea>();
     this.interestItems = new InterestItems(peer);
 }
Esempio n. 2
0
        public Item(Vector position, Vector rotation, Hashtable properties, MmoActorOperationHandler owner, string id, byte type, World world)
        {
            this.Position = position;
            this.Rotation = rotation;
            this.Owner = owner;
            this.eventChannel = new MessageChannel<ItemEventMessage>(ItemEventMessage.CounterEventSend);
            this.disposeChannel = new MessageChannel<ItemDisposedMessage>(MessageCounters.CounterSend);
            this.positionUpdateChannel = new MessageChannel<ItemPositionMessage>(MessageCounters.CounterSend);
            this.properties = properties ?? new Hashtable();
            if (properties != null)
            {
                this.PropertiesRevision++;
            }

            this.id = id;
            this.world = world;
            this.type = type;
        }
 public MmoActorOperationHandler(PeerBase peer, World world, InterestArea interestArea)
     : base(peer, world)
 {
     this.AddInterestArea(interestArea);
 }
Esempio n. 4
0
        private static void SetupClients(World world, List<Client> clients, Stopwatch t)
        {
            for (int x = (int)(world.Area.Min.X + (world.TileDimensions.X / 2)); x < world.Area.Max.X; x += (int)world.TileDimensions.X)
            {
                for (int y = (int)(world.Area.Min.Y + (world.TileDimensions.Y / 2)); y < world.Area.Max.Y; y += (int)world.TileDimensions.Y)
                {
                    string name = string.Format("MyUsername{0}/{1}", x, y);
                    var client = new Client(name, new Vector( x / 100f, y / 100f, 0f));
                    client.BeginConnect();
                    clients.Add(client);
                    clientCount++;
                }

                for (int y = (int)(world.Area.Min.Y + (world.TileDimensions.Y / 2)) + 1; y < world.Area.Max.Y; y += (int)world.TileDimensions.Y)
                {
                    string name = string.Format("MyUsername{0}/{1}", x + 1, y);
                    var client = new Client(name, new Vector((x + 1) / 100f, y / 100f, 0f));
                    client.BeginConnect();
                    clients.Add(client);
                    clientCount++;
                }
            }

            clients.ForEach(c => Assert.IsTrue(c.EndConnect()));
            log.InfoFormat("connect completed, {0} clients", clientCount);

            clients.ForEach(c => EnterWorldBegin(c, world));
            clients.ForEach(EnterWorldEnd);
            clients.ForEach(c => BeginReceiveEvent(c, EventCode.ItemSubscribed, d => (string)d[(byte)ParameterCode.ItemId] != c.Username, 500));
            clients.ForEach(c => EndReceiveEvent(c, EventCode.ItemSubscribed));
            PrintStats(t);
            Client.ResetStats();
            Assert.AreEqual(0, Client.Exceptions, "Exceptions occured at start");
            log.Info("enter completed");
        }
Esempio n. 5
0
        private static void EnterWorldBegin(Client client, World world)
        {
            var viewDistanceEnter = new Vector(1f, 1f, 0f);
            var viewDistanceExit = new Vector( 2f, 2f, 0f);

            ThreadPoolEnqueue(
                client,
                () =>
                    {
                        Operations.EnterWorld(client, world.Name, client.Username, null, client.Position, viewDistanceEnter, viewDistanceExit);
                        client.BeginReceiveResponse(10);
                    });
        }
Esempio n. 6
0
        private static void CreateWorld(World world, Client client)
        {
            Operations.CreateWorld(client, world.Name, world.Area, world.TileDimensions);

            client.BeginReceiveResponse(0);

            OperationResponse data;
            Assert.IsTrue(client.EndReceiveResponse(Settings.WaitTimeMultiOp, out data), "Response not received");
            Assert.IsTrue(data.ReturnCode == (int)ReturnCode.Ok || data.ReturnCode == (int)ReturnCode.WorldAlreadyExists);
        }
 public ClientInterestArea(PeerBase peer, byte id, World world)
     : base(id, world)
 {
     this.peer = peer;
     this.eventChannelSubscriptions = new Dictionary<Region, IDisposable>();
 }