public void Update(GameTime gameTime) { MapRenderer.Update(MapCurrent, gameTime); if (IsTransitionActive == false && IsAreaTransitionActive == false) { MainPlayer.Update(gameTime); if (IsAreaTransitionActive == true) { return; } MapCamera.Position = MainPlayer.Position - new Vector2(MapCamera.BoundingRectangle.Width / 2, MapCamera.BoundingRectangle.Height / 2); UpdateCameraPosition(ActiveArea); for (int i = 0; i <= Entities.Count() - 1; i++) { Entities.ElementAt(i).Update(gameTime); } } else if (IsAreaTransitionActive == true) { float deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds; AreaTransitionTimer += deltaTime; if (AreaTransitionTimer > 0.15f) { // Move Camera and Player into New Area if (MainPlayer.TransitionMoveState == PlayerActor.AreaTransitionMoveState.Complete) { IsAreaTransitionActive = false; AreaTransitionTimer = 0f; MainPlayer.ResetAreaTransitionState(); } else { MainPlayer.MoveToNewArea(AreaTransitionCollisionRectangle, ActiveArea, gameTime); AreaTransitionCameraUpdate(MainPlayer.TransitionMoveState, gameTime); } } } else { if (MapTransition.State == MapTransitionHandler.TransitionState.MapChange) { UnloadMap(); } else if (MapTransition.State == MapTransitionHandler.TransitionState.Complete) { IsTransitionActive = false; MapTransition = null; } else { MapTransition.Update(gameTime); } } }
public void Draw(SpriteBatch spriteBatch) { if (MapTransition != null && MapTransition.State == MapTransitionHandler.TransitionState.MapChange) { MapTransition.Draw(spriteBatch); } else { MapRenderer.Draw(MapCurrent, MapCamera.GetViewMatrix()); if (MainPlayer.IsActive == true) { MainPlayer.Draw(spriteBatch); } foreach (MapEntity entity in Entities) { entity.Draw(spriteBatch); } if (IsTransitionActive == true) { MapTransition.Draw(spriteBatch); } } }
public bool UpdateMapTransition(MapTransition mapTran) { int rowsAffected = ExecuteNonQuery(SqlUpdateMapTransition, command => { AddParameter(command, "@id", mapTran.Id); AddParameter(command, "@map_id", mapTran.MapId); AddParameter(command, "@transition_map_id", mapTran.TransitionMapId); AddParameter(command, "@x", mapTran.ReferencePos.X); AddParameter(command, "@y", mapTran.ReferencePos.Y); AddParameter(command, "@z", mapTran.ReferencePos.Z); AddParameter(command, "@maplink_heading", mapTran.MaplinkHeading); AddParameter(command, "@maplink_color", mapTran.MaplinkColor); AddParameter(command, "@maplink_offset", mapTran.MaplinkOffset); AddParameter(command, "@maplink_width", mapTran.MaplinkWidth); AddParameter(command, "@distance", mapTran.RefDistance); AddParameter(command, "@left_x", mapTran.LeftPos.X); AddParameter(command, "@left_y", mapTran.LeftPos.Y); AddParameter(command, "@left_z", mapTran.LeftPos.Z); AddParameter(command, "@right_x", mapTran.RightPos.X); AddParameter(command, "@right_y", mapTran.RightPos.Y); AddParameter(command, "@right_z", mapTran.RightPos.Z); AddParameter(command, "@invertedPos", mapTran.InvertedTransition); AddParameter(command, "@to_x", mapTran.ToPos.X); AddParameter(command, "@to_y", mapTran.ToPos.Y); AddParameter(command, "@to_z", mapTran.ToPos.Z); AddParameter(command, "@to_heading", mapTran.ToPos.Heading); AddParameter(command, "@state", mapTran.State); AddParameter(command, "@created", mapTran.Created); AddParameter(command, "@updated", mapTran.Updated); }); return(rowsAffected > NoRowsAffected); }
private MapTransition ReadMapTransition(DbDataReader reader) { MapTransition mapTran = new MapTransition(); mapTran.Id = GetInt32(reader, "id"); mapTran.MapId = GetInt32(reader, "map_id"); mapTran.TransitionMapId = GetInt32(reader, "transition_map_id"); mapTran.ReferencePos.X = GetFloat(reader, "x"); mapTran.ReferencePos.Y = GetFloat(reader, "y"); mapTran.ReferencePos.Z = GetFloat(reader, "z"); mapTran.MaplinkHeading = GetByte(reader, "maplink_heading"); mapTran.MaplinkColor = GetInt32(reader, "maplink_color"); mapTran.MaplinkOffset = GetInt32(reader, "maplink_offset"); mapTran.MaplinkWidth = GetInt32(reader, "maplink_width"); mapTran.RefDistance = GetInt32(reader, "distance"); mapTran.LeftPos.X = GetFloat(reader, "left_x"); mapTran.LeftPos.Y = GetFloat(reader, "left_y"); mapTran.LeftPos.Z = GetFloat(reader, "left_z"); mapTran.RightPos.X = GetFloat(reader, "right_x"); mapTran.RightPos.Y = GetFloat(reader, "right_y"); mapTran.RightPos.Z = GetFloat(reader, "right_z"); mapTran.InvertedTransition = GetBoolean(reader, "invertedPos"); mapTran.ToPos.X = GetFloat(reader, "to_x"); mapTran.ToPos.Y = GetFloat(reader, "to_y"); mapTran.ToPos.Z = GetFloat(reader, "to_z"); mapTran.ToPos.Heading = GetByte(reader, "to_heading"); mapTran.State = GetInt32(reader, "state") == 0 ? false : true; mapTran.Created = GetDateTime(reader, "created"); mapTran.Updated = GetDateTime(reader, "updated"); return(mapTran); }
// Update is called once per frame void Update() { if (state == State.loadTrasition) { SceneManager.LoadScene("Scenes/TransitionMap", LoadSceneMode.Additive); state = State.waitingLoad; } else if (state == State.waitingLoad) { if (SceneManager.GetSceneByName("Transition").isLoaded) { state = State.screenshot; } } else if (state == State.screenshot) { if (trasitionMapGo.Length == 0) { trasitionMapGo = SceneManager.GetSceneByName("Transition").GetRootGameObjects(); foreach (GameObject gO in trasitionMapGo) { if (gO.name == "Transition") { mapTransition = gO.GetComponent <MapTransition>(); state = State.screenshot; mapTransition.SetPreviousScene(SceneManager.GetActiveScene()); StartCoroutine(ScreenShotImage(cam)); break; } } } } }
public bool UpdateMapTransition(MapTransition mapTran) { int rowsAffected = ExecuteNonQuery(SQL_UPDATE_MAP_TRANSITION, command => { AddParameter(command, "@id", mapTran.id); AddParameter(command, "@map_id", mapTran.mapId); AddParameter(command, "@transition_map_id", mapTran.transitionMapId); AddParameter(command, "@x", mapTran.referencePos.X); AddParameter(command, "@y", mapTran.referencePos.Y); AddParameter(command, "@z", mapTran.referencePos.Z); AddParameter(command, "@maplink_heading", mapTran.maplinkHeading); AddParameter(command, "@maplink_color", mapTran.maplinkColor); AddParameter(command, "@maplink_offset", mapTran.maplinkOffset); AddParameter(command, "@maplink_width", mapTran.maplinkWidth); AddParameter(command, "@distance", mapTran.refDistance); AddParameter(command, "@left_x", mapTran.leftPos.X); AddParameter(command, "@left_y", mapTran.leftPos.Y); AddParameter(command, "@left_z", mapTran.leftPos.Z); AddParameter(command, "@right_x", mapTran.rightPos.X); AddParameter(command, "@right_y", mapTran.rightPos.Y); AddParameter(command, "@right_z", mapTran.rightPos.Z); AddParameter(command, "@invertedPos", mapTran.invertedTransition); AddParameter(command, "@to_x", mapTran.toPos.x); AddParameter(command, "@to_y", mapTran.toPos.y); AddParameter(command, "@to_z", mapTran.toPos.z); AddParameter(command, "@to_heading", mapTran.toPos.heading); AddParameter(command, "@state", mapTran.state); AddParameter(command, "@created", mapTran.created); AddParameter(command, "@updated", mapTran.updated); }); return(rowsAffected > NO_ROWS_AFFECTED); }
private void Awake() { if (instance == null) { instance = this; } }
public void ChangeMapMessageFrame(WorldClient client, ChangeMapMessage changeMapMessage) { int mapId = (int)changeMapMessage.mapId; MapTransition replacedMap = MapTransitionsRepository.Instance.GetTransitionFromMapId((int)changeMapMessage.mapId, (int)MapManager.Instance.GetMapNeighbourTransitionEnumFromCell(client.ActiveCharacter.CellId)); if (replacedMap != null) { mapId = replacedMap.MapIdReplaced; } if (!MapManager.Instance.CheckIfNextMapIsValid(client.ActiveCharacter.MapId, mapId, client.ActiveCharacter.CellId)) { return; } var oldMap = MapManager.Instance.GetMap(client.ActiveCharacter.MapId); var map = MapManager.Instance.GetMap(mapId); if (map != null) { oldMap.ExitMap(client); client.SendPacket(new GameContextDestroyMessage()); client.SendPacket(new GameContextCreateMessage(1)); client.ActiveCharacter.MapId = mapId; client.SendPacket(new CurrentMapMessage(client.ActiveCharacter.MapId, "649ae451ca33ec53bbcbcc33becf15f4")); client.ActiveCharacter.CellId = MapManager.Instance.CheckWalkableCell(map, MapManager.Instance.GetOppositeCellFromNeight(client.ActiveCharacter.CellId)); CharacterRepository.Instance.Update(client.ActiveCharacter); } }
public List <MapTransition> SelectMapTransitions() { List <MapTransition> mapTrans = new List <MapTransition>(); ExecuteReader(SqlSelectMapTransitions, reader => { while (reader.Read()) { MapTransition mapTran = ReadMapTransition(reader); mapTrans.Add(mapTran); } }); return(mapTrans); }
public List <MapTransition> SelectMapTransitions() { List <MapTransition> mapTrans = new List <MapTransition>(); ExecuteReader(SQL_SELECT_MAP_TRANSITIONS, reader => { while (reader.Read()) { MapTransition mapTran = ReadMapTransition(reader); mapTrans.Add(mapTran); } }); return(mapTrans); }
public MapTransition SelectMapTransitionsById(int Id) { MapTransition mapTrans = null; ExecuteReader(SqlSelectMapTransitionsById, command => { AddParameter(command, "@id", Id); }, reader => { if (reader.Read()) { mapTrans = ReadMapTransition(reader); } }); return(mapTrans); }
public MapTransition SelectMapTransitionsById(int id) { MapTransition mapTrans = null; ExecuteReader(SQL_SELECT_MAP_TRANSITIONS_BY_ID, command => { AddParameter(command, "@id", id); }, reader => { if (reader.Read()) { mapTrans = ReadMapTransition(reader); } }); return(mapTrans); }
public List <MapTransition> SelectMapTransitionsByMapId(int mapId) { List <MapTransition> mapTrans = new List <MapTransition>(); ExecuteReader(SqlSelectMapTransitionsByMapId, command => { AddParameter(command, "@map_id", mapId); }, reader => { while (reader.Read()) { MapTransition mapTran = ReadMapTransition(reader); mapTrans.Add(mapTran); } }); return(mapTrans); }
private bool spawnNearTransition(ZoneDefinition previousZone) { bool result = false; GameObject gameObject = null; ZoneTransition[] array = Object.FindObjectsOfType <ZoneTransition>(); foreach (ZoneTransition zoneTransition in array) { if (zoneTransition.Zone == null) { Log.LogErrorFormatted(this, "Invalid zone transition found while attempting to spawn player. No zone definition assigned to transition '{0}'", zoneTransition.GetPath()); } else if (zoneTransition.Zone.ZoneName == previousZone.ZoneName) { gameObject = zoneTransition.gameObject; break; } } if (gameObject != null) { SpawnPointSelector component = gameObject.GetComponent <SpawnPointSelector>(); if (component != null) { result = true; setPositionToSpawnPoint(component); } else { result = false; } } else { MapTransition mapTransition = Object.FindObjectOfType <MapTransition>(); if (mapTransition != null) { SpawnPointSelector component = mapTransition.GetComponent <SpawnPointSelector>(); if (component != null) { result = true; setPositionToSpawnPoint(component); } } } return(result); }
/// <summary> /// Clears the Current map's Lists from memory, Loads New TiledMap into memory, /// positions and faces the Player accordingly, snaps the MapCamera into place, /// then signals the MapTransition object to continue it's transition /// </summary> private void UnloadMap() { MapObjects.Clear(); CollisionObjects.Clear(); Areas.Clear(); AdjacentMaps.Clear(); LoadMap("maps/" + MapTransition.DestinationMapName); MainPlayer.SetPosition(MapTransition.DestinationPosition); MainPlayer.SetFacing(MapTransition.DestinationFacing); SetAreaBoundaries(MapTransition.DestinationAreaName); MapCamera.Position = MainPlayer.Position - new Vector2(MapCamera.BoundingRectangle.Width / 2, MapCamera.BoundingRectangle.Height / 2); UpdateCameraPosition(ActiveArea); MapTransition.MapChangeComplete((Rectangle)MapCamera.BoundingRectangle); }
public bool InsertMapTransition(MapTransition mapTran) { int rowsAffected = ExecuteNonQuery(SQL_INSERT_MAP_TRANSITION, command => { //AddParameter(command, "@id", gimmick.Id); AddParameter(command, "@map_id", mapTran.mapId); AddParameter(command, "@transition_map_id", mapTran.transitionMapId); AddParameter(command, "@x", mapTran.referencePos.X); AddParameter(command, "@y", mapTran.referencePos.Y); AddParameter(command, "@z", mapTran.referencePos.Z); AddParameter(command, "@maplink_heading", mapTran.maplinkHeading); AddParameter(command, "@maplink_color", mapTran.maplinkColor); AddParameter(command, "@maplink_offset", mapTran.maplinkOffset); AddParameter(command, "@maplink_width", mapTran.maplinkWidth); AddParameter(command, "@distance", mapTran.refDistance); AddParameter(command, "@left_x", mapTran.leftPos.X); AddParameter(command, "@left_y", mapTran.leftPos.Y); AddParameter(command, "@left_z", mapTran.leftPos.Z); AddParameter(command, "@right_x", mapTran.rightPos.X); AddParameter(command, "@right_y", mapTran.rightPos.Y); AddParameter(command, "@right_z", mapTran.rightPos.Z); AddParameter(command, "@invertedPos", mapTran.invertedTransition); AddParameter(command, "@to_x", mapTran.toPos.x); AddParameter(command, "@to_y", mapTran.toPos.y); AddParameter(command, "@to_z", mapTran.toPos.z); AddParameter(command, "@to_heading", mapTran.toPos.heading); AddParameter(command, "@state", mapTran.state); AddParameter(command, "@created", mapTran.created); AddParameter(command, "@updated", mapTran.updated); }, out long autoIncrement); if (rowsAffected <= NO_ROWS_AFFECTED || autoIncrement <= NO_AUTO_INCREMENT) { return(false); } mapTran.id = (int)autoIncrement; return(true); }
public bool InsertMapTransition(MapTransition mapTran) { int rowsAffected = ExecuteNonQuery(SqlInsertMapTransition, command => { //AddParameter(command, "@id", gimmick.Id); AddParameter(command, "@map_id", mapTran.MapId); AddParameter(command, "@transition_map_id", mapTran.TransitionMapId); AddParameter(command, "@x", mapTran.ReferencePos.X); AddParameter(command, "@y", mapTran.ReferencePos.Y); AddParameter(command, "@z", mapTran.ReferencePos.Z); AddParameter(command, "@maplink_heading", mapTran.MaplinkHeading); AddParameter(command, "@maplink_color", mapTran.MaplinkColor); AddParameter(command, "@maplink_offset", mapTran.MaplinkOffset); AddParameter(command, "@maplink_width", mapTran.MaplinkWidth); AddParameter(command, "@distance", mapTran.RefDistance); AddParameter(command, "@left_x", mapTran.LeftPos.X); AddParameter(command, "@left_y", mapTran.LeftPos.Y); AddParameter(command, "@left_z", mapTran.LeftPos.Z); AddParameter(command, "@right_x", mapTran.RightPos.X); AddParameter(command, "@right_y", mapTran.RightPos.Y); AddParameter(command, "@right_z", mapTran.RightPos.Z); AddParameter(command, "@invertedPos", mapTran.InvertedTransition); AddParameter(command, "@to_x", mapTran.ToPos.X); AddParameter(command, "@to_y", mapTran.ToPos.Y); AddParameter(command, "@to_z", mapTran.ToPos.Z); AddParameter(command, "@to_heading", mapTran.ToPos.Heading); AddParameter(command, "@state", mapTran.State); AddParameter(command, "@created", mapTran.Created); AddParameter(command, "@updated", mapTran.Updated); }, out long autoIncrement); if (rowsAffected <= NoRowsAffected || autoIncrement <= NoAutoIncrement) { return(false); } mapTran.Id = (int)autoIncrement; return(true); }
public override void Execute(string[] command, NecClient client, ChatMessage message, List <ChatResponse> responses) { Character character2 = null; NpcSpawn npc2 = null; Gimmick gimmick2 = null; MapTransition mapTran2 = null; MonsterSpawn monsterSpawn2 = null; if (uint.TryParse(command[0], out uint x)) { IInstance instance = server.instances.GetInstance(x); if (instance is Character character) { character2 = character; } else if (instance is NpcSpawn npc) { npc2 = npc; } else if (instance is Gimmick gimmick) { gimmick2 = gimmick; } else if (instance is MonsterSpawn monsterSpawn) { monsterSpawn2 = monsterSpawn; } else if (instance is MapTransition mapTran) { mapTran2 = mapTran; } else { responses.Add(ChatResponse.CommandError(client, "Please provide a character/npc/gimmick/map transition instance id")); return; } } IBuffer res = BufferProvider.Provide(); if (character2 != null) { res.WriteUInt32(client.character.instanceId); res.WriteFloat(character2.x); res.WriteFloat(character2.y); res.WriteFloat(character2.z); res.WriteByte(client.character.heading); res.WriteByte(client.character.movementAnim); } else if (npc2 != null) { res.WriteUInt32(client.character.instanceId); res.WriteFloat(npc2.x); res.WriteFloat(npc2.y); res.WriteFloat(npc2.z); res.WriteByte(client.character.heading); res.WriteByte(client.character.movementAnim); } else if (gimmick2 != null) { res.WriteUInt32(client.character.instanceId); res.WriteFloat(gimmick2.x); res.WriteFloat(gimmick2.y); res.WriteFloat(gimmick2.z); res.WriteByte(client.character.heading); res.WriteByte(client.character.movementAnim); } else if (monsterSpawn2 != null) { res.WriteUInt32(client.character.instanceId); res.WriteFloat(monsterSpawn2.x); res.WriteFloat(monsterSpawn2.y); res.WriteFloat(monsterSpawn2.z); res.WriteByte(client.character.heading); res.WriteByte(client.character.movementAnim); } else if (mapTran2 != null) { res.WriteUInt32(client.character.instanceId); res.WriteFloat(mapTran2.referencePos.X); res.WriteFloat(mapTran2.referencePos.Y); res.WriteFloat(mapTran2.referencePos.Z); res.WriteByte(client.character.heading); res.WriteByte(client.character.movementAnim); } router.Send(client.map, (ushort)AreaPacketId.recv_object_point_move_notify, res, ServerType.Area); }
public void Insert(MapTransition entity) { throw new NotImplementedException(); }
public override void Execute(string[] command, NecClient client, ChatMessage message, List <ChatResponse> responses) { if (command[0] == null) { responses.Add(ChatResponse.CommandError(client, $"Invalid argument: {command[0]}")); return; } if (!int.TryParse(command[1], out int x)) { responses.Add(ChatResponse.CommandError(client, "Please provide a value. Destination Map from Map.csv, or a table ID for updating")); return; } if (!int.TryParse(command[2], out int y)) { responses.Add(ChatResponse.CommandError(client, "Good Job!")); } MapTransition myMapTransition = new MapTransition(); IBuffer res = BufferProvider.Provide(); switch (command[0]) { case "spawn" : //spawns a new object on the map at your position. makes a sign above it. and jumps over it myMapTransition = new MapTransition(); server.instances.AssignInstance(myMapTransition); IBuffer res1 = BufferProvider.Provide(); // it's the aura portal for map res1.WriteUInt32(myMapTransition.instanceId); // Unique ID res1.WriteFloat(client.character.x); //x res1.WriteFloat(client.character.y); //y res1.WriteFloat(client.character.z + 2); //z res1.WriteByte(client.character.heading); // offset res1.WriteFloat(myMapTransition.maplinkOffset); // Height res1.WriteFloat(myMapTransition.maplinkWidth); // Width res1.WriteInt32(Util.GetRandomNumber(0, 6)); // Aura color 0=blue 1=gold 2=white 3=red 4=purple 5=black 0 to 5, crash above 5 router.Send(client.map, (ushort)AreaPacketId.recv_data_notify_maplink, res1, ServerType.Area); myMapTransition.mapId = client.character.mapId; myMapTransition.transitionMapId = x; myMapTransition.referencePos.X = client.character.x; myMapTransition.referencePos.Y = client.character.y; myMapTransition.referencePos.Z = client.character.z; myMapTransition.maplinkHeading = client.character.heading; myMapTransition.maplinkColor = 0; // Aura color 0=blue (safe, town) 1=gold (locked) 2=white (open) 3=red (occupied) 4=purple (special) 5=black (Boss Exit) 0 to 5, crash above 5 myMapTransition.maplinkOffset = 200; myMapTransition.maplinkWidth = 1000; myMapTransition.refDistance = 400; myMapTransition.leftPos.X = client.character.x + 50; myMapTransition.leftPos.Y = client.character.y + 50; myMapTransition.leftPos.Z = client.character.z + 10; myMapTransition.rightPos.X = client.character.x - 50; myMapTransition.rightPos.Y = client.character.y - 50; myMapTransition.rightPos.Z = client.character.z - 10; myMapTransition.invertedTransition = false; server.settingRepository.map.TryGetValue(x, out MapSetting targetMap); myMapTransition.toPos.x = targetMap.x; myMapTransition.toPos.y = targetMap.y; myMapTransition.toPos.z = targetMap.z; myMapTransition.toPos.heading = (byte)targetMap.orientation; myMapTransition.state = true; myMapTransition.created = DateTime.Now; myMapTransition.updated = DateTime.Now; myMapTransition.maplinkHeading = (byte)(client.character.heading + 90); myMapTransition.maplinkHeading = (byte)(myMapTransition.maplinkHeading % 180); if (myMapTransition.maplinkHeading < 0) { myMapTransition.maplinkHeading += 180; } responses.Add(ChatResponse.CommandError(client, $"Spawned MapTransition {myMapTransition.instanceId}")); if (command[2] == "add" ) //if you want to send your MapTransition straight to the DB. type Add at the end of the spawn command. { if (!server.database.InsertMapTransition(myMapTransition)) { responses.Add(ChatResponse.CommandError(client, "myMapTransition could not be saved to database")); return; } responses.Add(ChatResponse.CommandError(client, $"Added MapTransition {myMapTransition.id} to the database")); } //so you dont map transition immediatly client.character.mapChange = true; Task.Delay(TimeSpan.FromSeconds(5)).ContinueWith (t1 => { myMapTransition.Start(server, client.map); client.character.mapChange = false; } ); client.map.mapTransitions.Add(myMapTransition.instanceId, myMapTransition); break; case "add": //Adds a new entry to the database myMapTransition = server.instances.GetInstance((uint)x) as MapTransition; myMapTransition.updated = DateTime.Now; if (!server.database.InsertMapTransition(myMapTransition)) { responses.Add(ChatResponse.CommandError(client, "myMapTransition could not be saved to database")); } else { responses.Add(ChatResponse.CommandError(client, $"Added MapTransition {myMapTransition.id} to the database")); } break; case "update": //Updates an existing entry in the database myMapTransition = server.instances.GetInstance((uint)x) as MapTransition; //myMapTransition = Server.Database.SelectMapTransitionsById(x); myMapTransition.updated = DateTime.Now; if (!server.database.UpdateMapTransition(myMapTransition)) { responses.Add(ChatResponse.CommandError(client, "myMapTransition could not be saved to database")); } else { responses.Add(ChatResponse.CommandError(client, $"Updated MapTransition {myMapTransition.id} in the database")); } break; case "setdestination" : //Updates the to Postion of a given maptrans row ID to the players current position on the destination map. //myMapTransition = Server.Instances.GetInstance((uint)x) as MapTransition; myMapTransition = server.database.SelectMapTransitionsById(x); myMapTransition.toPos.x = client.character.x; myMapTransition.toPos.y = client.character.y; myMapTransition.toPos.z = client.character.z; myMapTransition.toPos.heading = client.character.heading; myMapTransition.transitionMapId = client.character.mapId; myMapTransition.updated = DateTime.Now; if (!server.database.UpdateMapTransition(myMapTransition)) { responses.Add(ChatResponse.CommandError(client, "myMapTransition could not be saved to database")); } else { responses.Add(ChatResponse.CommandError(client, $"Updated MapTransition {myMapTransition.id} in the database")); } break; case "setleft": //Updates the left position of the maptransition //myMapTransition = Server.Instances.GetInstance((uint)x) as MapTransition; myMapTransition = server.database.SelectMapTransitionsById(x); myMapTransition.leftPos.X = client.character.x; myMapTransition.leftPos.Y = client.character.y; myMapTransition.leftPos.Z = client.character.z; myMapTransition.updated = DateTime.Now; if (!server.database.UpdateMapTransition(myMapTransition)) { responses.Add(ChatResponse.CommandError(client, "myMapTransition could not be saved to database")); } else { responses.Add(ChatResponse.CommandError(client, $"Updated MapTransition {myMapTransition.id} in the database")); } break; case "setright": //Updates the right position of the maptransition //myMapTransition = Server.Instances.GetInstance((uint)x) as MapTransition; myMapTransition = server.database.SelectMapTransitionsById(x); myMapTransition.rightPos.X = client.character.x; myMapTransition.rightPos.Y = client.character.y; myMapTransition.rightPos.Z = client.character.z; myMapTransition.updated = DateTime.Now; if (!server.database.UpdateMapTransition(myMapTransition)) { responses.Add(ChatResponse.CommandError(client, "myMapTransition could not be saved to database")); } else { responses.Add(ChatResponse.CommandError(client, $"Updated MapTransition {myMapTransition.id} in the database")); } break; case "stop" : //stops the maptrans task so you can modify the maptran. actually this didnt work, so i just set your transition state to 'true' so it doesnt transition you myMapTransition = server.instances.GetInstance((uint)x) as MapTransition; //myMapTransition = Server.Database.SelectMapTransitionsById(x); myMapTransition.Stop(); client.character.mapChange = true; myMapTransition.updated = DateTime.Now; { responses.Add(ChatResponse.CommandError(client, $"Stoped {myMapTransition.instanceId}. Safe to edit")); } break; case "start": //starts the maptrans task so you can test the maptran myMapTransition = server.instances.GetInstance((uint)x) as MapTransition; //myMapTransition = Server.Database.SelectMapTransitionsById(x); myMapTransition.Start(server, client.map); client.character.mapChange = false; myMapTransition.updated = DateTime.Now; { responses.Add(ChatResponse.CommandError(client, $"Started {myMapTransition.instanceId}. Safe to Warp")); } break; case "remove": //removes a MapTransition from the database myMapTransition = server.instances.GetInstance((uint)x) as MapTransition; if (!server.database.DeleteMapTransition(myMapTransition.id)) { responses.Add(ChatResponse.CommandError(client, "myMapTransition could not be deleted from database")); return; } else { responses.Add(ChatResponse.CommandError(client, $"Removed MapTransition {myMapTransition.id} from the database")); } res.WriteUInt32(myMapTransition.instanceId); router.Send(client.map, (ushort)AreaPacketId.recv_object_disappear_notify, res, ServerType.Area); break; default: //you don't know what you're doing do you? _Logger.Error($"There is no recv of type : {command[0]} "); { responses.Add(ChatResponse.CommandError(client, $"{command[0]} is not a valid MapTransition command.")); } break; } }
public void Update(MapTransition entity) { throw new NotImplementedException(); }
public override void Execute(string[] command, NecClient client, ChatMessage message, List <ChatResponse> responses) { if (command[0] == null) { responses.Add(ChatResponse.CommandError(client, $"Invalid argument: {command[0]}")); return; } switch (command[0]) { case "mob": responses.Add(ChatResponse.CommandError(client, "Mob instance ids for current map:")); foreach (KeyValuePair <uint, MonsterSpawn> monster in client.map.monsterSpawns) { MonsterSpawn mobHolder = server.instances.GetInstance(monster.Key) as MonsterSpawn; if (mobHolder != null) { responses.Add(ChatResponse.CommandError(client, $"{mobHolder.name} has instance id {mobHolder.instanceId}")); } } break; case "npc": responses.Add(ChatResponse.CommandError(client, "Npc instance ids for current map:")); foreach (KeyValuePair <uint, NpcSpawn> npc in client.map.npcSpawns) { NpcSpawn npcHolder = server.instances.GetInstance(npc.Key) as NpcSpawn; if (npcHolder != null) { responses.Add(ChatResponse.CommandError(client, $"{npcHolder.name} has instance id {npcHolder.instanceId}")); } } break; case "maptran": responses.Add(ChatResponse.CommandError(client, "Map transition instance ids for current map:")); foreach (KeyValuePair <uint, MapTransition> mapTran in client.map.mapTransitions) { MapTransition mapTranHolder = server.instances.GetInstance(mapTran.Key) as MapTransition; responses.Add(ChatResponse.CommandError(client, $"Map transition {mapTranHolder.id} has instance id {mapTranHolder.instanceId}")); } break; case "gimmick": responses.Add(ChatResponse.CommandError(client, "Gimmick instance ids for current map:")); foreach (KeyValuePair <uint, Gimmick> gimmick in client.map.gimmickSpawns) { Gimmick gimmickHolder = server.instances.GetInstance(gimmick.Key) as Gimmick; responses.Add(ChatResponse.CommandError(client, $"Gimmick {gimmickHolder.id} has instance id {gimmickHolder.instanceId}")); } break; case "ggate": responses.Add(ChatResponse.CommandError(client, "Ggate instance ids for current map:")); foreach (KeyValuePair <uint, GGateSpawn> ggate in client.map.gGateSpawns) { GGateSpawn ggateHolder = server.instances.GetInstance(ggate.Key) as GGateSpawn; responses.Add(ChatResponse.CommandError(client, $"Ggate {ggateHolder.id} has instance id {ggateHolder.instanceId}")); } break; default: _Logger.Error($"Unable to searc for: {command[0]} "); break; } }