예제 #1
0
        /// <summary>
        /// Spawns the semi-randomized monsters scattered around the outdoors
        /// </summary>
        public void SpawnEncounters()
        {
            // get the encounter spawns for this landblock
            var encounters = DatabaseManager.World.GetCachedEncountersByLandblock(Id.Landblock);

            foreach (var encounter in encounters)
            {
                var wo = WorldObjectFactory.CreateNewWorldObject(encounter.WeenieClassId);

                if (wo == null)
                {
                    continue;
                }

                var xPos = encounter.CellX * 24.0f;
                var yPos = encounter.CellY * 24.0f;

                var pos = new Physics.Common.Position();
                pos.ObjCellID = (uint)(Id.Landblock << 16) | 1;
                pos.Frame     = new Physics.Animation.AFrame(new Vector3(xPos, yPos, 0), Quaternion.Identity);
                pos.adjust_to_outside();

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

                wo.Location = new Position(pos.ObjCellID, pos.Frame.Origin, pos.Frame.Orientation);

                if (!worldObjects.ContainsKey(wo.Guid))
                {
                    AddWorldObject(wo);
                }
            }
        }
예제 #2
0
        public Landblock(LandblockId id)
        {
            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.GetCachedInstancesByLandblock(Id.Landblock); // Instances

            var factoryObjects = WorldObjectFactory.CreateNewWorldObjects(objects);

            factoryObjects.ForEach(fo =>
            {
                AddWorldObject(fo);
                fo.ActivateLinks();
            });

            _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);
        }