Example #1
0
        private void OnLoad(object sender, EventArgs e)
        {
            Lumberjack.Debug("Loading window state");
            // Set up lighting
            GL.ShadeModel(ShadingModel.Smooth);
            GL.Enable(EnableCap.ColorMaterial);

            // Set up caps
            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.RescaleNormal);
            GL.Disable(EnableCap.Texture2D);
            GL.Disable(EnableCap.CullFace);

            // Set up blending
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);

            // Set background color
            GL.ClearColor(Color.FromArgb(255, 13, 13, 13));

            // Init keyboard to ensure first frame won't NPE
            _keyboard = Keyboard.GetState();

            Lumberjack.Debug("Loading render engine");
            _mappingEngine = new MappingEngine();
            _renderEngine  = new RenderEngine(this, _mappingEngine);

            _camera = new Camera();

            Lumberjack.Debug("Loading world");
            _structure = StructureLoader.Load(_args[0]);
            _renderEngine.LoadStructure(_structure);
        }
        private void RedrawList()
        {
            int number = 1;

            Line.Items.Clear();
            foreach (Lumberjack lumberJackCycle in breakfastLine)
            {
                Line.Items.Add(number + "." + lumberJackCycle.Name);
                number++;
            }

            if (breakfastLine.Count == 0)
            {
                CrispyRadioButton1.Enabled  = false;
                SoggyRadioButton1.Enabled   = false;
                BrownedRadioButton1.Enabled = false;
                BananaRadioButton2.Enabled  = false;
                nextInLine.Text             = "";
            }
            else
            {
                CrispyRadioButton1.Enabled  = true;
                SoggyRadioButton1.Enabled   = true;
                BrownedRadioButton1.Enabled = true;
                BananaRadioButton2.Enabled  = true;
                Lumberjack currentLumberjack = breakfastLine.Peek();
                nextInLine.Text = currentLumberjack.Name + " has "
                                  + currentLumberjack.FlapjackCount + " flapjacks";
            }
        }
