Пример #1
0
        private static void Client_ClientTick(object sender, ulong e)
        {
            //This needs to be changed, as the performance time WILL be awful.

            foreach (Dimension ii in World.Dimensions)
            {
                int chunkWidth  = ii.Width;
                int chunkHeight = ii.Height;

                for (int chunkX = 0; chunkX < chunkWidth; chunkX++)
                {
                    for (int chunkY = 0; chunkY < chunkHeight; chunkY++)
                    {
                        Chunk chunk = ii.GetChunk(chunkX, chunkY);

                        foreach (Living item in chunk.Creatures)
                        {
                            if (item != null)
                            {
                                Living l = item;
                                l.Movement.WearOff();

                                if (item.QueuedMovement.Count > 0)
                                {
                                    EntityWorldMovement.MoveEntity(ref l);
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        private static void Uni_TickEvent(object sender, ulong e)
        {
            lock (SyncObject)
            {
                foreach (Dimension ii in World.Dimensions)
                {
                    int chunkWidth  = ii.Width;
                    int chunkHeight = ii.Height;

                    for (int chunkX = 0; chunkX < chunkWidth; chunkX++)
                    {
                        for (int chunkY = 0; chunkY < chunkHeight; chunkY++)
                        {
                            Chunk chunk = ii.GetChunk(chunkX, chunkY);

                            List <Guid> keys   = chunk.Creatures.Keys.ToList();
                            int         length = keys.Count;
                            for (int i = 0; i < length; i++)
                            {
                                chunk.Creatures.TryGetValue(keys[i], out Living l);

                                if (l != null)
                                {
                                    ComponentMovement movementComponent = l.GetExactComponent <ComponentMovement>();
                                    movementComponent.Movement.WearOff();

                                    if (movementComponent.QueuedMovement.Count > 0)
                                    {
                                        EntityWorldMovement.MoveEntity(l);
                                    }

                                    if (l.Task != null && !l.Task.IsFinished)
                                    {
                                        l.Task.Tick(l);
                                    }
                                    else
                                    {
                                        TaskManager.Manager.AssignTask(l);
                                        //Find a job
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        private static void Client_ClientTick(object sender, ulong e)
        {
            //This needs to be changed, as the performance time WILL be awful.

            foreach (Dimension ii in World.Dimensions)
            {
                int chunkWidth  = ii.Width;
                int chunkHeight = ii.Height;

                for (int chunkX = 0; chunkX < chunkWidth; chunkX++)
                {
                    for (int chunkY = 0; chunkY < chunkHeight; chunkY++)
                    {
                        Chunk chunk = ii.GetChunk(chunkX, chunkY);

                        List <Guid> keys   = chunk.Creatures.Keys.ToList();
                        int         length = keys.Count;
                        for (int i = 0; i < length; i++)
                        {
                            chunk.Creatures.TryGetValue(keys[i], out Living l);

                            if (l != null)
                            {
                                l.Movement.WearOff();

                                if (l.QueuedMovement.Count > 0)
                                {
                                    EntityWorldMovement.MoveEntity(l);
                                }

                                if (l.Task != null)
                                {
                                    l.Task.Tick(l);
                                }
                                else
                                {
                                    TaskManager.Manager.AssignTask(l);
                                    //Find a job
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #4
0
        private static void Client_ClientTick(object sender, ulong e)
        {
            //This needs to be changed, as the performance time WILL be awful.
            //This WILL be changed after the rewrite of how the world is stored in memory

            foreach (Tile item in World.MainWorld.Tiles)
            {
                if (item.Living != null)
                {
                    Living l = item.Living;
                    l.Movement.WearOff();

                    if (item.Living.QueuedMovement.Count > 0)
                    {
                        EntityWorldMovement.MoveEntity(ref l);
                    }
                }
            }
        }
Пример #5
0
        private static void Client_ClientTick(object sender, ulong e)
        {
            //This needs to be changed, as the performance time WILL be awful.

            foreach (Dimension ii in World.Dimensions)
            {
                int chunkWidth  = ii.Width;
                int chunkHeight = ii.Height;

                for (int chunkX = 0; chunkX < chunkWidth; chunkX++)
                {
                    for (int chunkY = 0; chunkY < chunkHeight; chunkY++)
                    {
                        Chunk chunk = ii.GetChunk(chunkX, chunkY);

                        List <Guid> keys   = chunk.Creatures.Keys.ToList();
                        int         length = keys.Count;
                        for (int i = 0; i < length; i++)
                        {
                            chunk.Creatures.TryGetValue(keys[i], out Living l);

                            if (l != null)
                            {
                                l.Movement.WearOff();

                                if (l.QueuedMovement.Count > 0)
                                {
                                    EntityWorldMovement.MoveEntity(l);
                                }

                                if (l.Task != null)
                                {
                                    l.Task.DoJob(l);
                                }
                            }
                        }

                        //Dictionary<Guid, Living>.KeyCollection keys = chunk.Creatures.Keys;
                        //lock (keys)
                        //{
                        //    foreach (Guid item in keys)
                        //    {
                        //        chunk.Creatures.TryGetValue(item, out Living l);

                        //        if (l != null)
                        //        {
                        //            l.Movement.WearOff();

                        //            if (l.QueuedMovement.Count > 0)
                        //            {
                        //                EntityWorldMovement.MoveEntity(l);
                        //            }

                        //            if (l.Task != null)
                        //            {
                        //                l.Task.DoJob(l);
                        //            }
                        //        }
                        //    }
                        //}
                        //lock (chunk.Creatures)
                        //{
                        //    foreach (KeyValuePair<System.Guid, Living> item in chunk.Creatures)
                        //    {
                        //        if (item.Value != null)
                        //        {
                        //            Living l = item.Value;
                        //            l.Movement.WearOff();

                        //            if (item.Value.QueuedMovement.Count > 0)
                        //            {
                        //                EntityWorldMovement.MoveEntity(l);
                        //            }

                        //            if (l.Task != null)
                        //            {
                        //                l.Task.DoJob(l);
                        //            }
                        //        }
                        //    }
                        //}
                    }
                }
            }
        }