/// <summary> /// Tries to create a new instance of a <see cref="Command"/> with the specified /// command ID. Returns <c>true</c> if the instance was created successfully. /// </summary> /// <param name="id">The command ID.</param> /// <param name="command">The instance of the <see cref="Command"/>.</param> /// <returns>Returns <c>true</c> if the instance was created successfully.</returns> public static bool TryCreate(int id, out Command command) { var type = (Type)null; if (!CommandDictionary.TryGetValue(id, out type)) { command = null; return false; } command = (Command)Activator.CreateInstance(type); return true; }
private static void HandleBuyBuildingCommand(CoCServer server, CoCRemoteClient client, Command command) { s_client = client; //TODO: Find a more consitent way of doing stuff. s_server = server; var bbCmd = command as BuyBuildingCommand; var dataIndex = bbCmd.BuildingDataIndex; var dataID = Building.IndexToDataID(dataIndex); //Console.WriteLine("Buying new building {0} at {1}, {2}", dataID, bbCmd.X, bbCmd.Y); var building = new Building(dataID); building.Data = server.DataManager.FindBuilding(dataIndex, 0); building.X = bbCmd.X; building.Y = bbCmd.Y; building.BeginConstruct(); building.ConstructionFinished += OnConstructed; client.Avatar.Home.Buildings.Add(building); }
private static void HandleUpgradeBuildingCommand(CoCServer server, CoCRemoteClient client, Command command) { // Space }
/// <summary> /// Initializes a new instance of the <see cref="InvalidCommandException"/> class with a /// specified error message and <see cref="Command"/> instance that caused the error. /// </summary> /// <param name="message">The message that describes the error.</param> /// <param name="commandInstance"> /// The <see cref="Command"/> instance that caused the error. /// </param> public InvalidCommandException(string message, Command commandInstance) : base(message, commandInstance) { // Space }
/// <summary> /// Initializes a new instance of the <see cref="InvalidCommandException"/> class with /// the specified <see cref="Command"/> instance that caused the error. /// </summary> /// <param name="commandInstance"> /// The <see cref="Command"/> instance that caused the error. /// </param> public InvalidCommandException(Command commandInstance) : base(commandInstance) { // Space }
public void RegisterCommandHandler(Command command, CommandHandler handler) { CommandHandlers.Add(command.ID, handler); }
/// <summary> /// Initializes a new instance of the <see cref="CommandException"/> class with a /// specified error message and <see cref="Message"/> instance that caused the error. /// </summary> /// <param name="message">The message that describes the error.</param> /// <param name="commandInstance"> /// The <see cref="Command"/> instance that caused the error. /// </param> public CommandException(string message, Command commandInstance) : base(message) { CommandInstance = commandInstance; }
/// <summary> /// Initializes a new instance of the <see cref="CommandException"/> class with /// the specified <see cref="Command"/> instance that caused the error. /// </summary> /// <param name="commandInstance"> /// The <see cref="Command"/> instance that caused the error. /// </param> public CommandException(Command commandInstance) { CommandInstance = commandInstance; }