Example #3
0
    // cast Profession to a newly initialized Person
    public static Person ToPerson(this Profession prof)
    {
        Person p = null;

        switch (prof)
        {
        case Profession.Farmer:
            p = new Farmer();
            break;

        case Profession.Lumberjack:
            p = new Lumberjack();
            break;

        case Profession.Miner:
            p = new Miner();
            break;

        case Profession.Blacksmith:
            p = new Blacksmith();
            break;

        default:
            throw new NotSupportedException();
        }

        return(p);
    }
        public static void Run()
        {
            // Load local mapping database
            Lumberjack.Log("Loading mapping database...");
            _mappingDatabase = new MappingDatabase(Path.Combine(Program.BaseDirConfig, "mappings.db"));

            var assy = Assembly.GetExecutingAssembly().GetName();

            Lumberjack.Info("Fabric Lightweight Obfuscation Remapping Assistant (FLORA)");
            Lumberjack.Info($"Version {assy.Version} - parzivail");
            Lumberjack.Info($"Source, issues and discussion: {"https://github.com/Parzivail-Modding-Team/FLORA".Pastel(Color.RoyalBlue)}");
            Lumberjack.Info("Interactive Mode - \"help\" for commands, \"exit\" to quit.");

            // Enter read-eval-print loop
            InteractiveCommand command;

            do
            {
                command = GetCommand();
                if (command == null)
                {
                    Lumberjack.Error("Unknown command");
                }
                else
                {
                    command.Run(_mappingDatabase);
                }
            } while (!(command is ExitCommand));
        }
Example #5
0
        public static string[] GetYarnMappings(YarnVersion version)
        {
            try
            {
                var lines = new List <string>();

                var mappingsTarball =
                    $"https://maven.fabricmc.net/net/fabricmc/yarn/{version.Version}/yarn-{version.Version}-tiny.gz";
                using (var client = new WebClient())
                    using (var fileStream = new MemoryStream(client.DownloadData(mappingsTarball)))
                        using (var gzStream = new GZipStream(fileStream, CompressionMode.Decompress))
                            using (var sr = new StreamReader(gzStream))
                            {
                                sr.ReadLine();

                                string line;
                                while ((line = sr.ReadLine()) != null)
                                {
                                    lines.Add(line);
                                }
                            }

                return(lines.ToArray());
            }
            catch (WebException e)
            {
                Lumberjack.Error($"Could not retrieve remote Yarn mappings: {e.Message}");
                return(null);
            }
            catch (Exception e)
            {
                Lumberjack.Error($"Could not load remote Yarn mappings: {e.Message}! Please report this to the developer.");
                return(null);
            }
        }
        /// <inheritdoc />
        public override void Run(MappingDatabase mappingDatabase)
        {
            var args = GetUnquotedArgs();

            if (args.Length < 1 || args.Length > 2)
            {
                PrintErrorUsage();
                return;
            }

            var input  = args[0];
            var output = args.Length == 1 ? $"{Path.GetFileNameWithoutExtension(input)}-mapped" : args[1];

            if (!File.Exists(input))
            {
                Lumberjack.Error($"Input file \"{input}\" does not exist!");
                return;
            }

            var mappingSource = InteractiveMapper.GetSelectedMappingSource();

            if (mappingSource == null)
            {
                return;
            }

            Mapper.MapArchive(mappingSource, input, output);
        }
Example #7
0
        private void LoadScript(string filename)
        {
            var fs = WaitForFile(filename, FileMode.Open, FileAccess.Read, FileShare.Read);

            if (fs == null)
            {
                Lumberjack.Error("Failed to gain exclusive lock to read script!");
                return;
            }

            string scriptCode;

            using (var reader = new StreamReader(fs))
            {
                scriptCode = reader.ReadToEnd();
            }

            if (scriptCode.GetHashCode() == _stringHash)
            {
                return;
            }

            _stringHash = scriptCode.GetHashCode();

            OnFileChanged(new ScriptChangedEventArgs
            {
                ScriptCode = scriptCode,
                Filename   = filename
            });
        }
        private static int Main(string[] args)
        {
            if (args.Length == 0)
            {
                return(-1);
            }

            Thread.CurrentThread.Name = "main";

            Lumberjack.Init();

            Lumberjack.Debug("Loading configuration");
            Config = ConfigContainer.Load();

            if (Config.UnpackTextures)
            {
                Lumberjack.Debug("Unpacking textures");
                ZipFile.ExtractToDirectory("Resources/assets.zip", "Resources");
                Config.UnpackTextures = false;
                Config.Save();
            }

            Lumberjack.Debug("Loading window");
            new MainWindow(args)
            {
                VSync = VSyncMode.Off
            }.Run();

            return(0);
        }
        /// <inheritdoc />
        public override void Run(MappingDatabase mappingDatabase)
        {
            if (Args == null)
            {
                PrintErrorUsage();
                return;
            }

            if (Args.EndsWith(".tiny"))
            {
                if (!File.Exists(Args))
                {
                    Lumberjack.Error($"Mapping file \"{Args}\" could not be found!");
                    return;
                }

                mappingDatabase.UseLocalFile(Args);

                Lumberjack.Log($"Using mappings from \"{Args}\"");
            }
            else
            {
                LoadRemoteMappings(mappingDatabase, Args);
            }
        }
        /// <inheritdoc />
        public override void Run(MappingDatabase mappingDatabase)
        {
            if (Args == null)
            {
                PrintErrorUsage();
                return;
            }

            var mappingSource = InteractiveMapper.GetSelectedMappingSource();

            if (mappingSource == null)
            {
                return;
            }

            var mappings = mappingSource.Search(Args);

            foreach (var mapping in mappings)
            {
                if (mapping.ParentOfficialName != null)
                {
                    var parentMapping = mappingSource.GetClassByObf(mapping.ParentOfficialName);
                    Lumberjack.Log($"{mapping.GetMappingString()} (child of {parentMapping.GetMappingString()})");
                }
                else
                {
                    Lumberjack.Log($"{mapping.GetMappingString()}");
                }
            }
        }
Example #11
0
 protected void Log(string msg)
 {
     msg = msg.Trim();
     if (msg.Length > 0)
     {
         Lumberjack.Log(msg, ConsoleColor.DarkYellow, OutputLevel.Debug, "GLSL");
     }
 }
Example #12
0
 protected void Log(string msg)
 {
     msg = msg.Trim();
     if (msg.Length > 0)
     {
         Lumberjack.Error("GLSL", msg);
     }
 }
Example #13
0
    private void OnTriggerEnter(Collider other)
    {
        Lumberjack lumber = other.GetComponent <Lumberjack>();

        if (other != null)
        {
            lumber.Rabbitify();
        }
    }
Example #14
0
        private static void OnGlMessage(DebugSource source, DebugType type, int id, DebugSeverity severity, int length, IntPtr message, IntPtr userparam)
        {
            if (severity == DebugSeverity.DebugSeverityNotification || SuppressedGlMessages.Contains(id))
            {
                return;
            }

            var msg = Marshal.PtrToStringAnsi(message, length);

            Lumberjack.Debug("OpenGL", msg);
        }
Example #15
0
        /// <summary>
        /// Check if the mapping for the regex match is valid
        /// </summary>
        /// <param name="mapping">The class, field or method mapping from the database</param>
        /// <param name="match">The regex match for the keyword</param>
        /// <param name="failedMappings">The list to insert failed mappings into</param>
        /// <returns></returns>
        private static string CheckMatch(Mapping mapping, Capture match, List <string> failedMappings = null)
        {
            if (mapping != null)
            {
                Lumberjack.Log($"{match.Value}\t-> {mapping.GetMappingString()}");
                return(mapping.MappedShortName);
            }

            Lumberjack.Warn($"{match.Value}\t-> ??? (No mapping)");
            failedMappings?.Add(match.Value);
            return(match.Value);
        }
Example #16
0
 public void GoToSwarmill()
 {
     if (!isDead)
     {
         Sawmill sawmill = GetClosestSawmill();
         lumb = Instantiate(gameManager.lumberjackPrefab, this.transform.position, this.transform.rotation);
         lumb.gameObject.SetActive(false);
         navMeshAgent.destination = sawmill.transform.position;
         navMeshAgent.isStopped   = false;
         animator.SetBool("walk", true);
     }
 }
 public static IMappingSource GetSelectedMappingSource()
 {
     if (_mappingDatabase.IsUsingLocalFile)
     {
         return(_mappingDatabase.GetMappingSet(null));
     }
     if (_selectedMappingSource == null)
     {
         Lumberjack.Error("No mapping source defined! Select one with \"mapsrc\"");
     }
     return(_selectedMappingSource);
 }
 /// <inheritdoc />
 public override void PrintAdvancedHelp()
 {
     Lumberjack.Log(GetCommandDescription().Usage);
     Lumberjack.Log("");
     Lumberjack.Log("The mapjar command is used to convert the intermediary mappings in all of the Java");
     Lumberjack.Log("files in a given jar/zip archive to their named counterparts. The input file must be");
     Lumberjack.Log("a \"source\" jar or a decompiled zip (as produced by jd-gui, for example), where the");
     Lumberjack.Log("contents are Java files and not class files. All of the contents of the jar will be");
     Lumberjack.Log("copied to the output directory, even if they were not modified by the mapping");
     Lumberjack.Log("procedure. If no output directory is specified, a directory based on the input filename");
     Lumberjack.Log("is used.");
 }
Example #19
0
        private void OnScriptChanged(object sender, ScriptChangedEventArgs e)
        {
            Lumberjack.Info(string.Format(EmbeddedFiles.Info_FileReloaded, e.Filename));
            var success = _terrainGenerator.LoadScript(e.ScriptCode);

            if (!success)
            {
                return;
            }

            _renderManager.Rebuild();
        }
        private static void LoadRemoteMappings(MappingDatabase mappingDatabase, string version)
        {
            Lumberjack.Log("Fetching mapping versions from remote...");
            var yarnVersions = YarnUtil.GetYarnVersions();

            if (yarnVersions == null)
            {
                // If we couldn't get them, try to use the ones we've already cached

                Lumberjack.Warn("Working in offline mode. Only local Yarn mappings will be available.");
                yarnVersions = mappingDatabase.GetYarnVersions();
            }

            if (yarnVersions.All(mapping => mapping.Version != version))
            {
                // If a specific mapping version was specified that doesn't exist in the version listing, fail

                Lumberjack.Error($"Could not find mapping version {version}!");
                return;
            }

            var mappingVersion = yarnVersions.First(mapping => mapping.Version == version);

            if (!mappingDatabase.HasMappingSet(mappingVersion))
            {
                // If we don't have those mappings cached, download them and cache them

                Lumberjack.Log("Fetching mappings from remote...");
                var mappings = YarnUtil.GetYarnMappings(mappingVersion);

                if (mappings != null)
                {
                    Lumberjack.Log("Updating database...");
                    mappingDatabase.CreateMappingSet(mappingVersion, mappings);
                }
                else
                {
                    Lumberjack.Error($"Failed to load requested mappings {mappingVersion.Version}");
                    Environment.Exit((int)ExitConditions.MappingVersionNotFound);
                }
            }
            else
            {
                Lumberjack.Log("Local database contains required mappings.");
            }

            InteractiveMapper.SetYarnVersion(mappingVersion);

            Lumberjack.Log($"Using mappings from yarn {version}");
        }
 /// <inheritdoc />
 public override void PrintAdvancedHelp()
 {
     Lumberjack.Log(GetCommandDescription().Usage);
     Lumberjack.Log("");
     Lumberjack.Log("The search command is used to find the mappings associated with the given named,");
     Lumberjack.Log("intermediary, or official/obfuscated mapping. Searching by official/obfuscated names");
     Lumberjack.Log("is only available for classes, as all classes' fields and methods first obfuscated");
     Lumberjack.Log("name is the same, and there's a good chance any given query will return thousands of");
     Lumberjack.Log("results.");
     Lumberjack.Log("");
     Lumberjack.Log("Examples:");
     Lumberjack.Log("");
     Lumberjack.Info("search CowEntity");
     Lumberjack.Info("search class_1430");
     Lumberjack.Info("search ath");
 }
 /// <inheritdoc />
 public override void PrintAdvancedHelp()
 {
     Lumberjack.Log(GetCommandDescription().Usage);
     Lumberjack.Log("");
     Lumberjack.Log("The children command is useful to determine what methods, fields, and classes are");
     Lumberjack.Log("defined explicitly as children of the given class. The class can be given in either");
     Lumberjack.Log("the mapped form, the intermediate form, or the official/obfuscated form. For example:");
     Lumberjack.Log("");
     Lumberjack.Info("children MatrixStack");
     Lumberjack.Info("children class_4587");
     Lumberjack.Info("children cyl");
     Lumberjack.Log("");
     Lumberjack.Log("are all equivelant. The children listed will only be children that are explicitly");
     Lumberjack.Log("defined in the target class. As such, fields, methods, and subclasses that are");
     Lumberjack.Log("inherited from a superclass will not be shown unless they are overridden.");
 }
 /// <inheritdoc />
 public override void PrintAdvancedHelp()
 {
     Lumberjack.Log(GetCommandDescription().Usage);
     Lumberjack.Log("");
     Lumberjack.Log("The mapsrc command is used to set which mappings are being used by the interactive");
     Lumberjack.Log("environment. As a parameter, you can specify a Tiny v1 mapping file or a Yarn version");
     Lumberjack.Log("string. If the latter is specified, the mappings will be saved to a local mapping");
     Lumberjack.Log("database (mappings.db) for faster reuse of those mappings. If you do not have an");
     Lumberjack.Log("internet connection, you are limited to using mappings in a provided Tiny v1 file or");
     Lumberjack.Log("ones already cached in the database.");
     Lumberjack.Log("");
     Lumberjack.Log("Examples:");
     Lumberjack.Log("");
     Lumberjack.Info("mapsrc 1.15.2+build.7");
     Lumberjack.Info("mapsrc my_mappings.tiny");
 }
        protected void NextLumberJackButton_Click(object sender, EventArgs e)
        {
            if (breakfastLine.Count == 0)
            {
                return;
            }
            Lumberjack nextLumberjack = breakfastLine.Dequeue();

            OutputListBox.Items.Add(nextLumberjack.EatFlapjacks());
            foreach (string strings in nextLumberjack.EatFlapjacks2())
            {
                OutputListBox.Items.Add(strings);
            }

            nextInLine.Text = "";
            RedrawList();
        }
Example #25
0
        private void OnLoad(object sender, EventArgs e)
        {
            Title = $"{EmbeddedFiles.AppName} | {EmbeddedFiles.Title_Unsaved}";
            Icon  = EmbeddedFiles.logo;

            // Set up lights
            const float diffuse = 0.9f;

            float[] matDiffuse = { diffuse, diffuse, diffuse };
            GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Diffuse, matDiffuse);
            GL.Light(LightName.Light0, LightParameter.Position, new[] { 0.0f, 0.0f, 0.0f, 10.0f });
            GL.Light(LightName.Light0, LightParameter.Diffuse, new[] { diffuse, diffuse, diffuse, diffuse });

            // Set up lighting
            GL.Enable(EnableCap.Lighting);
            GL.Enable(EnableCap.Light0);
            GL.ShadeModel(ShadingModel.Smooth);
            GL.Enable(EnableCap.ColorMaterial);

            // Set up caps
            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.RescaleNormal);
            GL.Disable(EnableCap.Texture2D);
            GL.Disable(EnableCap.CullFace);

            // Set up blending
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);

            // Set background color
            GL.ClearColor(Color.FromArgb(255, 13, 13, 13));

            // Init keyboard to ensure first frame won't NPE
            _keyboard = Keyboard.GetState();

            _terrainGenerator = new CsTerrainGenerator();
            _renderManager    = new RenderManager(_terrainGenerator);

            _terrainLayerList = new RenderController(this);
            _terrainLayerList.Show();

            _scriptWatcher              = new ScriptWatcher();
            _scriptWatcher.FileChanged += OnScriptChanged;

            Lumberjack.Info(EmbeddedFiles.Info_WindowLoaded);
        }
        public EmulatorWindow() : base(GameWindowSettings.Default, NativeWindowSettings.Default)
        {
            Thread.CurrentThread.Name = "EmuWindow";

            Load   += WindowLoad;
            Resize += WindowResize;

            RenderFrame += WindowRender;
            UpdateFrame += WindowUpdate;

            Closing += WindowClosing;

            WindowBorder = WindowBorder.Fixed;

            _logger   = Lumberjack.CreateLogger("RmEmulator");
            _glLogger = Lumberjack.CreateLogger("OpenGL");
        }
