Beispiel #1
0
        public Landblock(LandblockId id)
        {
            this.id = id;

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

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

            // TODO: load objects from world database such as lifestones, doors, player corpses, NPCs, Vendors
            var objects = DatabaseManager.World.GetObjectsByLandblock(this.id.Landblock);

            foreach (var o in objects)
            {
                ImmutableWorldObject iwo = new ImmutableWorldObject(o);
                worldObjects.Add(iwo.Guid, iwo);
            }
        }
Beispiel #2
0
        public Position(float northSouth, float eastWest)
        {
            northSouth -= 0.5f;
            eastWest   -= 0.5f;
            northSouth *= 10.0f;
            eastWest   *= 10.0f;

            uint baseX = (uint)(eastWest + 0x400);
            uint baseY = (uint)(northSouth + 0x400);

            if (baseX < 0 || baseX >= 0x7F8 || baseY < 0 || baseY >= 0x7F8)
            {
                throw new Exception("Bad coordinates");  // TODO: Instead of throwing exception should we set to a default location?
            }
            float xOffset = ((baseX & 7) * 24.0f) + 12;
            float yOffset = ((baseY & 7) * 24.0f) + 12;
            // float zOffset = GetZFromCellXY(LandblockId.Raw, xOffset, yOffset);
            float zOffset = 0.0f;

            LandblockId = new LandblockId(GetCellFromBase(baseX, baseY));
            // Offset
            PositionX = xOffset;
            PositionY = yOffset;
            PositionZ = zOffset;
            // Facing
            RotationX = 0.0f;
            RotationY = 0.0f;
            RotationZ = 0.0f;
            RotationW = 1.0f;
        }
Beispiel #3
0
        public Landblock(LandblockId id)
        {
            this.id = id;

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

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

            // TODO: load objects from world database such as lifestones, doors, player corpses, NPCs, Vendors
            var objects        = DatabaseManager.World.GetObjectsByLandblock(this.id.Landblock);
            var factoryObjects = GenericObjectFactory.CreateWorldObjects(objects);

            factoryObjects.ForEach(fo => worldObjects.Add(fo.Guid, fo));

            var creatures = DatabaseManager.World.GetCreaturesByLandblock(this.id.Landblock);

            foreach (var c in creatures)
            {
                Creature cwo = new Creature(c);
                worldObjects.Add(cwo.Guid, cwo);
            }
        }
Beispiel #4
0
        public Position(BinaryReader payload)
        {
            LandblockId = new LandblockId(payload.ReadUInt32());
            Offset      = new Vector3(payload.ReadSingle(), payload.ReadSingle(), payload.ReadSingle());

            // packet stream isn't the same order as the quaternion constructor
            float qw = payload.ReadSingle();

            Facing = new Quaternion(payload.ReadSingle(), payload.ReadSingle(), payload.ReadSingle(), qw);
        }
Beispiel #5
0
 public Position(uint landblock, float x, float y, float z, float qx = 0.0f, float qy = 0.0f, float qz = 0.0f, float qw = 0.0f)
 {
     LandblockId = new LandblockId(landblock);
     Cell        = LandblockId.Raw;
     PositionX   = x;
     PositionY   = y;
     PositionZ   = z;
     RotationX   = qx;
     RotationY   = qy;
     RotationZ   = qz;
     RotationW   = qw;
 }
Beispiel #6
0
 public Position(AceObjectPropertiesPosition aoPos)
 {
     Cell        = aoPos.Cell;
     LandblockId = new LandblockId(Cell);
     PositionX   = aoPos.PositionX;
     PositionY   = aoPos.PositionY;
     PositionZ   = aoPos.PositionZ;
     RotationW   = aoPos.RotationW;
     RotationX   = aoPos.RotationX;
     RotationY   = aoPos.RotationY;
     RotationZ   = aoPos.RotationZ;
 }
Beispiel #7
0
 public Position(uint newCell, float newPositionX, float newPositionY, float newPositionZ, float newRotationX, float newRotationY, float newRotationZ, float newRotationW)
 {
     LandblockId = new LandblockId(newCell);
     Cell        = newCell;
     PositionX   = newPositionX;
     PositionY   = newPositionY;
     PositionZ   = newPositionZ;
     RotationX   = newRotationX;
     RotationY   = newRotationY;
     RotationZ   = newRotationZ;
     RotationW   = newRotationW;
 }
