/// <summary> /// Monster Locations, Generators<para /> /// This will be called from a separate task from our constructor. Use thread safety when interacting with this landblock. /// </summary> private void CreateWorldObjects() { var objects = DatabaseManager.World.GetCachedInstancesByLandblock(Id.Landblock); var shardObjects = DatabaseManager.Shard.GetStaticObjectsByLandblock(Id.Landblock); var factoryObjects = WorldObjectFactory.CreateNewWorldObjects(objects, shardObjects); // for mansion linking var houses = new List <House>(); actionQueue.EnqueueAction(new ActionEventDelegate(() => { foreach (var fo in factoryObjects) { WorldObject parent = null; if (fo.WeenieType == ACE.Entity.Enum.WeenieType.House && fo.HouseType == ACE.Entity.Enum.HouseType.Mansion) { var house = fo as House; houses.Add(house); house.LinkedHouses.Add(houses[0]); if (houses.Count > 1) { houses[0].LinkedHouses.Add(house); parent = houses[0]; } } AddWorldObject(fo); fo.ActivateLinks(objects, shardObjects, parent); } })); }
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(); }
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; }
/// <summary> /// Monster Locations, Generators<para /> /// This will be called from a separate task from our constructor. Use thread safety when interacting with this landblock. /// </summary> private void CreateWorldObjects() { var objects = DatabaseManager.World.GetCachedInstancesByLandblock(Id.Landblock); var shardObjects = DatabaseManager.Shard.GetStaticObjectsByLandblock(Id.Landblock); var factoryObjects = WorldObjectFactory.CreateNewWorldObjects(objects, shardObjects); actionQueue.EnqueueAction(new ActionEventDelegate(() => { foreach (var fo in factoryObjects) { AddWorldObject(fo); fo.ActivateLinks(objects, shardObjects); } })); }
/// <summary> /// Monster Locations, Generators<para /> /// This will be called from a separate task from our constructor. Use thread safety when interacting with this landblock. /// </summary> private void CreateWorldObjects() { var objects = DatabaseManager.World.GetCachedInstancesByLandblock(Id.Landblock); var shardObjects = DatabaseManager.Shard.GetStaticObjectsByLandblock(Id.Landblock); var factoryObjects = WorldObjectFactory.CreateNewWorldObjects(objects, shardObjects); actionQueue.EnqueueAction(new ActionEventDelegate(() => { // for mansion linking var houses = new List <House>(); foreach (var fo in factoryObjects) { WorldObject parent = null; if (fo.WeenieType == WeenieType.House) { var house = fo as House; Houses.Add(house); if (fo.HouseType == HouseType.Mansion) { houses.Add(house); house.LinkedHouses.Add(houses[0]); if (houses.Count > 1) { houses[0].LinkedHouses.Add(house); parent = houses[0]; } } } AddWorldObject(fo); fo.ActivateLinks(objects, shardObjects, parent); if (fo.PhysicsObj != null) { fo.PhysicsObj.Order = 0; } } CreateWorldObjectsCompleted = true; _landblock.SortObjects(); })); }
public House LoadHouse(bool forceLoad = false) { if (House != null && !forceLoad) { return(House); } var houseGuid = HouseInstance.Value; var landblock = (ushort)((houseGuid >> 12) & 0xFFFF); var biota = DatabaseManager.Shard.GetBiota(houseGuid); var instances = DatabaseManager.World.GetCachedInstancesByLandblock(landblock); if (instances == null || instances.Count == 0 || biota == null) { Console.WriteLine($"{Name} sent HouseInstance={HouseInstance:X8}, instances={instances}, biota={biota}"); return(null); } var objects = WorldObjectFactory.CreateNewWorldObjects(instances, new List <Biota>() { biota }, houseGuid); if (objects.Count == 0) { Console.WriteLine($"{Name} sent HouseInstance={HouseInstance:X8}, found instances and biota, but object count=0"); return(null); } var house = objects[0] as House; if (house == null) { Console.WriteLine($"{Name} sent HouseInstance={HouseInstance:X8}, found instances and biota, but type {objects[0].WeenieType}"); return(null); } house.ActivateLinks(instances, new List <Biota>() { biota }); House = house; return(house); }
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.GetCachedInstancesByLandblock(Id.Landblock); // Instances var factoryObjects = WorldObjectFactory.CreateNewWorldObjects(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); }
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); }