Example #27
0
        public void Init(Flat6Window window)
        {
            Window = window;

            Lumberjack.Debug("Creating framebuffers");
            FramebufferScene = new Framebuffer(8);
            FramebufferScene.Init(Window.Width, Window.Height);
            FramebufferInterface = new Framebuffer(8);
            FramebufferInterface.Init(Window.Width, Window.Height);

            CreateScreenVao();

            Lumberjack.Debug("Creating shaders");
            ShaderDefault = new ShaderProgram(EmbeddedResources.FsDefault, EmbeddedResources.VsDefault);
            ShaderDefault.Uniforms.SetValue("texModel", 0);
            ShaderDefault.Uniforms.SetValue("texRandom", 1);

            ShaderScreen = new ShaderProgram(EmbeddedResources.FsScreen, EmbeddedResources.VsScreen);
            ShaderScreen.Uniforms.SetValue("width", Window.Width);
            ShaderScreen.Uniforms.SetValue("height", Window.Height);
            ShaderScreen.Uniforms.SetValue("texScene", 0);
            ShaderScreen.Uniforms.SetValue("texInterface", 1);
            ShaderScreen.Uniforms.SetValue("samplesScene", FramebufferScene.Width);
            ShaderScreen.Uniforms.SetValue("samplesInterface", FramebufferInterface.Samples);

            TextureDefault = TexturePointer.Create(EmbeddedResources.ImgNoTexture);
            TextureRandom  = TexturePointer.Create(EmbeddedResources.ImgRandom);

            Lumberjack.Debug("Creating NanoVG context");
            Nvg = GlNanoVg.CreateGl(NvgCreateFlags.StencilStrokes);
            Nvg.CreateFont("engine_mono", EmbeddedResources.IBMPlexMono_Text);

            // Just so ProcGraph is happy for now, TODO
            Nvg.CreateFont("sans", EmbeddedResources.IBMPlexMono_Text);

            UserInterface = new DebugUserInterface();

            Lumberjack.Debug("Creating scene");
            Camera = new Camera();
            Scene  = new Scene();

            Flat6Window.SuppressGlMessage(131218); // "Shader will be recompiled due to..."

            WindowCreated?.Invoke(this, EventArgs.Empty);
        }
 /// <inheritdoc />
 public override void PrintAdvancedHelp()
 {
     Lumberjack.Log(GetCommandDescription().Usage);
     Lumberjack.Log("");
     Lumberjack.Log("The yarnver command is used to determine the yarn versions that are applicable to");
     Lumberjack.Log("the given game version. If no game version is provided, then all known yarn versions");
     Lumberjack.Log("are shown, grouped by their applicable game version. Next to the Yarn version string,");
     Lumberjack.Log("the maven ID is provided, and stable versions are denoted.");
     Lumberjack.Log("");
     Lumberjack.Log("Examples:");
     Lumberjack.Log("");
     Lumberjack.Info("yarnver");
     Lumberjack.Log("\tWill search all mappings");
     Lumberjack.Info("yarnver 1.15");
     Lumberjack.Log("\tWill search all mappings for 1.15.x");
     Lumberjack.Info("yarnver 1.15.1");
     Lumberjack.Log("\tWill search all mappings for 1.15.1");
 }
