Esempio n. 1
0
        public Landblock(LandblockId id)
        {
            Id = id;
            //Console.WriteLine("Landblock constructor(" + (id.Raw | 0xFFFF).ToString("X8") + ")");

            UpdateStatus(LandBlockStatusFlag.IdleUnloaded);

            // initialize adjacency array
            adjacencies.Add(Adjacency.North, null);
            adjacencies.Add(Adjacency.NorthEast, null);
            adjacencies.Add(Adjacency.East, null);
            adjacencies.Add(Adjacency.SouthEast, null);
            adjacencies.Add(Adjacency.South, null);
            adjacencies.Add(Adjacency.SouthWest, null);
            adjacencies.Add(Adjacency.West, null);
            adjacencies.Add(Adjacency.NorthWest, null);

            UpdateStatus(LandBlockStatusFlag.IdleLoading);

            actionQueue = new NestedActionQueue(WorldManager.LandblockActionQueue);

            // create world objects (monster locations, generators)
            var objects        = DatabaseManager.World.GetCachedInstancesByLandblock(Id.Landblock);
            var factoryObjects = WorldObjectFactory.CreateNewWorldObjects(objects);

            foreach (var fo in factoryObjects)
            {
                AddWorldObject(fo);
                fo.ActivateLinks();
            }

            // create shard objects (corpses after unloading)
            DatabaseManager.Shard.GetObjectsByLandblock(Id.Landblock, ((List <Biota> biotas) =>
            {
                var shardObjects = (WorldObjectFactory.CreateWorldObjects(biotas));
                foreach (var so in shardObjects)
                {
                    AddWorldObject(so);
                }
            }));

            _landblock = LScape.get_landblock(Id.Raw);

            //LoadMeshes(objects);

            SpawnEncounters();

            UpdateStatus(LandBlockStatusFlag.IdleLoaded);

            // FIXME(ddevec): Goal: get rid of UseTime() function...
            actionQueue.EnqueueAction(new ActionEventDelegate(() => UseTimeWrapper()));

            motionQueue = new NestedActionQueue(WorldManager.LandblockMotionQueue);

            LastActiveTime = Timer.CurrentTime;

            QueueNextHeartBeat();
        }
Esempio n. 2
0
        /// <summary>
        /// Corpses<para />
        /// This will be called from a separate task from our constructor. Use thread safety when interacting with this landblock.
        /// </summary>
        private void SpawnDynamicShardObjects()
        {
            var dynamics            = DatabaseManager.Shard.GetDynamicObjectsByLandblock(Id.Landblock);
            var factoryShardObjects = WorldObjectFactory.CreateWorldObjects(dynamics);

            actionQueue.EnqueueAction(new ActionEventDelegate(() =>
            {
                foreach (var fso in factoryShardObjects)
                {
                    AddWorldObject(fso);
                }
            }));
        }
Esempio n. 3
0
        public Landblock(LandblockId id)
        {
            this.id = id;

            UpdateStatus(LandBlockStatusFlag.IdleUnloaded);

            // initialize adjacency array
            adjacencies.Add(Adjacency.North, null);
            adjacencies.Add(Adjacency.NorthEast, null);
            adjacencies.Add(Adjacency.East, null);
            adjacencies.Add(Adjacency.SouthEast, null);
            adjacencies.Add(Adjacency.South, null);
            adjacencies.Add(Adjacency.SouthWest, null);
            adjacencies.Add(Adjacency.West, null);
            adjacencies.Add(Adjacency.NorthWest, null);

            UpdateStatus(LandBlockStatusFlag.IdleLoading);

            actionQueue = new NestedActionQueue(WorldManager.ActionQueue);

            // TODO: Load cell.dat contents
            //   1. landblock cell structure
            //   2. terrain data
            // TODO: Load portal.dat contents (as/if needed)
            // TODO: Load spawn data

            var objects = DatabaseManager.World.GetWeenieInstancesByLandblock(this.id.Landblock); // Instances

            // FIXME: Likely the next line should be eliminated after generators have been refactored into the instance structure, if that ends up making the most sense
            //        I don't know for sure however that it does yet. More research on them is required -Ripley
            objects.AddRange(DatabaseManager.World.GetObjectsByLandblock(this.id.Landblock)); // Generators

            var factoryObjects = WorldObjectFactory.CreateWorldObjects(objects);

            factoryObjects.ForEach(fo =>
            {
                if (!worldObjects.ContainsKey(fo.Guid))
                {
                    worldObjects.Add(fo.Guid, fo);
                    fo.SetParent(this);
                }
            });

            UpdateStatus(LandBlockStatusFlag.IdleLoaded);

            // FIXME(ddevec): Goal: get rid of UseTime() function...
            actionQueue.EnqueueAction(new ActionEventDelegate(() => UseTimeWrapper()));

            motionQueue = new NestedActionQueue(WorldManager.MotionQueue);
        }
