internal void OnCycle(ref int idleCount) { ToRemove.Clear(); int userCounter = 0; foreach (RoomUnit unit in UnitList.Values) { unit.OnCycle(); bool updated = false; RoomUser user = unit as RoomUser; if (room.GotFreeze() && user != null) { room.GetFreeze().CycleUser(user); } if (unit.SetStep) { if (room.GetGameMap().CanWalk(unit.SetX, unit.SetY, unit.AllowOverride)) { room.GetGameMap().UpdateUnitMovement(new Point(unit.Coordinate.X, unit.Coordinate.Y), new Point(unit.SetX, unit.SetY), unit); List <RoomItem> items = room.GetGameMap().GetCoordinatedItems(new Point(unit.X, unit.Y)); unit.X = unit.SetX; unit.Y = unit.SetY; unit.Z = unit.SetZ; lock (items) { foreach (RoomItem item in items) { item.UserWalksOffFurni(unit); } } if (user != null && unit.X == room.GetGameMap().Model.DoorX&& unit.Y == room.GetGameMap().Model.DoorY&& !ToRemove.Contains(unit)) { ToRemove.Add(user); continue; } UpdateUserStatus(unit, true); } unit.SetStep = false; } if (unit.IsWalking) { // Find next square GameMap map = room.GetGameMap(); SquarePoint Point = DreamPathfinder.GetNextStep(unit.X, unit.Y, unit.GoalX, unit.GoalY, map.Map, map.ItemHeightMap, map.Model.MapSizeX, map.Model.MapSizeY, unit.AllowOverride, map.DiagonalEnabled); if (Point.X == unit.X && Point.Y == unit.Y) //No path found, or reached goal (: { unit.IsWalking = false; unit.RemoveStatus("mv"); UpdateUserStatus(unit, false); } else { // Let's walk! int nextX = Point.X; int nextY = Point.Y; //unit.RemoveStatus("mv"); double nextZ = room.GetGameMap().SqAbsoluteHeight(nextX, nextY); unit.Statuses.Remove("lay"); unit.Statuses.Remove("sit"); unit.AddStatus("mv", nextX + "," + nextY + "," + TextHandling.GetString(nextZ)); bool moonWalk = user == null ? false : user.moonwalkEnabled; int newRot = Rotation.Calculate(unit.X, unit.Y, nextX, nextY, moonWalk); unit.RotBody = newRot; unit.RotHead = newRot; unit.SetStep = true; unit.SetX = nextX; unit.SetY = nextY; unit.SetZ = nextZ; updated = true; room.GetGameMap().Map[unit.X, unit.Y] = unit.SqState; // REstore the old one unit.SqState = room.GetGameMap().Map[unit.SetX, unit.SetY]; //Backup the new one if (user != null) { UpdateUserEffect(user, user.SetX, user.SetY); if (user.IsSitting == true) { user.IsSitting = false; } if (user.IsLaying == true) { user.IsLaying = false; } } if (!room.AllowWalkthrough) { room.GetGameMap().Map[nextX, nextY] = 0; } } unit.UpdateNeeded = true; } else { if (unit.Statuses.ContainsKey("mv")) { unit.Statuses.Remove("mv"); unit.UpdateNeeded = true; } } if (user != null) { userCounter++; } if (!updated && user != null) { UpdateUserEffect(user, user.X, user.Y); } } if (userCounter == 0) { idleCount++; } foreach (RoomUser toRemove in ToRemove) { GameClient client = FirewindEnvironment.GetGame().GetClientManager().GetClientByUserID(toRemove.ID); if (client != null) { RemoveUserFromRoom(client, true, false); client.CurrentRoomUserID = -1; } else { RemoveRoomUnit(toRemove); } } if (userCount != userCounter) { UpdateUserCount(userCounter); } }
private void Initialize(UInt32 Id, string Name, string Description, string Owner, int OwnerId, int Category, int State, int UsersMax, string ModelName, int Score, List<string> pTags, bool AllowPets, bool AllowPetsEating, bool AllowWalkthrough, bool Hidewall, string Password, string Wallpaper, string Floor, string Landscape, RoomData RoomData, bool RightOverride, int walltickness, int floorthickness, Group group) { this.mDisposed = false; this.Id = Id; this.Name = Name; this.Description = Description; this.Owner = Owner; this.OwnerId = OwnerId; this.Category = Category; this.State = State; this.UsersNow = 0; this.UsersMax = UsersMax; this.ModelName = ModelName; this.Score = Score; tagCount = 0; this.Tags = new ArrayList(); foreach (string tag in pTags) { tagCount++; Tags.Add(tag); } this.AllowPets = AllowPets; this.AllowPetsEating = AllowPetsEating; this.AllowWalkthrough = AllowWalkthrough; this.Hidewall = Hidewall; this.Password = Password; this.Bans = new Dictionary<int, double>(); this.Wallpaper = Wallpaper; this.Floor = Floor; this.Landscape = Landscape; this.chatMessageManager = new ChatMessageManager(); this.ActiveTrades = new ArrayList(); this.mCycleEnded = false; this.mRoomData = RoomData; this.EveryoneGotRights = RightOverride; this.roomMessages = new Queue(); this.chatMessageQueue = new Queue(); this.rnd = new Random(); this.roomMessages = new Queue(); this.roomAlerts = new Queue(); this.roomBadge = new Queue(); this.roomKick = new Queue(); this.roomServerMessages = new Queue(); this.IdleTime = 0; this.RoomMuted = false; this.WallThickness = walltickness; this.FloorThickness = floorthickness; this.gamemap = new GameMap(this); this.roomItemHandling = new RoomItemHandling(this); this.roomUserManager = new RoomUnitManager(this); this.wiredHandler = new WiredHandler(this); this.Group = group; LoadRights(); GetRoomItemHandler().LoadFurniture(); wiredHandler.LoadWired(); GetGameMap().GenerateMaps(); LoadMusic(); //LoadBots(); using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.runFastQuery("REPLACE INTO room_active VALUES (" + Id + ",1)"); } FirewindEnvironment.GetGame().GetRoomManager().QueueActiveRoomAdd(mRoomData); }
private void Initialize(UInt32 Id, string Name, string Description, string Owner, int OwnerId, int Category, int State, int UsersMax, string ModelName, int Score, List <string> pTags, bool AllowPets, bool AllowPetsEating, bool AllowWalkthrough, bool Hidewall, string Password, string Wallpaper, string Floor, string Landscape, RoomData RoomData, bool RightOverride, int walltickness, int floorthickness, Group group) { this.mDisposed = false; this.Id = Id; this.Name = Name; this.Description = Description; this.Owner = Owner; this.OwnerId = OwnerId; this.Category = Category; this.State = State; this.UsersNow = 0; this.UsersMax = UsersMax; this.ModelName = ModelName; this.Score = Score; tagCount = 0; this.Tags = new ArrayList(); foreach (string tag in pTags) { tagCount++; Tags.Add(tag); } this.AllowPets = AllowPets; this.AllowPetsEating = AllowPetsEating; this.AllowWalkthrough = AllowWalkthrough; this.Hidewall = Hidewall; this.Password = Password; this.Bans = new Dictionary <int, double>(); this.Wallpaper = Wallpaper; this.Floor = Floor; this.Landscape = Landscape; this.chatMessageManager = new ChatMessageManager(); this.ActiveTrades = new ArrayList(); this.mCycleEnded = false; this.mRoomData = RoomData; this.EveryoneGotRights = RightOverride; this.roomMessages = new Queue(); this.chatMessageQueue = new Queue(); this.rnd = new Random(); this.roomMessages = new Queue(); this.roomAlerts = new Queue(); this.roomBadge = new Queue(); this.roomKick = new Queue(); this.roomServerMessages = new Queue(); this.IdleTime = 0; this.RoomMuted = false; this.WallThickness = walltickness; this.FloorThickness = floorthickness; this.gamemap = new GameMap(this); this.roomItemHandling = new RoomItemHandling(this); this.roomUserManager = new RoomUnitManager(this); this.wiredHandler = new WiredHandler(this); this.Group = group; LoadRights(); GetRoomItemHandler().LoadFurniture(); wiredHandler.LoadWired(); GetGameMap().GenerateMaps(); LoadMusic(); //LoadBots(); using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.runFastQuery("REPLACE INTO room_active VALUES (" + Id + ",1)"); } FirewindEnvironment.GetGame().GetRoomManager().QueueActiveRoomAdd(mRoomData); }