Example #29
0
        /// <summary>
        /// Maps the input string contents
        /// </summary>
        /// <param name="mappingSource">The mapping provider</param>
        /// <param name="file">The contents to map</param>
        /// <param name="failedMappings">The list of failed mappings to generate a report for</param>
        /// <returns>The mapped string contents</returns>
        public static string MapString(IMappingSource mappingSource, string file, List <string> failedMappings = null)
        {
            Lumberjack.PushCategory("Mapper");

            // Create regexes for matching intermediary names
            var rgxClass  = new Regex("class_\\d+", RegexOptions.Compiled);
            var rgxField  = new Regex("field_\\d+", RegexOptions.Compiled);
            var rgxMethod = new Regex("method_\\d+", RegexOptions.Compiled);

            // Replace all of the intermediary names
            file = rgxClass.Replace(file, match => CheckMatch(mappingSource.GetClassByInt(match.Value), match, failedMappings));
            file = rgxField.Replace(file, match => CheckMatch(mappingSource.GetFieldByInt(match.Value), match, failedMappings));
            file = rgxMethod.Replace(file,
                                     match => CheckMatch(mappingSource.GetMethodByInt(match.Value), match, failedMappings));

            Lumberjack.PopCategory();
            return(file);
        }
Example #30
0
    void HeavyAttack()
    {
        Collider2D[] hits = Physics2D.OverlapCircleAll(attackPoint.position, heavyAttackRange, LumberjackLayer);
        attackHeavySource.Play();

        foreach (Collider2D Lumberjack in hits)
        {
            Lumberjack.GetComponent <Lumberjack>().TakeDamage(heavyAttackDamage);
        }

        Collider2D[] hits2 = Physics2D.OverlapCircleAll(attackPoint.position, heavyAttackRange, HunterLayer);


        foreach (Collider2D Hunter in hits2)
        {
            Hunter.GetComponent <Hunter>().TakeDamage(heavyAttackDamage);
        }
    }
 public InitializeTreeProduction()
 {
     GameObject ob = GameObject.Find("Lumberjack");
     if (ob != null) Lumber = ob.GetComponent<Lumberjack>();
     else Debug.LogError("Cant Find Lumberjack");
 }
Example #32
0
 public SawmillProduce()
 {
     GameObject ob = GameObject.Find("Lumberjack");
     if (ob != null) Lumber = ob.GetComponent<Lumberjack>();
     else Debug.LogError("Cant Find Lumberjack");
 }