Beispiel #8
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);

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

            // TODO: load objects from world database such as lifestones, doors, player corpses, NPCs, Vendors
            var objects        = DatabaseManager.World.GetObjectsByLandblock(this.id.Landblock);
            var factoryObjects = GenericObjectFactory.CreateWorldObjects(objects);

            factoryObjects.ForEach(fo => worldObjects.Add(fo.Guid, fo));

            // Load static creature spawns from DB
            var creatures = DatabaseManager.World.GetCreaturesByLandblock(this.id.Landblock);

            foreach (var c in creatures)
            {
                Creature cwo = new Creature(c);
                worldObjects.Add(cwo.Guid, cwo);
            }

            // Load generator creature spawns from DB
            var creatureGenerators = DatabaseManager.World.GetCreatureGeneratorsByLandblock(this.id.Landblock);

            foreach (var cg in creatureGenerators)
            {
                List <Creature> creatureList = MonsterFactory.SpawnCreaturesFromGenerator(cg);
                foreach (var c in creatureList)
                {
                    worldObjects.Add(c.Guid, c);
                }
            }

            UpdateStatus(LandBlockStatusFlag.IdleLoaded);
        }
Beispiel #9
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);
        }
Beispiel #10
0
 public Position(uint characterId, PositionType type, uint newCell, float newPositionX, float newPositionY, float newPositionZ, float newRotationX, float newRotationY, float newRotationZ, float newRotationW)
 {
     LandblockId  = new LandblockId(newCell);
     CharacterId  = characterId;
     PositionType = type;
     Cell         = newCell;
     PositionX    = newPositionX;
     PositionY    = newPositionY;
     PositionZ    = newPositionZ;
     RotationX    = newRotationX;
     RotationY    = newRotationY;
     RotationZ    = newRotationZ;
     RotationW    = newRotationW;
 }
Beispiel #11
0
 public Position(BinaryReader payload)
 {
     LandblockId = new LandblockId(payload.ReadUInt32());
     Cell        = LandblockId.Raw;
     // Offset  = new Vector3(payload.ReadSingle(), payload.ReadSingle(), payload.ReadSingle());
     PositionX = payload.ReadSingle();
     PositionY = payload.ReadSingle();
     PositionZ = payload.ReadSingle();
     // float qw = payload.ReadSingle();
     RotationW = payload.ReadSingle();
     // Facing  = new Quaternion(payload.ReadSingle(), payload.ReadSingle(), payload.ReadSingle(), qw);
     RotationX = payload.ReadSingle();
     RotationY = payload.ReadSingle();
     RotationZ = payload.ReadSingle();
     // packet stream isn't the same order as the quaternion constructor
 }
Beispiel #12
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);
        }
Beispiel #13
0
        public Position(float northSouth, float eastWest)
        {
            northSouth -= 0.5f;
            eastWest   -= 0.5f;
            northSouth *= 10.0f;
            eastWest   *= 10.0f;

            uint baseX = (uint)(eastWest + 0x400);
            uint baseY = (uint)(northSouth + 0x400);

            if (baseX < 0 || baseX >= 0x7F8 || baseY < 0 || baseY >= 0x7F8)
            {
                throw new Exception("Bad coordinates");  // TODO: Instead of throwing exception should we set to a default location?
            }
            float xOffset = ((baseX & 7) * 24.0f) + 12;
            float yOffset = ((baseY & 7) * 24.0f) + 12;
            float zOffset = GetZFromCellXY(LandblockId.Raw, xOffset, yOffset);

            LandblockId = new LandblockId(GetCellFromBase(baseX, baseY));
            Offset      = new Vector3(xOffset, yOffset, zOffset);
            Facing      = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f);
        }
Beispiel #14
0
        public Landblock(LandblockId id)
        {
            this.id = id;

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

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

            // TODO: load objects from world database such as lifestones, doors, player corpses, NPCs, Vendors
        }
Beispiel #15
0
 public bool IsAdjacentTo(LandblockId block)
 {
     return(Math.Abs(this.LandblockX - block.LandblockX) <= 1 && Math.Abs(this.LandblockY - block.LandblockY) <= 1);
 }
Beispiel #16
0
 public Position(uint landblock, float x, float y, float z, float qx = 0.0f, float qy = 0.0f, float qz = 0.0f, float qw = 0.0f)
 {
     LandblockId = new LandblockId(landblock);
     Offset      = new Vector3(x, y, z);
     Facing      = new Quaternion(qx, qy, qz, qw);
 }