Esempio n. 4
0
        public Landblock(LandblockId id)
        {
            Id = id;
            //Console.WriteLine("Landblock constructor(" + (id.Raw | 0xFFFF).ToString("X8") + ")");

            UpdateStatus(LandBlockStatusFlag.IdleUnloaded);

            // initialize adjacency array
            adjacencies.Add(Adjacency.North, null);
            adjacencies.Add(Adjacency.NorthEast, null);
            adjacencies.Add(Adjacency.East, null);
            adjacencies.Add(Adjacency.SouthEast, null);
            adjacencies.Add(Adjacency.South, null);
            adjacencies.Add(Adjacency.SouthWest, null);
            adjacencies.Add(Adjacency.West, null);
            adjacencies.Add(Adjacency.NorthWest, null);

            UpdateStatus(LandBlockStatusFlag.IdleLoading);

            // create world objects (monster locations, generators)
            var objects        = DatabaseManager.World.GetCachedInstancesByLandblock(Id.Landblock);
            var factoryObjects = WorldObjectFactory.CreateNewWorldObjects(objects);

            foreach (var fo in factoryObjects)
            {
                AddWorldObject(fo);
                fo.ActivateLinks();
            }

            // create shard objects (corpses after unloading)
            DatabaseManager.Shard.GetObjectsByLandblock(Id.Landblock, ((List <Biota> biotas) =>
            {
                var shardObjects = (WorldObjectFactory.CreateWorldObjects(biotas));
                foreach (var so in shardObjects)
                {
                    AddWorldObject(so);
                }
            }));

            _landblock = LScape.get_landblock(Id.Raw);

            //LoadMeshes(objects);

            SpawnEncounters();

            UpdateStatus(LandBlockStatusFlag.IdleLoaded);

            lastActiveTime = DateTime.UtcNow;
        }
Esempio n. 5
0
        public Landblock(LandblockId id)
        {
            this.id = id;

            UpdateStatus(LandBlockStatusFlag.IdleUnloaded);

            // initialize adjacency array
            adjacencies.Add(Adjacency.North, null);
            adjacencies.Add(Adjacency.NorthEast, null);
            adjacencies.Add(Adjacency.East, null);
            adjacencies.Add(Adjacency.SouthEast, null);
            adjacencies.Add(Adjacency.South, null);
            adjacencies.Add(Adjacency.SouthWest, null);
            adjacencies.Add(Adjacency.West, null);
            adjacencies.Add(Adjacency.NorthWest, null);

            UpdateStatus(LandBlockStatusFlag.IdleLoading);

            actionQueue = new NestedActionQueue(WorldManager.ActionQueue);

            // TODO: Load cell.dat contents
            //   1. landblock cell structure
            //   2. terrain data
            // TODO: Load portal.dat contents (as/if needed)
            // TODO: Load spawn data

            var objects        = DatabaseManager.World.GetObjectsByLandblock(this.id.Landblock);
            var factoryObjects = WorldObjectFactory.CreateWorldObjects(objects);

            factoryObjects.ForEach(fo =>
            {
                if (!worldObjects.ContainsKey(fo.Guid))
                {
                    worldObjects.Add(fo.Guid, fo);
                    fo.SetParent(this);
                }
            });

            UpdateStatus(LandBlockStatusFlag.IdleLoaded);

            // FIXME(ddevec): Goal: get rid of UseTime() function...
            actionQueue.EnqueueAction(new ActionEventDelegate(() => UseTimeWrapper()));

            motionQueue = new NestedActionQueue(WorldManager.MotionQueue);
        }
