/// <summary> /// Processes commands (chat messages starting with /) /// </summary> /// <param name="text">input text</param> private void ProcessCommand(string text) { //Commands are processed locally and then sent to the server to be processed there again. var args = new List <string>(); CommandParsing.ParseArguments(text, args); string command = args[0]; //Entity player; //var entMgr = IoCManager.Resolve<IEntityManager>(); //var plrMgr = IoCManager.Resolve<IPlayerManager>(); //player = plrMgr.ControlledEntity; //IoCManager.Resolve<INetworkManager>(). switch (command) { case "cls": components.Clear(); last_y = 0; //this.scrollbarH.Value = 0; this.scrollbarV.Value = 0; break; case "quit": Environment.Exit(0); break; case "addparticles": //This is only clientside. if (args.Count >= 3) { Entity target = null; if (args[1].ToLowerInvariant() == "player") { var plrMgr = IoCManager.Resolve <IPlayerManager>(); if (plrMgr != null) { if (plrMgr.ControlledEntity != null) { target = plrMgr.ControlledEntity; } } } else { var entMgr = IoCManager.Resolve <IEntityManagerContainer>(); if (entMgr != null) { int entUid = int.Parse(args[1]); target = entMgr.EntityManager.GetEntity(entUid); } } if (target != null) { if (!target.HasComponent(ComponentFamily.Particles)) { var entMgr = IoCManager.Resolve <IEntityManagerContainer>(); var compo = (IParticleSystemComponent)entMgr.EntityManager.ComponentFactory.GetComponent("ParticleSystemComponent"); target.AddComponent(ComponentFamily.Particles, compo); } else { var entMgr = IoCManager.Resolve <IEntityManagerContainer>(); var compo = (IParticleSystemComponent)entMgr.EntityManager.ComponentFactory.GetComponent("ParticleSystemComponent"); target.AddComponent(ComponentFamily.Particles, compo); } } } SendServerConsoleCommand(text); //Forward to server. break; case "removeparticles": if (args.Count >= 3) { Entity target = null; if (args[1].ToLowerInvariant() == "player") { var plrMgr = IoCManager.Resolve <IPlayerManager>(); if (plrMgr != null) { if (plrMgr.ControlledEntity != null) { target = plrMgr.ControlledEntity; } } } else { var entMgr = IoCManager.Resolve <IEntityManagerContainer>(); if (entMgr != null) { int entUid = int.Parse(args[1]); target = entMgr.EntityManager.GetEntity(entUid); } } if (target != null) { if (target.HasComponent(ComponentFamily.Particles)) { IParticleSystemComponent compo = (IParticleSystemComponent)target.GetComponent(ComponentFamily.Particles); compo.RemoveParticleSystem(args[2]); } } } SendServerConsoleCommand(text); //Forward to server. break; case "sendchat": if (args.Count < 2) { return; } INetworkManager NetworkManager = IoCManager.Resolve <INetworkManager>(); NetOutgoingMessage message = NetworkManager.CreateMessage(); message.Write((byte)NetMessage.ChatMessage); message.Write((byte)ChatChannel.Player); message.Write(args[1]); NetworkManager.SendMessage(message, NetDeliveryMethod.ReliableUnordered); break; // To debug console scrolling and stuff. case "fill": SFML.Graphics.Color[] colors = { SFML.Graphics.Color.Green, SFML.Graphics.Color.Blue, SFML.Graphics.Color.Red }; Random random = new Random(); for (int x = 0; x < 50; x++) { AddLine("filling...", colors[random.Next(0, colors.Length)]); } break; default: SendServerConsoleCommand(text); //Forward to server. break; } }
/// <summary> /// Processes commands (chat messages starting with /) /// </summary> /// <param name="text">input text</param> private void ProcessCommand(string text) { //Commands are processed locally and then sent to the server to be processed there again. var args = new List<string>(); CommandParsing.ParseArguments(text, args); string command = args[0]; //Entity player; //var entMgr = IoCManager.Resolve<IEntityManager>(); //var plrMgr = IoCManager.Resolve<IPlayerManager>(); //player = plrMgr.ControlledEntity; //IoCManager.Resolve<INetworkManager>(). switch (command) { case "cls": lines.Clear(); components.Clear(); last_y = 0; //this.scrollbarH.Value = 0; this.scrollbarV.Value = 0; break; case "quit": Environment.Exit(0); break; case "addparticles": //This is only clientside. if (args.Count >= 3) { Entity target = null; if (args[1].ToLowerInvariant() == "player") { var plrMgr = IoCManager.Resolve<IPlayerManager>(); if (plrMgr != null) if (plrMgr.ControlledEntity != null) target = plrMgr.ControlledEntity; } else { var entMgr = IoCManager.Resolve<IEntityManagerContainer>(); if (entMgr != null) { int entUid = int.Parse(args[1]); target = entMgr.EntityManager.GetEntity(entUid); } } if (target != null) { if (!target.HasComponent(ComponentFamily.Particles)) { var entMgr = IoCManager.Resolve<IEntityManagerContainer>(); var compo = (IParticleSystemComponent)entMgr.EntityManager.ComponentFactory.GetComponent("ParticleSystemComponent"); target.AddComponent(ComponentFamily.Particles, compo); } else { var entMgr = IoCManager.Resolve<IEntityManagerContainer>(); var compo = (IParticleSystemComponent)entMgr.EntityManager.ComponentFactory.GetComponent("ParticleSystemComponent"); target.AddComponent(ComponentFamily.Particles, compo); } } } SendServerConsoleCommand(text); //Forward to server. break; case "removeparticles": if (args.Count >= 3) { Entity target = null; if (args[1].ToLowerInvariant() == "player") { var plrMgr = IoCManager.Resolve<IPlayerManager>(); if (plrMgr != null) if (plrMgr.ControlledEntity != null) target = plrMgr.ControlledEntity; } else { var entMgr = IoCManager.Resolve<IEntityManagerContainer>(); if (entMgr != null) { int entUid = int.Parse(args[1]); target = entMgr.EntityManager.GetEntity(entUid); } } if (target != null) { if (target.HasComponent(ComponentFamily.Particles)) { IParticleSystemComponent compo = (IParticleSystemComponent)target.GetComponent(ComponentFamily.Particles); compo.RemoveParticleSystem(args[2]); } } } SendServerConsoleCommand(text); //Forward to server. break; default: SendServerConsoleCommand(text); //Forward to server. break; } }
public void ProcessCommand(string text, NetConnection sender) { var args = new List <string>(); CommandParsing.ParseArguments(text, args); string command = args[0]; Vector2 position; Entity player; var playerMgr = IoCManager.Resolve <IPlayerManager>(); player = playerMgr.GetSessionByConnection(sender).attachedEntity; var map = IoCManager.Resolve <IMapManager>(); switch (command) { case "addparticles": if (args.Count >= 3) { var _serverMain = IoCManager.Resolve <ISS14Server>(); Entity target = null; if (args[1].ToLowerInvariant() == "player") { target = player; } else { int entUid = int.Parse(args[1]); target = _serverMain.EntityManager.GetEntity(entUid); } if (target != null) { if (target.HasComponent(ComponentFamily.Particles)) { IParticleSystemComponent compo = (IParticleSystemComponent)target.GetComponent(ComponentFamily.Particles); compo.AddParticleSystem(args[2], true); } else { var compo = (IParticleSystemComponent)_serverMain.EntityManager.ComponentFactory.GetComponent("ParticleSystemComponent"); target.AddComponent(ComponentFamily.Particles, compo); compo.AddParticleSystem(args[2], true); //Can't find a way to add clientside compo from here. } } } break; case "removeparticles": if (args.Count >= 3) { var _serverMain = IoCManager.Resolve <ISS14Server>(); Entity target = null; if (args[1].ToLowerInvariant() == "player") { target = player; } else { int entUid = int.Parse(args[1]); target = _serverMain.EntityManager.GetEntity(entUid); } if (target != null) { if (target.HasComponent(ComponentFamily.Particles)) { IParticleSystemComponent compo = (IParticleSystemComponent)target.GetComponent(ComponentFamily.Particles); compo.RemoveParticleSystem(args[2]); } } } break; //case "addgas": // if (args.Count > 1 && Convert.ToDouble(args[1]) > 0) // { // if (player != null) // { // double amount = Convert.ToDouble(args[1]); // var t = // map.GetFloorAt( // player.GetComponent<ITransformComponent>(ComponentFamily.Transform).Position) as // Tile; // if (t != null) // t.GasCell.AddGas((float) amount, GasType.Toxin); // SendConsoleReply(amount.ToString() + " Gas added.", sender); // } // } // break; //case "heatgas": // if (args.Count > 1 && Convert.ToDouble(args[1]) > 0) // { // if (player != null) // { // double amount = Convert.ToDouble(args[1]); // var t = // map.GetFloorAt( // player.GetComponent<ITransformComponent>(ComponentFamily.Transform).Position) as // Tile; // if (t != null) // t.GasCell.AddGas((float) amount, GasType.Toxin); // SendConsoleReply(amount.ToString() + " Gas added.", sender); // } // } // break; //case "atmosreport": // IoCManager.Resolve<IAtmosManager>().TotalAtmosReport(); // break; //case "tpvreport": // Reports on temp / pressure // if (player != null) // { // var ti = // (Tile) // map.GetFloorAt(player.GetComponent<ITransformComponent>(ComponentFamily.Transform).Position); // if (ti == null) // break; // GasCell ce = ti.gasCell; // SendConsoleReply("T/P/V: " + ce.GasMixture.Temperature.ToString() + " / " + ce.GasMixture.Pressure.ToString() + " / " + ce.GasVelocity.ToString(), sender); // //var chatMgr = IoCManager.Resolve<IChatManager>(); // //chatMgr.SendChatMessage(ChatChannel.Default, // // "T/P/V: " + ce.GasMixture.Temperature.ToString() + " / " + // // ce.GasMixture.Pressure.ToString() + " / " + ce.GasVelocity.ToString(), // // "TempCheck", // // 0); // } // break; //case "gasreport": // if (player != null) // { // var tile = map.GetFloorAt(player.GetComponent<ITransformComponent>(ComponentFamily.Transform).Position) as Tile; // if (tile == null) // break; // GasCell c = tile.gasCell; // for (int i = 0; i < c.GasMixture.gasses.Length; i++) // { // SendConsoleReply(((GasType) i).ToString() + ": " +c.GasMixture.gasses[i].ToString(CultureInfo.InvariantCulture) + " m", sender); // //var chatMgr = IoCManager.Resolve<IChatManager>(); // //chatMgr.SendChatMessage(ChatChannel.Default, // // ((GasType) i).ToString() + ": " + // // c.GasMixture.gasses[i].ToString(CultureInfo.InvariantCulture) + " m", // // "GasReport", 0); // } // } // break; case "everyonesondrugs": foreach (IPlayerSession playerfordrugs in IoCManager.Resolve <IPlayerManager>().GetAllPlayers()) { playerfordrugs.AddPostProcessingEffect(PostProcessingEffectType.Acid, 60); SendConsoleReply("Okay then.", sender); } break; default: string message = "Command '" + command + "' not recognized."; SendConsoleReply(message, sender); break; } }