public Command(string command, string commandArgs, string descSmall, string descLarge, User.PermissionLevel permission) { this.command = command; this.command_args = commandArgs; this.description_small = descSmall; this.description_Long = descLarge; this.permission = permission; }
public User CreateUser(string name) { SaveVersions.Version_Current.User usrSave = new SaveVersions.Version_Current.User (); usrSave.name = name; User user = new User (usrSave); _users.Add (name, user); return user; }
public CommandDescription(string _command, string _command_args, string _description_small, User.PermissionLevel permission, string _callback) { command = _command.ToLower(); command_args = _command_args; description_small = _description_small; description_Long = string.Empty; this.permission = permission; callback = GetCallbackFromString(_command, _callback); }
public CommandDescription(string _command, string _command_args, string _description_small, User.PermissionLevel permission, CommandExecuter.CommandFunction _callback) { command = _command.ToLower(); command_args = _command_args; description_small = _description_small; description_Long = string.Empty; this.permission = permission; callback = _callback; }
public bool CreateAlliance(string name, User owner) { // see if can create alliance. if (!AllianceExist(name)) { Alliance all = new Alliance(name, owner); _alliances.Add(name, all); return true; } return false; }
public void Load(AllianceSave save) { if (GameServer.Instance.Users.UserExists(save.owner)) { members.Clear(); Name = save.name; Owner = GameServer.Instance.Users.GetUser(save.owner); for (int i = 0; i < save.members.Length; i++) { if (GameServer.Instance.Users.UserExists(save.members[i])) { User user = GameServer.Instance.Users.GetUser(save.members[i]); user.alliance = this; members.Add(user.Name, new Member(user)); } } } }
private object NetUsage_CMD(User caller, params string[] args) { _server.Net.DisplayDataRate (); return string.Empty; }
private object Mute_CMD(User caller, params string[] args) { if (caller.Permission == User.PermissionLevel.Moderator || caller.Permission == User.PermissionLevel.Admin || caller.Permission == User.PermissionLevel.Server) { // moderators must specify time arg. } return "Not implemented."; }
public Alliance(string name, User owner) { Name = name; Owner = owner; members = new Dictionary<string, Member>(); }
public void AddUser(User user) { if (!UserExists (user.Name)) { _users.Add(user.Name, user); } }
private object Time_CMD(User caller, params string[] args) { return GameTimer.GetDateTime(); }
// command functions private object Runtime_CMD(User caller, params string[] args) { if (_server.WorldLoaded) return _server.GameTime.GetRuntime(); Logger.LogWarning ("World not loaded."); return string.Empty; }
private object NewUser_CMD(User caller, params string[] args) { if (args.Length == 5) { string username = args[1]; string password = args[2]; string permission = args[3]; string email = args[4]; return GameServer.Instance.CreatePlayer(username, password, permission, email); } else return "Requires 4 arguments."; }
private object Clear_CMD(User caller, params string[] args) { Logger.Clear (); return string.Empty; }
public Standing GetStandings(User usr) { if (usr.Permission == PermissionLevel.Admin || usr.Permission == PermissionLevel.Admin) return Standing.Own; if (usr.Name == Name) return Standing.Own; if (alliance != null && alliance.HasMember(usr)) return Standing.Ally; if (alliance != null && usr.alliance != null && alliance.IsEnemy(usr.alliance.Name)) return Standing.Enemy; return Standing.Nuetral; }
public bool HasMember(User user) { return members.ContainsKey(user.Name); }
public void AddMember(User user) { if (!HasMember(user)) { members.Add(user.Name, new Member(user)); } }
private object NewAlliance_CMD(User caller, params string[] args) { if (caller.Permission == User.PermissionLevel.Server) { if (args.Length == 2) { GameServer.Instance.Alliances.CreateAlliance(args[0], args[1]); return "Alliance created"; } else if (args.Length == 1) { GameServer.Instance.Alliances.CreateAlliance(args[0], "_server_"); return "Alliance created"; } } else if (caller.Permission == User.PermissionLevel.Admin) { if (args.Length == 2) { GameServer.Instance.Alliances.CreateAlliance(args[0], args[1]); return "Alliance created"; } else if (args.Length == 1) { GameServer.Instance.Alliances.CreateAlliance(args[0], caller.Name); return "Alliance created"; } } return "Alliance creation failed."; }
private object NewStructure_CMD(User caller, params string[] args) { if (caller.Permission == User.PermissionLevel.Admin || caller.Permission == User.PermissionLevel.Server) { if (args.Length == 3) { int x; int y; Structures.Structure.StructureType type; if (int.TryParse(args[0], out x) && int.TryParse(args[1], out y) && Enum.TryParse(args[2], out type)) { caller.CreateStructure(new Vector2Int(x, y), type, true); return "Structure created."; } } else return "Error: command requires 3 arguements."; } return "Invalid permission level."; }
private object Create_CMD(User caller, params string[] args) { try { if (args.Length == 2){ TaskQueue.QeueAsync("GeneralWorker", ()=> _server.Worlds.CreateWorld(args[1])); } } catch(Exception e){ Logger.LogError("{0}\n{1}", e.Message, e.StackTrace); } return string.Empty; }
private object Preview_CMD(User caller, params string[] args) { int seed = 0; if (args.Length == 1) seed = AppSettings.TerrainSeed; else if (args.Length == 2 && args [1].Equals ("-r")) { seed = new Random (GameTimer.GetEpoch ()).Next (int.MinValue, int.MaxValue); } else if (args.Length == 2) { if (int.TryParse(args[1], out seed)); } TaskQueue.QeueAsync("terrain preview", ()=>{ try { List<GradientPresets.GradientKeyData> keys = new List<GradientPresets.GradientKeyData>(); keys.Add(new GradientPresets.GradientKeyData(new Color(255, 0, 0, 128), 0)); keys.Add(new GradientPresets.GradientKeyData(new Color(255, 32, 64, 128), 0.4f)); keys.Add(new GradientPresets.GradientKeyData(new Color(255, 64, 96, 191), 0.48f)); keys.Add(new GradientPresets.GradientKeyData(new List<string> {"sand.png"}, 0.5f)); keys.Add(new GradientPresets.GradientKeyData(new List<string> {"trees1.png", "trees2.png" }, 0.52f)); keys.Add(new GradientPresets.GradientKeyData(new List<string> {"grass1.png", "trees2.png"}, 0.55f)); keys.Add(new GradientPresets.GradientKeyData(new List<string> {"grass1.png", "grass2.png", "trees2.png"}, 0.60f)); keys.Add(new GradientPresets.GradientKeyData(new List<string> {"grass1.png", "grass2.png"}, 0.90f)); keys.Add(new GradientPresets.GradientKeyData(new List<string> {"grass1.png", "grass2.png"}, 1f)); //GradientPresets.CreateGradient(keys); GradiantPresetLoader.PresetSerializer saveObj = new GradiantPresetLoader.PresetSerializer(AppSettings.TerrainPreset, keys); FileManager.SaveConfigFile(GameServer.Instance.AppDirectory + "GradientPresets" + GameServer.sepChar + AppSettings.TerrainPreset+".json", saveObj, false); //return; IModule module = new Perlin (); ((Perlin)module).OctaveCount = 16; ((Perlin)module).Seed = AppSettings.TerrainSeed; TerrainBuilder builder = new TerrainBuilder(AppSettings.TerrainWidth, AppSettings.TerrainHeight, seed); builder.Generate (module, AppSettings.TerrainPreset); System.Drawing.Bitmap map = builder.GetBitmap(); /*System.Windows.Forms.Form imageForm = new System.Windows.Forms.Form(); imageForm.Text = "Seed preview: " + seed; imageForm.Width = settings.TerrainWidth; imageForm.Height = settings.TerrainHeight; imageForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable; imageForm.Controls.Add (new System.Windows.Forms.PictureBox () {Image = map, Dock = System.Windows.Forms.DockStyle.Fill}); imageForm.ShowDialog(); Logger.Log("Preview closed."); imageForm.Close(); imageForm.Dispose();*/ } catch(Exception e){ Logger.LogError("{0}\n{1}", e.Message, e.StackTrace); } }); return "Seed: " + seed; }
private object Exit_CMD(User caller, params string[] args) { if (_server.WorldLoaded) _server.Worlds.SaveCurrentWorld (); _server.Exit (); return "Good bye..."; }
private object Save_CMD(User caller, params string[] args) { if (args.Length == 1) _server.Save (); else if (args.Length == 2) _server.Save (args [1]); return string.Empty; }
private object Help_CMD(User caller, params string[] args) { StringBuilder output = new StringBuilder (); if (args.Length == 1) { output.AppendLine(string.Format("Commands ({0}):", _cmdTable.Count.ToString())); foreach (string key in _cmdTable.Keys) { if (caller.CanCallCommand(key)) output.AppendLine (string.Format (" {0} : {1}", key.PadRight(padAmount, ' '), _cmdDescription [key].description_small)); } } else if (args.Length == 2) { if (_cmdTable.ContainsKey (args [1])) { if (caller.CanCallCommand(args[1])) { output.AppendLine(string.Format(" - Command: {0} {1}", _cmdDescription[args[1]].command, _cmdDescription[args[1]].command_args)); output.AppendLine(string.Format(" - Short description: {0}", _cmdDescription[args[1]].description_small)); if (!string.IsNullOrEmpty(_cmdDescription[args[1]].description_Long)) output.AppendLine(string.Format(" - Long description: {0}", _cmdDescription[args[1]].description_Long)); } else return string.Format("error: {0} permissions required.", _cmdDescription[args[1]].permission.ToString()); } else return "Command not found: " + args[1]; } else { return "To many arguments."; } return output.ToString(); }
public void AddConnectedUser(string key, User usr) { _connectedUsers [key] = usr; }
private object Load_CMD(User caller, params string[] args) { try { if (args.Length == 2){ _server.Worlds.LoadWorld(args[1]); } } catch(Exception e){ Logger.LogError("{0}: {1}\n{2}", e.GetType().ToString(), e.Message, e.StackTrace); } return string.Empty; }
private object Kick_CMD(User caller, params string[] args) { if (caller.Permission == User.PermissionLevel.Moderator || caller.Permission == User.PermissionLevel.Admin || caller.Permission == User.PermissionLevel.Server) { } return "Not implemented."; }
public Member(User user) { this.user = user; }