Esempio n. 6
0
        public Landblock(LandblockId id)
        {
            this.Id = id;

            UpdateStatus(LandBlockStatusFlag.IdleUnloaded);

            // initialize adjacency array
            adjacencies.Add(Adjacency.North, null);
            adjacencies.Add(Adjacency.NorthEast, null);
            adjacencies.Add(Adjacency.East, null);
            adjacencies.Add(Adjacency.SouthEast, null);
            adjacencies.Add(Adjacency.South, null);
            adjacencies.Add(Adjacency.SouthWest, null);
            adjacencies.Add(Adjacency.West, null);
            adjacencies.Add(Adjacency.NorthWest, null);

            UpdateStatus(LandBlockStatusFlag.IdleLoading);

            actionQueue = new NestedActionQueue(WorldManager.ActionQueue);

            var objects = DatabaseManager.World.GetWeenieInstancesByLandblock(this.Id.Landblock); // Instances

            var factoryObjects = WorldObjectFactory.CreateWorldObjects(objects);

            factoryObjects.ForEach(fo =>
            {
                if (!worldObjects.ContainsKey(fo.Guid))
                {
                    worldObjects.Add(fo.Guid, fo);
                    fo.SetParent(this);
                }
            });

            LoadMeshes(objects);

            UpdateStatus(LandBlockStatusFlag.IdleLoaded);

            // FIXME(ddevec): Goal: get rid of UseTime() function...
            actionQueue.EnqueueAction(new ActionEventDelegate(() => UseTimeWrapper()));

            motionQueue = new NestedActionQueue(WorldManager.MotionQueue);
        }
Esempio n. 7
0
        public Landblock(LandblockId id)
        {
            Id = id;
            //Console.WriteLine("Landblock constructor(" + (id.Raw | 0xFFFF).ToString("X8") + ")");

            UpdateStatus(LandBlockStatusFlag.IdleUnloaded);

            // initialize adjacency array
            adjacencies.Add(Adjacency.North, null);
            adjacencies.Add(Adjacency.NorthEast, null);
            adjacencies.Add(Adjacency.East, null);
            adjacencies.Add(Adjacency.SouthEast, null);
            adjacencies.Add(Adjacency.South, null);
            adjacencies.Add(Adjacency.SouthWest, null);
            adjacencies.Add(Adjacency.West, null);
            adjacencies.Add(Adjacency.NorthWest, null);

            UpdateStatus(LandBlockStatusFlag.IdleLoading);

            actionQueue = new NestedActionQueue(WorldManager.ActionQueue);

            // create world objects (monster locations, generators)
            var objects        = DatabaseManager.World.GetCachedInstancesByLandblock(Id.Landblock);
            var factoryObjects = WorldObjectFactory.CreateNewWorldObjects(objects);

            foreach (var fo in factoryObjects)
            {
                AddWorldObject(fo);
                fo.ActivateLinks();
            }

            // create shard objects (corpses after unloading)
            DatabaseManager.Shard.GetObjectsByLandblock(Id.Landblock, ((List <Biota> biotas) =>
            {
                var shardObjects = (WorldObjectFactory.CreateWorldObjects(biotas));
                foreach (var so in shardObjects)
                {
                    AddWorldObject(so);
                }
            }));

            _landblock = LScape.get_landblock(Id.Raw);

            // Many thanks for GDL cache and GDL coding for loading into landblock and gmriggs assistance with taking the byte arrays and turning them in to more easy to follow (for me) data structures
            var encounters = DatabaseManager.World.GetCachedEncountersByLandblock(Id.Landblock);

            encounters.ForEach(encounter =>
            {
                var wo = WorldObjectFactory.CreateNewWorldObject(encounter.WeenieClassId);

                if (wo != null)
                {
                    float x_shift = 24.0f * encounter.CellX;
                    float y_shift = 24.0f * encounter.CellY;

                    var pos       = new Physics.Common.Position();
                    pos.ObjCellID = (uint)(id.Landblock << 16) | 1;
                    pos.Frame     = new Physics.Animation.AFrame(new Vector3(x_shift, y_shift, 0), new Quaternion(0, 0, 0, 1));
                    pos.adjust_to_outside();

                    pos.Frame.Origin.Z = _landblock.GetZ(pos.Frame.Origin);

                    wo.Location = new Position(pos.ObjCellID, pos.Frame.Origin.X, pos.Frame.Origin.Y, pos.Frame.Origin.Z, pos.Frame.Orientation.X, pos.Frame.Orientation.Y, pos.Frame.Orientation.Z, pos.Frame.Orientation.W);

                    if (!worldObjects.ContainsKey(wo.Guid))
                    {
                        AddWorldObject(wo);
                    }
                }
            });


            //LoadMeshes(objects);

            UpdateStatus(LandBlockStatusFlag.IdleLoaded);

            // FIXME(ddevec): Goal: get rid of UseTime() function...
            actionQueue.EnqueueAction(new ActionEventDelegate(() => UseTimeWrapper()));

            motionQueue = new NestedActionQueue(WorldManager.MotionQueue);

            LastActiveTime = Timer.CurrentTime;

            QueueNextHeartBeat();
        }