public static GameObject[] ResolveTargets(GameObject source, IEnumerable<string> TargetIds, GameObjectCollection parent, GameConsole console, bool DeepProcess) { // If it passed, find all targets and activate them List<GameObject> foundTargets = new List<GameObject>(5); foreach (var item in parent) { if (item.Value != source && TargetIds.Contains(item.Value.GetSetting("id"))) foundTargets.Add(item.Value); } // Process all known collections if (DeepProcess) { for (int i = 0; i < console.LayeredTextSurface.LayerCount; i++) { var objects = console.GetObjectCollection(i); if (objects != parent) { foreach (var item in objects) { if (item.Value != source && TargetIds.Contains(item.Value.GetSetting("id"))) foundTargets.Add(item.Value); } } } } return foundTargets.ToArray(); }
public void Awake() { if (_instance != null && _instance != this) { Destroy(gameObject); } else { _instance = this; Application.logMessageReceived += LogMessageReceived; } }
protected override void Awake() { if (_instance == null) _instance = this; else { DestroyImmediate(this); return; } DontDestroyOnLoad(gameObject); base.Awake(); _rect = new Rect(10, Screen.height - 170, Screen.width / 2, 160); }
public void Triggered(GameObject source, GameConsole console) { GameObjectCollection parent = null; Parent.TryGetTarget(out parent); ResolvedTargets = GameObjectParser.ResolveTargets(this, TargetIds, parent, console, DeepProcess); for (int i = 0; i < ResolvedTargets.Length; i++) { if (ResolvedTargets[i] is ITarget) ((ITarget)ResolvedTargets[i]).Triggered(this, console); } }
public override void Process(GameConsole console) { // Check for condition pass if (Condition(this, console)) { GameObjectCollection parent = null; Parent.TryGetTarget(out parent); ResolvedTargets = GameObjectParser.ResolveTargets(this, TargetIds, parent, console, DeepProcess); //Result(this, parent, console); for (int i = 0; i < ResolvedTargets.Length; i++) { if (ResolvedTargets[i] is ITarget) ((ITarget)ResolvedTargets[i]).Triggered(this, console); } } }
static void Main() { int mode; do { gc = new GameConsole(); do { //choose game mode mode = ChooseMode(); switch (mode) { case 1://one player Console.Clear(); gc.Write("Please get a piece of paper and draw a grid that has " + SeaConstants.SEA_SIZE + " columns that each have " + SeaConstants.SEA_SIZE + @" rows. Number your columns and rows from 0 to " + (SeaConstants.SEA_SIZE - 1) + @". Then, place " + ShipConstants.TOTAL_BATTLESHIPS + " battleship(s) which are " + ShipConstants.BATTLESHIP_LENGTH + @" block(s) long. And then, place " + ShipConstants.TOTAL_CRUISERS + " cruiser(s) which are " + ShipConstants.CRUISER_LENGTH + @" block(s) long. And then, place " + ShipConstants.TOTAL_SUBMARINES + " submarine(s) which are " + ShipConstants.SUBMARINE_LENGTH + @" block(s) long. And then, place " + ShipConstants.TOTAL_ROWING_BOATS + " rowing boats(s) which are " + ShipConstants.ROWING_BOAT_LENGTH + @" block(s) long. When you are done, press enter to continue.."); Console.ReadLine(); OnePlayer(); break; case 2://two player Console.Clear(); TwoPlayer(); break; default: break; } } while (mode != 1 && mode != 2); } while (gc.PlayAgain()); //Console.ReadLine(); }
public XBoxBuilder() { this.console = new GameConsole(); }
public GameConsolePacMan() { this.console = null; }
private void Awake() { GameConsole.Log("awake"); _Connection = new SocketConnection(IP, Port, this); GameConsole.Log("awake2"); }
private void SetupGameConsole() { #if WINDOWS GameConsole.Initialize(this, "DiagnosticFont", Color.White, Color.Black, 0.5f, 15); IGameConsole console = (IGameConsole)Services.GetService(typeof(IGameConsole)); console.LoadStuff(); console.Log("Type '?' for help"); console.BindCommandHandler("?", delegate(GameTime time, string[] args) { console.Log("Commands"); console.Log("--------"); //console.Log("PrintArgs [arg1] [arg2] [arg3] ... - Prints the list of arguments passed to it, one per line"); //console.Log("PrintLine [text] - Prints the specified text to the console"); //console.Log("SetDefaultLogLevel [level] - Sets the default log level to the specified level"); //console.Log("SetEchoLogLevel [level] - Sets the log level for echoed output from user input"); //console.Log("SetLogLevelThreshold [threshold] - Sets the log level threshold to the specified threshold value"); //console.Log("SetDisplayLevelThreshold [threshold] - Sets the display level threshold to the specified threshold value"); //console.Log("ToggleEchoEnabled - Toggles the auto input echo feature"); //console.Log("ToggleTimestamp - Toggles the display of each message's timestamp"); //console.Log("ToggleLogLevel - Toggles the display of each message's log level"); //console.Log("SetTextColor [r] [g] [b] - Sets the default text color of console text, where r, g, and b are in the range 0-255"); //console.Log("SetLogLevelColor [level] [r] [g] [b] - Sets the text color for the specified log level, where r, g and b are in the range 0-255"); console.Log("SetGameBackgroundColor [r] [g] [b] - Sets the game back color, where r, g and b are in the range 0-255"); console.Log("SceneStats - Displays the stats of the currently active scene"); }); console.BindCommandHandler("PrintArgs", delegate(GameTime time, string[] args) { foreach (string arg in args) { console.Log(arg); } }, ' '); console.BindCommandHandler("SceneStats", delegate(GameTime time, string[] args) { string _str = ""; _str = "Scene Items Count : " + SceneManager.ActiveScene.SceneItems.Count.ToString(); console.Log(_str); }, ' '); console.BindCommandHandler("SetGameBackgroundColor", delegate(GameTime time, string[] args) { if (args.Length < 3) { return; } try { byte r = byte.Parse(args[0]); byte g = byte.Parse(args[1]); byte b = byte.Parse(args[2]); console.TextColor = new Color(r, g, b, 255); } catch { } }, ' '); console.BindCommandHandler("PrintLine", delegate(GameTime time, string[] args) { if (args.Length == 0) { return; } console.Log(args[0]); }); console.BindCommandHandler("SetDefaultLogLevel", delegate(GameTime time, string[] args) { if (args.Length == 0) { return; } try { console.DefaultLogLevel = uint.Parse(args[0]); } catch { } }, ' '); console.BindCommandHandler("SetEchoLogLevel", delegate(GameTime time, string[] args) { if (args.Length == 0) { return; } try { console.EchoLogLevel = uint.Parse(args[0]); } catch { } }, ' '); console.BindCommandHandler("SetLogLevelThreshold", delegate(GameTime time, string[] args) { if (args.Length == 0) { return; } try { console.LogLevelThreshold = int.Parse(args[0]); } catch { } }, ' '); console.BindCommandHandler("SetDisplayLevelThreshold", delegate(GameTime time, string[] args) { if (args.Length == 0) { return; } try { console.DisplayLevelThreshold = int.Parse(args[0]); } catch { } }, ' '); console.BindCommandHandler("ToggleEchoEnabled", delegate(GameTime time, string[] args) { console.EchoEnabled = !console.EchoEnabled; }); console.BindCommandHandler("ToggleTimestamp", delegate(GameTime time, string[] args) { if ((console.DisplayOptions & ConsoleDisplayOptions.TimeStamp) == ConsoleDisplayOptions.TimeStamp) { console.DisplayOptions &= ~ConsoleDisplayOptions.TimeStamp; } else { console.DisplayOptions |= ConsoleDisplayOptions.TimeStamp; } }); console.BindCommandHandler("ToggleLogLevel", delegate(GameTime time, string[] args) { if ((console.DisplayOptions & ConsoleDisplayOptions.LogLevel) == ConsoleDisplayOptions.LogLevel) { console.DisplayOptions &= ~ConsoleDisplayOptions.LogLevel; } else { console.DisplayOptions |= ConsoleDisplayOptions.LogLevel; } }); console.BindCommandHandler("SetTextColor", delegate(GameTime time, string[] args) { if (args.Length < 3) { return; } try { byte r = byte.Parse(args[0]); byte g = byte.Parse(args[1]); byte b = byte.Parse(args[2]); console.TextColor = new Color(r, g, b, 255); } catch { } }, ' '); console.BindCommandHandler("SetLogLevelColor", delegate(GameTime time, string[] args) { if (args.Length < 4) { return; } try { uint level = uint.Parse(args[0]); byte r = byte.Parse(args[1]); byte g = byte.Parse(args[2]); byte b = byte.Parse(args[3]); console.SetLogLevelCustomColor(level, new Color(r, g, b, 255)); } catch { } }, ' '); #endif }
public GameConsoleLanko() { this.console = null; }
public GameConsoleGhost() { this.console = null; }
public void Save(string file) { GameConsole tempConsole = new GameConsole(_consoleLayers.Layers, _consoleLayers.Width, _consoleLayers.Height); for (int i = 0; i < _consoleLayers.Layers; i++) tempConsole.RemoveLayer(0); for (int i = 0; i < _consoleLayers.Layers; i++) { tempConsole.AddLayer(_consoleLayers[i].CellData); var metadataNew = new GameConsoleMetadata(); var metadataOld = _consoleLayers.GetLayerMetadata(i); metadataNew.IsMoveable = metadataOld.IsMoveable; metadataNew.IsRemoveable = metadataOld.IsRemoveable; metadataNew.IsRenamable = metadataOld.IsRenamable; metadataNew.IsVisible = metadataOld.IsVisible; metadataNew.Name = metadataOld.Name; metadataNew.Index = metadataOld.Index; metadataNew.GameObjects = GameObjects[i]; tempConsole.SetLayerMetadata(i, metadataNew); } SadConsole.Serializer.Save<GameConsole>(tempConsole, file); //tempConsole.Save(file); //_consoleLayers.Save(file); //GameObjectCollection.SaveCollection(GameObjects, file.Replace(System.IO.Path.GetExtension(file), ".objects")); }
public virtual void Loaded(GameConsole console) { }
public GameConsolePacMan(GameConsole console) { this.console = console; }
protected override void Update(GameTime gameTime) { Window.Title = $"ctrviewer [{Math.Round(1000.0f / gameTime.ElapsedGameTime.TotalMilliseconds)} FPS]"; //if (loading == null) // LoadGame(); //x += 0.01f ; //if (x > Math.PI * 2) // x = 0; //camera.SetRotation(x, y); //Console.WriteLine(x); oldgs = newgs; oldkb = newkb; oldms = newms; newms = Mouse.GetState(); newgs = GamePad.GetState(activeGamePad); newkb = Keyboard.GetState(); if (IsActive) { newmenu.Update(gameTime, new Point(newms.X, newms.Y)); foreach (Kart k in karts) { k.Update(gameTime); } if (newgs.Buttons.Start == ButtonState.Pressed && newgs.Buttons.Back == ButtonState.Pressed) { Exit(); } if (eng.Settings.StereoPair) { if (newgs.IsButtonDown(Buttons.RightShoulder)) { eng.Settings.StereoPairSeparation += 5; } if (newgs.IsButtonDown(Buttons.LeftShoulder)) { eng.Settings.StereoPairSeparation -= 5; } if (eng.Settings.StereoPairSeparation < 0) { eng.Settings.StereoPairSeparation = 0; } if (newgs.IsButtonDown(Buttons.RightShoulder) && newgs.IsButtonDown(Buttons.LeftShoulder)) { eng.Settings.StereoPairSeparation = 130; } } if ((newkb.IsKeyDown(Keys.Enter) && newkb.IsKeyDown(Keys.RightAlt)) && !(oldkb.IsKeyDown(Keys.Enter) && newkb.IsKeyDown(Keys.RightAlt))) { eng.Settings.Windowed = !eng.Settings.Windowed; } if ( (newkb.IsKeyDown(Keys.OemTilde) && !oldkb.IsKeyDown(Keys.OemTilde)) || (newgs.IsButtonDown(Buttons.Back) && !oldgs.IsButtonDown(Buttons.Back)) ) { eng.Settings.ShowConsole = !eng.Settings.ShowConsole; } if (newkb.IsKeyDown(Keys.OemMinus)) { eng.Settings.FieldOfView--; } if (newkb.IsKeyDown(Keys.OemPlus)) { eng.Settings.FieldOfView++; } if ((newgs.Buttons.Start == ButtonState.Pressed && oldgs.Buttons.Start != newgs.Buttons.Start) || (newkb.IsKeyDown(Keys.Escape) && newkb.IsKeyDown(Keys.Escape) != oldkb.IsKeyDown(Keys.Escape))) { menu.Visible = !menu.Visible; } if (menu.Visible) { menu.Update(oldgs, newgs, oldkb, newkb); //currentflag = menu.items.Find(x => x.Title == "current flag: {0}").rangeval; if (menu.Exec) { switch (menu.SelectedItem.Action) { case "close": menu.Visible = false; break; //case "load": // LoadGame(); // InMenu = false; // break; case "loadbig": LoadLevelsFromBig(menu.SelectedItem.Value); //, 0, 2); break; case "loadbigadv": LoadLevelsFromBig(200, 203, 206, 209, 212); break; case "tod_day": SetTimeOfDay(PreferredTimeOfDay.Day); break; case "tod_evening": SetTimeOfDay(PreferredTimeOfDay.Evening); break; case "tod_night": SetTimeOfDay(PreferredTimeOfDay.Night); break; case "link": menu.SetMenu(font); break; case "setleveltype": levelType = (LevelType)menu.SelectedItem.Value; break; case "toggle": switch (menu.SelectedItem.Param) { case "inst": eng.Settings.ShowModels = !eng.Settings.ShowModels; break; case "paths": eng.Settings.ShowBotsPath = !eng.Settings.ShowBotsPath; break; case "lod": eng.Settings.UseLowLod = !eng.Settings.UseLowLod; break; case "antialias": eng.Settings.AntiAlias = !eng.Settings.AntiAlias; break; case "invis": HideInvisible = !HideInvisible; break; case "water": HideWater = !HideWater; break; case "console": eng.Settings.ShowConsole = !eng.Settings.ShowConsole; break; case "campos": eng.Settings.ShowCamPos = !eng.Settings.ShowCamPos; break; case "visbox": eng.Settings.VisData = !eng.Settings.VisData; break; case "nocull": ForceNoCulling = !ForceNoCulling; break; case "visboxleaf": eng.Settings.VisDataLeaves = !eng.Settings.VisDataLeaves; break; case "filter": Samplers.EnableFiltering = !Samplers.EnableFiltering; Samplers.Refresh(); break; case "wire": Samplers.EnableWireframe = !Samplers.EnableWireframe; break; case "genmips": eng.Settings.GenerateMips = !eng.Settings.GenerateMips; break; case "window": eng.Settings.Windowed = !eng.Settings.Windowed; break; case "vcolor": eng.Settings.VertexLighting = !eng.Settings.VertexLighting; break; case "stereo": eng.Settings.StereoPair = !eng.Settings.StereoPair; break; case "sky": eng.Settings.ShowSky = !eng.Settings.ShowSky; break; case "vsync": eng.Settings.VerticalSync = !eng.Settings.VerticalSync; break; default: GameConsole.Write("unimplemented toggle: " + menu.SelectedItem.Param); break; } break; case "exit": Exit(); break; } menu.Exec = !menu.Exec; } if ((newgs.Buttons.B == ButtonState.Pressed && newgs.Buttons.B != oldgs.Buttons.B) || (newgs.Buttons.Y == ButtonState.Pressed && newgs.Buttons.Y != oldgs.Buttons.Y)) { bool togglemenu = true; foreach (MenuItem m in menu.items) { if (m.Action == "link" && m.Title == "BACK") { menu.SetMenu(font, m.Param); togglemenu = false; } } if (togglemenu) { menu.Visible = !menu.Visible; } } } else { foreach (var mg in eng.MeshHigh) { mg.Update(gameTime); } foreach (var mg in eng.MeshLow) { mg.Update(gameTime); } foreach (var im in eng.instanced) { im.Update(gameTime); } foreach (var im in eng.paths) { im.Update(gameTime); } if (ControlsEnabled) { UpdateCameras(gameTime); } } } base.Update(gameTime); }
public void Triggered(GameObject source, GameConsole console) { System.Diagnostics.Debugger.Break(); }
private void LoadLevel() { GameConsole.Write("LoadLevel()"); RenderEnabled = false; //wait for the end of frame, in case we are still rendering. while (IsDrawing) { } ; //Dispose(); eng.Clear(); //making sure we have default stuff loaded. maybe should just allocate statically? LoadCones(); LoadGenericTextures(); TestLoadKart(); TestLoadExtrenalModels(); Stopwatch sw = new Stopwatch(); sw.Start(); GameConsole.Write("scenes parsed at: " + sw.Elapsed.TotalSeconds); //loading textures between scenes and conversion to monogame for alpha textures info LoadTextures(); GameConsole.Write("textures extracted at: " + sw.Elapsed.TotalSeconds); foreach (Scene s in Scenes) { eng.MeshHigh.Add(CrashTeamRacingLoader.FromScene(s, Detail.Med)); eng.MeshLow.Add(CrashTeamRacingLoader.FromScene(s, Detail.Low)); } GameConsole.Write("converted scenes to monogame render at: " + sw.Elapsed.TotalSeconds); //force 1st scene sky and back color if (Scenes.Count > 0) { eng.BackgroundColor = DataConverter.ToColor(Scenes[0].header.backColor); if (Scenes[0].skybox != null) { eng.sky = new MGLevel(Scenes[0].skybox); } } foreach (Scene s in Scenes) { if (s.unkadv != null) { foreach (var pa in s.unkadv.smth) { eng.instanced.Add(new InstancedModel("limecone", DataConverter.ToVector3(pa.Position, 0.01f), Vector3.Zero, new Vector3(0.03f))); } } if (s.header.ptru2 != 0) { foreach (var v in s.posu2) { eng.instanced.Add(new InstancedModel("goldcone", DataConverter.ToVector3(v, 0.01f), Vector3.Zero, new Vector3(0.03f))); } } if (s.header.ptrTrialData != UIntPtr.Zero) { foreach (var v in s.posu1) { eng.instanced.Add(new InstancedModel("browncone", DataConverter.ToVector3(v.Position, 0.01f), Vector3.Zero, new Vector3(0.03f))); } } } foreach (var scene in Scenes) { foreach (var model in scene.Models) { ContentVault.AddModel(model.Name, DataConverter.ToTriList(model)); } } foreach (Scene s in Scenes) { foreach (var pa in s.header.startGrid) { eng.instanced.Add(new InstancedModel("purplecone", DataConverter.ToVector3(pa.Position), Vector3.Zero, new Vector3(0.03f))); } foreach (var ph in s.pickups) { eng.instanced.Add(new InstancedModel( ph.ModelName, DataConverter.ToVector3(ph.Pose.Position), new Vector3( (float)(ph.Pose.Rotation.Y * Math.PI * 2f), (float)(ph.Pose.Rotation.X * Math.PI * 2f), (float)(ph.Pose.Rotation.Z * Math.PI * 2f) ), new Vector3(ph.Scale.Y, ph.Scale.X, ph.Scale.Z) )); } foreach (var n in s.restartPts) { eng.paths.Add(new InstancedModel("cyancone", DataConverter.ToVector3(n.Position), Vector3.Zero, new Vector3(0.03f))); } if (s.nav.paths.Count == 3) { foreach (NavFrame n in s.nav.paths[0].frames) { eng.paths.Add(new InstancedModel("greencone", DataConverter.ToVector3(n.position, 0.01f), Vector3.Zero, new Vector3(0.03f))); } foreach (NavFrame n in s.nav.paths[1].frames) { eng.paths.Add(new InstancedModel("yellowcone", DataConverter.ToVector3(n.position, 0.01f), Vector3.Zero, new Vector3(0.03f))); } foreach (NavFrame n in s.nav.paths[2].frames) { eng.paths.Add(new InstancedModel("redcone", DataConverter.ToVector3(n.position, 0.01f), Vector3.Zero, new Vector3(0.03f))); } } } GameConsole.Write("extracted dynamics an bsp at: " + sw.Elapsed.TotalSeconds); foreach (Scene s in Scenes) { if (s.visdata.Count > 0) { BspPopulate(s.visdata[0], s, 0); } GameConsole.Write(s.Info()); } sw.Stop(); GameConsole.Write("level done: " + sw.Elapsed.TotalSeconds); UpdateEffects(); RenderEnabled = true; }
protected override void Draw(GameTime gameTime) { //remember we're busy drawing stuff IsDrawing = true; GraphicsDevice.Clear(eng.BackgroundColor); spriteBatch.Begin(); if (eng.Settings.StereoPair) { graphics.GraphicsDevice.Viewport = vpLeft; eng.UpdateProjectionMatrices(); DrawLevel(eng.Cameras[CameraType.LeftEyeCamera]); graphics.GraphicsDevice.Viewport = vpRight; eng.UpdateProjectionMatrices(); DrawLevel(eng.Cameras[CameraType.RightEyeCamera]); graphics.GraphicsDevice.Viewport = vpFull; eng.UpdateProjectionMatrices(); } else { DrawLevel(); } menu.Draw(GraphicsDevice, spriteBatch, font, tint); if (IsLoading) { spriteBatch.DrawString(font, "LOADING...", new Vector2(graphics.PreferredBackBufferWidth / 2 - (font.MeasureString("LOADING...").X / 2), graphics.PreferredBackBufferHeight / 2), Color.Yellow); } if (Scenes.Count == 0 && !IsLoading) { spriteBatch.DrawString(font, "Crash Team Racing level viewer\r\n\r\n" + "No levels loaded.\r\n" + "Put LEV/VRM files in levels folder,\r\n" + "or put BIGFILE.BIG in root folder,\r\n" + "or insert/mount CTR CD and use load level menu.", new Vector2(20 * graphics.GraphicsDevice.Viewport.Height / 1080f, 20 * graphics.GraphicsDevice.Viewport.Height / 1080f), Color.Yellow, 0, Vector2.Zero, graphics.GraphicsDevice.Viewport.Height / 1080f, SpriteEffects.None, 0.5f); } //spriteBatch.DrawString(font, $"{newms.ToString()}", new Vector2(graphics.PreferredBackBufferWidth / 2 - (font.MeasureString($"{newms.ToString()}").X / 2), graphics.PreferredBackBufferHeight / 2), Color.Yellow); if (Keyboard.GetState().IsKeyDown(Keys.OemMinus) || Keyboard.GetState().IsKeyDown(Keys.OemPlus)) { spriteBatch.DrawString(font, String.Format("FOV {0}", eng.Cameras[CameraType.DefaultCamera].ViewAngle.ToString("0.##")), new Vector2(graphics.PreferredBackBufferWidth - font.MeasureString(String.Format("FOV {0}", eng.Cameras[CameraType.DefaultCamera].ViewAngle.ToString("0.##"))).X - 20, 20), Color.Yellow); } if (GamePad.GetState(0).Triggers.Left > 0 || GamePad.GetState(0).Triggers.Right > 0) { spriteBatch.DrawString( font, $"Speed scale: {eng.Cameras[CameraType.DefaultCamera].speedScale.ToString("0.##")}", new Vector2(graphics.PreferredBackBufferWidth - font.MeasureString($"Speed scale: {eng.Cameras[CameraType.DefaultCamera].speedScale.ToString("0.##")}").X - 20, 20), Color.Yellow); } if (eng.Settings.ShowCamPos) { spriteBatch.DrawString(font, $"({eng.Cameras[CameraType.DefaultCamera].Position.X.ToString("0.00")}, {eng.Cameras[CameraType.DefaultCamera].Position.Y.ToString("0.00")}, {eng.Cameras[CameraType.DefaultCamera].Position.Z.ToString("0.00")})", new Vector2(20, 20), Color.Yellow, 0, Vector2.Zero, graphics.GraphicsDevice.Viewport.Height / 1080f, SpriteEffects.None, 0.5f); } //spriteBatch.DrawString(font, String.Format("sp: {0}\r\nac:{1}", karts[0].Speed, karts[0].Accel), new Vector2(20, 20), Color.Yellow); if (eng.Settings.ShowConsole) { GameConsole.Draw(graphics.GraphicsDevice, spriteBatch); } newmenu.Draw(gameTime, spriteBatch); spriteBatch.End(); //reset depth state to default cause spritebatch uses none GraphicsDevice.DepthStencilState = DepthStencilState.Default; // base.Draw(gameTime); IsDrawing = false; }
public GameConsoleGhost(GameConsole console) { this.console = console; }
public override void ExecuteCommand(EvtChatCommandArgs args) { List <string> arguments = args.Command.ArgumentsAsList; if (arguments.Count < 2) { QueueMessage(UsageMessage); return; } string macroName = arguments[0].ToLowerInvariant(); //Make sure the first argument has at least a minimum number of characters if (macroName.Length < MIN_MACRO_NAME_LENGTH) { QueueMessage($"Input macros need to be at least {MIN_MACRO_NAME_LENGTH} characters long."); return; } if (macroName.StartsWith(Parser.DEFAULT_PARSER_REGEX_MACRO_INPUT) == false) { QueueMessage($"Input macros must start with \"{Parser.DEFAULT_PARSER_REGEX_MACRO_INPUT}\"."); return; } //For simplicity with wait inputs, force the first character in the macro name to be alphanumeric if (char.IsLetterOrDigit(arguments[0][1]) == false) { QueueMessage("The first character in input macro names must be alphanumeric."); return; } //Check for max macro name if (macroName.Length > MAX_MACRO_NAME_LENGTH) { QueueMessage($"Input macros may have up to a max of {MAX_MACRO_NAME_LENGTH} characters in their name."); return; } int curConsoleID = (int)DataHelper.GetSettingInt(SettingsConstants.LAST_CONSOLE, 1L); GameConsole consoleInstance = null; using (BotDBContext context = DatabaseManager.OpenContext()) { GameConsole curConsole = context.Consoles.FirstOrDefault(c => c.ID == curConsoleID); if (curConsole == null) { QueueMessage("Cannot validate input macro, as the current console is invalid. Fix this by setting another console."); return; } consoleInstance = new GameConsole(curConsole.Name, curConsole.InputList); } Parser parser = new Parser(); //Trim the macro name from the input sequence string macroVal = args.Command.ArgumentsAsString.Remove(0, macroName.Length + 1).ToLowerInvariant(); //Console.WriteLine(macroVal); bool isDynamic = false; //Check for a dynamic macro int openParenIndex = macroName.IndexOf('(', 0); if (openParenIndex >= 0) { //If we found the open parenthesis, check for the asterisk //This is not comprehensive, but it should smooth out a few issues if (openParenIndex == (macroName.Length - 1) || macroName[openParenIndex + 1] != '*') { QueueMessage("Invalid input macro. Dynamic macro arguments must be specified with \"*\"."); return; } if (macroName[macroName.Length - 1] != ')') { QueueMessage("Invalid input macro. Dynamic macros must end with \")\"."); return; } isDynamic = true; } //Validate input if not dynamic if (isDynamic == false) { ParsedInputSequence inputSequence = default; try { string userName = args.Command.ChatMessage.Username; //Get default and max input durations //Use user overrides if they exist, otherwise use the global values int defaultDur = (int)DataHelper.GetUserOrGlobalDefaultInputDur(userName); int maxDur = (int)DataHelper.GetUserOrGlobalMaxInputDur(userName); string regexStr = consoleInstance.InputRegex; string readyMessage = string.Empty; using (BotDBContext context = DatabaseManager.OpenContext()) { IQueryable <InputSynonym> synonyms = context.InputSynonyms.Where(syn => syn.ConsoleID == curConsoleID); readyMessage = parser.PrepParse(macroVal, context.Macros, synonyms); } inputSequence = parser.ParseInputs(readyMessage, regexStr, new ParserOptions(0, defaultDur, true, maxDur)); TRBotLogger.Logger.Debug(inputSequence.ToString()); if (inputSequence.ParsedInputResult != ParsedInputResults.Valid) { if (string.IsNullOrEmpty(inputSequence.Error) == true) { QueueMessage("Invalid input macro."); } else { QueueMessage($"Invalid input macro: {inputSequence.Error}"); } return; } } catch (Exception e) { QueueMessage($"Invalid input macro: {e.Message}"); return; } } string message = string.Empty; using (BotDBContext context = DatabaseManager.OpenContext()) { InputMacro inputMacro = context.Macros.FirstOrDefault(m => m.MacroName == macroName); //Not an existing macro, so add it if (inputMacro == null) { InputMacro newMacro = new InputMacro(macroName, macroVal); context.Macros.Add(newMacro); if (isDynamic == false) { message = $"Added input macro \"{macroName}\"!"; } else { message = $"Added dynamic input macro \"{macroName}\"! Dynamic input macros can't be validated beforehand, so verify it works manually."; } } //Update the macro value else { inputMacro.MacroValue = macroVal; if (isDynamic == false) { message = $"Updated input macro \"{macroName}\"!"; } else { message = $"Updated dynamic input macro \"{macroName}\"! Dynamic input macros can't be validated beforehand, so verify it works manually."; } } context.SaveChanges(); } QueueMessage(message); }
private static void InitializeConsole() { // Set up font using (MemoryStream ms = new MemoryStream(FontResources.ConsoleFont)) { MBackend.FontStorage.LoadStream(ms, "console"); } MBackend.console = new GameConsole(new Rectangle(0, 0, GraphicsManager.ScreenSize.X, GraphicsManager.ScreenSize.Y / 3), MBackend.GraphicsManager.GetGraphicsDevice(), MBackend.keyboard, MBackend.TextureStorage.White); // TODO: Break out magic numbers into config file. MBackend.Console.ToggleKey = Microsoft.Xna.Framework.Input.Keys.F1; MBackend.Console.CommandBroker.Register("exit", CommandExit); MBackend.Console.CommandBroker.Register("loglevel", 1, MBackend.CommandLogLevel); MBackend.Console.CommandBroker.Register("version", 0, MBackend.CommandVersion); MBackend.Console.TextFont = MBackend.FontStorage.GetAsset("console"); }
public void OnContact(Vector3 contactPoint, float force2, Vector3 normal) { List <int> hitPoints = new List <int>(); Vector3 force = force2 * normal; force = Vector3.Transform(force, _actor.GlobalOrientation); force.X *= 0.5f; //limit sideways crush force.Y *= 0.9f; force *= 0.00000011f * _carFile.CrushSections[1].DamageMultiplier; //scale it down to a managable number float forceSize = force.Length(); //if (forceSize > 0.04f) //{ //force *= 0.04f / forceSize; //cap max force so things dont get loco //} if (forceSize < 0.004f) { return; } Vector3 force3 = force; force.X = Math.Abs(force.X); force.Y = Math.Abs(force.Y); force.Z = Math.Abs(force.Z); if (float.IsNaN(Vector3.Normalize(force).X)) { return; } int hitpoints = 0; CrushData data = GetClosestCrushData(contactPoint); if (data == null) { return; //no crush data for this car } //foreach (CrushData data in _carFile.CrushSections[1].Data) { Vector3 crushPoint = Vector3.Transform(_localVertices[data.RefVertex].Position, GameVars.ScaleMatrix * _actor.GlobalPose); // if (Vector3.Distance(crushPoint, contactPoint) < 0.5f) { hitPoints.Add(data.RefVertex); hitpoints++; Vector3 curPos = _localVertices[data.RefVertex].Position; Vector3 directedForce = new Vector3(); directedForce.X = curPos.X < 0 ? force.X : -force.X; directedForce.Y = curPos.Y < 0 ? force.Y : -force.Y; directedForce.Z = curPos.Z < 0 ? force.Z : -force.Z; Vector3 parentScale = new Vector3(); parentScale.X = directedForce.X > 0 ? data.LeftScale : data.RightScale; parentScale.Y = directedForce.Y > 0 ? data.BottomScale : data.TopScale; parentScale.Z = directedForce.Z > 0 ? data.FrontScale : data.RearScale; directedForce *= parentScale; Vector3 oldPos = _localVertices[data.RefVertex].Position; curPos = KeepCrushPositionInBounds(curPos + directedForce, data.Box); float distanceMoved = Vector3.Distance(oldPos, curPos); _localVertices[data.RefVertex].Position = curPos; Vector3 parentDir = curPos - oldPos; if (distanceMoved < 0.0002f) { return; } Vector3 normalforce = Vector3.Normalize(force); foreach (CrushPoint point in data.Points) { if (point.VertexIndex < 0) { continue; } if (float.IsNaN(normalforce.X) || float.IsNaN(normalforce.Y) || float.IsNaN(normalforce.Z)) { break; } curPos = _localVertices[point.VertexIndex].Position; //float distanceFromParent = Vector3.Distance(curPos, _localVertices[data.RefVertex].Position); //float originalDistanceFromParent = Vector3.Distance(curPos, _originalPositions[data.RefVertex]); //if (distanceFromParent < originalDistanceFromParent) // return; //directedForce = force * parentScale; Vector3 vdir = _localVertices[data.RefVertex].Position - _localVertices[point.VertexIndex].Position; vdir.Normalize(); Vector3 newpos = _localVertices[point.VertexIndex].Position + (vdir * distanceMoved * parentScale * 2f * (1 - point.DistanceFromParent)); if (point.DistanceFromParent < 0.1f || GameEngine.Random.Next(10) % 2 == 0) { newpos = _localVertices[point.VertexIndex].Position + (parentDir * 0.6f * (1 - point.DistanceFromParent)); } //else //{ //} float dist3 = Vector3.Distance(_originalPositions[point.VertexIndex], newpos); // if were not too far away from orig position and this will move us closer to our parent, move this vert if (dist3 < 0.07f) { _localVertices[point.VertexIndex].Position = newpos; if (_vertexLinks[point.VertexIndex] != null) { foreach (int idx in _vertexLinks[point.VertexIndex]) { _localVertices[idx].Position = newpos; } } } else { //GameConsole.WriteEvent("not moving child"); } //force = normalforce * distanceMoved * MathHelper.Lerp(1f, 0.1f, point.DistanceFromParent); //curPos = _localVertices[point.VertexIndex].Position; //if (Math.Abs(force.Y) < 0.0001f) // force.Y *= (_localVertices[data.RefVertex].Position.Y - curPos.Y) * 1000; //directedForce.X = curPos.X < 0 ? force.X : -force.X; //directedForce.Y = curPos.Y < 0 ? force.Y : -force.Y; //directedForce.Z = curPos.Z < 0 ? force.Z : -force.Z; ////rnd.Y = (_localVertices[data.RefVertex].Position.Y - curPos.Y) * 80; //rnd.Y *= curPos.Y > 0 ? 1 : -1; ////Vector3 forceToUse = directedForce * Vector3.Lerp(Vector3.One, rnd * 1.5f, point.DistanceFromParent); //as we get further away from parent, more random //if (Vector3.Distance(_originalPositions[point.VertexIndex], curPos + directedForce) < 0.04f) // _localVertices[point.VertexIndex].Position = curPos + directedForce; } _changed = true; } } if (_changed) { bool tidied = false; foreach (CrushData data2 in _carFile.CrushSections[1].Data) { Vector3 oldpos = _localVertices[data2.RefVertex].Position; _localVertices[data2.RefVertex].Position = KeepCrushPositionInBounds(_localVertices[data2.RefVertex].Position, data2.Box); if (oldpos != _localVertices[data2.RefVertex].Position) { tidied = true; } } if (tidied) { GameConsole.WriteEvent("tidied up"); } for (int i = 0; i < _localVertices.Length; i++) { if (float.IsNaN(_localVertices[i].Position.X) || float.IsNaN(_localVertices[i].Position.Y) || float.IsNaN(_localVertices[i].Position.Z)) { } } } if (hitpoints > 0) { GameConsole.WriteEvent("f: " + Math.Round(forceSize, 4) + ", pts: " + hitpoints); _lastHitPts = hitPoints; } }
public override void ExecuteCommand(EvtChatCommandArgs args) { List <string> arguments = args.Command.ArgumentsAsList; bool arg1FoundConsole = false; long lastConsole = DataHelper.GetSettingInt(SettingsConstants.LAST_CONSOLE, 1L); StringBuilder strBuilder = null; using (BotDBContext context = DatabaseManager.OpenContext()) { GameConsole console = null; //For no arguments, view all inputs on the current console //For one argument, check if it's a console and view all inputs, and if not, view the input data //For two arguments, view the input data for the given console switch (arguments.Count) { //First find the console case 0: console = context.Consoles.FirstOrDefault(console => console.ID == lastConsole); break; case 1: console = context.Consoles.FirstOrDefault(console => console.Name == arguments[0]); if (console == null) { goto case 0; } //We found the console in the first argument arg1FoundConsole = true; break; case 2: goto case 1; default: QueueMessage(UsageMessage); return; } //Invalid console if (console == null) { QueueMessage("The current console is invalid!? No inputs or input data are available."); return; } //Check for the input data if (arguments.Count == 1 || arguments.Count == 2) { string inputName = arguments[arguments.Count - 1].ToLowerInvariant(); InputData inpData = console.InputList.Find(inp => inp.Name == inputName); if (inpData != null) { QueueMessage(inpData.ToString()); return; } else { //For two arguments, end here since we didn't find an input for this console //For one argument, the value was a console so we should continue to print all the inputs for it //If we didn't find the console in the first argument, that means it's an input and it wasn't found if (arguments.Count == 2 || arg1FoundConsole == false) { QueueMessage($"No input named \"{inputName}\" exists for the {console.Name} console."); return; } } } //No valid inputs if (console.InputList.Count() == 0) { QueueMessage($"Console \"{console.Name}\" has no valid inputs!"); return; } //List all inputs for this console strBuilder = new StringBuilder(300); strBuilder.Append("Valid inputs for "); strBuilder.Append(console.Name).Append(':').Append(' '); foreach (InputData inputData in console.InputList) { strBuilder.Append(inputData.Name); //Note if the input is disabled if (inputData.Enabled == 0) { strBuilder.Append(" (disabled)"); } strBuilder.Append(", "); } } int maxCharCount = (int)DataHelper.GetSettingInt(SettingsConstants.BOT_MSG_CHAR_LIMIT, 500L); strBuilder.Remove(strBuilder.Length - 2, 2); QueueMessageSplit(strBuilder.ToString(), maxCharCount, ", "); }
public PlayStationBuilder() { this.console = new GameConsole(); }
public static void Initialize() { if (General.OrbwalkerOnlyMenuBool.Enabled) { GameConsole.Print( $"<font color = \"#1a8cff\">AIO Version </font><font color = \"#FFFFFF\">{VERSION}</font><font color = \"#99ccff\"> - {Commit} </font><font color = \"#ff1a1a\">(Orbwalker Only)</font>"); return; } try { var name = LocalPlayer.Instance.CharName; // Special Cases // ReSharper disable once SwitchStatementMissingSomeCases switch (name) { case "Leblanc": name = "LeBlanc"; break; } //var path = $"Entropy.AIO.Champions.{name}.{name}"; //var type = Type.GetType(path, true); //Activator.CreateInstance(type); switch (LocalPlayer.Instance.GetChampion()) { case Champion.Ashe: new Ashe(); break; case Champion.Annie: new Annie(); break; case Champion.Xerath: new Xerath(); break; default: Logging.Log($"AIO: {LocalPlayer.Instance.CharName} is not supported.", LogLevels.warning); break; } GameConsole.Print("Template Loaded"); /*GameConsole.Print( * $"<font color = \"#1a8cff\">AIO Version</font> <font color = \"#FFFFFF\">{VERSION}</font><font color = \"#99ccff\"> - {Commit}</font>");*/ } catch (Exception e) { switch (e) { case TargetInvocationException _: Logging.Log($"AIO: Error occurred while trying to load {LocalPlayer.Instance.CharName}.", LogLevels.error); e.ToolKitLog(); break; case TypeLoadException _: Logging.Log($"AIO: {LocalPlayer.Instance.CharName} is not supported.", LogLevels.warning); break; } } }
public virtual void Process(GameConsole console) { }
public override void ExecuteCommand(EvtChatCommandArgs args) { List <string> arguments = args.Command.ArgumentsAsList; //Ignore with incorrect number of arguments if (arguments.Count != 1) { QueueMessage(UsageMessage); return; } string consoleName = arguments[0].ToLowerInvariant(); long curConsoleID = DataHelper.GetSettingInt(SettingsConstants.LAST_CONSOLE, 1L); long removedConsoleID = 0L; bool removed = false; using (BotDBContext context = DatabaseManager.OpenContext()) { GameConsole console = context.Consoles.FirstOrDefault(c => c.Name == consoleName); if (console != null) { removedConsoleID = console.ID; removed = true; context.Consoles.Remove(console); context.SaveChanges(); } } if (removed == true) { QueueMessage($"Successfully removed console \"{consoleName}\"!"); //After removing the console, check if that console was the current one //If so, set the last console ID to the first console in the list if (curConsoleID == removedConsoleID) { using (BotDBContext context = DatabaseManager.OpenContext()) { GameConsole firstConsole = context.Consoles.FirstOrDefault(); if (firstConsole != null) { //Change the setting and save Settings lastConsoleSetting = DataHelper.GetSettingNoOpen(SettingsConstants.LAST_CONSOLE, context); lastConsoleSetting.ValueInt = firstConsole.ID; context.SaveChanges(); QueueMessage($"\"{consoleName}\" used to be the current console, so the current console has been set to \"{firstConsole.Name}\"!"); } else { QueueMessage($"\"{consoleName}\" used to be the current console, but there are no other consoles available. Please add a new console in order to play."); } } } return; } QueueMessage($"No console named \"{consoleName}\" exists."); }
public SegaBuilder() { this.console = new GameConsole(); }
public GameConsoleGlub(GameConsole gameconsole) { this.console = gameconsole; }
public GameConsoleGlub() { this.console = null; }
public GameConsoleLanko(GameConsole gameconsole) { this.console = gameconsole; }
void Start() { Instance = this; Commands = new Dictionary<string, Action<string>>(); HelpText = new Dictionary<string, string>(); RegisterCommand("Help", Help); RegisterCommand("ListShips", ListShips); RegisterCommand("ListPorts", ListPorts); RegisterCommand("ListInventory", ListInventory); RegisterCommand("ModifyStat", ModifyStat); HelpText.Add("Help", "Usage: Help <command>"); HelpText.Add("ListShips", "Usage: ListShips"); HelpText.Add("ListPorts", "Usage: ListPorts"); HelpText.Add("ListInventory", "Usage: ListInventory <container>"); HelpText.Add("ModifyStat", "Usage: ModifyStat <object_type>,<object_name>,<modification_string>"); }
public override void Draw() { GameConsole.ForegroundColor = Color.White; GameConsole.BackgroundColor = Terr.GetTile(Pos).BackgroundColor; GameConsole.DrawChar(Char, (int)Pos.X, (int)Pos.Y); }