public static bool FilterEnabled(int filterId)
        {
            var f = (FilterType)filterId;

            switch (f)
            {
            // TODO
            case FilterType.Quests:
                return(!AHK.IniFlag("HideQuestFilter"));

            case FilterType.Teleports:
                return(!AHK.IniFlag("HideWarpFilter"));

            case FilterType.Collectibles:
                return(!AHK.IniFlag("HideCollectableFilter"));

            case FilterType.InLogic:
                return(SeedController.HasInternalSpoilers);

            case FilterType.Spoilers:
                return(UberGet.value(34543, 11226).Bool);

            default:
                return(true);
            }
        }
        public static void FilterIconText(IntPtr buffer, int length, int groupId, int id, int value, int filterId)
        {
            var cond = new UberStateCondition(groupId, id, value);
            var f    = (FilterType)filterId;

            string text = ((f == FilterType.InLogic || f == FilterType.Spoilers) && UberGet.value(34543, 11226).Bool ? cond.SpoilerName() : LocName(cond)) ?? " ";

            length = Math.Min(text.Length, length);
            Marshal.Copy(text.ToCharArray(), 0, buffer, length);
        }
 public static bool Bought(this AbilityType at) => UberGet.value(at.BoughtState()).Bool;
 public static bool HaveTree(this AbilityType at) => UberGet.value(at.TreeState()).Bool;
 public static bool Have(this QuestEventType at) => UberGet.value(at.State()).Bool;
Example #6
0
        public static void HandleSignal(string signal)
        {
            switch (signal)
            {
            case "reload":
                if (FramesTillUnlockReload == 0)
                {
                    iniFlagCache.Clear();
                    FramesTillNextSend = 0;
                    Randomizer.Client.Connect();
                    SeedController.ReadSeed();
                    if (InterOp.get_game_state() == GameState.Game)
                    {
                        PsuedoLocs.RELOAD_SEED.OnCollect();
                    }
                    FramesTillUnlockReload = 120;
                }
                break;

            case "lastPickup":
                FramesTillNextSend = 1; // the only reason this isn't = 0 is that spamming this could get really annoying
                MessageQueue.Enqueue(Last);
                break;

            case "progressAndHints":
                HintsController.ProgressWithHints();
                break;

            case "dev":
                Randomizer.Dev = !Randomizer.Dev;
                Randomizer.Log($"Dev: {Randomizer.Dev}");
                break;

            case "exitapp":
                Environment.Exit(Environment.ExitCode);
                break;

            case "toggleDebug":
                InterOp.set_debug_controls(!InterOp.get_debug_controls());
                Print($"Debug {(InterOp.get_debug_controls() ? "enabled" : "disabled")}", toMessageLog: false);
                break;

            case "toggleCursorLock":
                Print($"Cursor Lock {(InterOp.toggle_cursorlock() ? "enabled" : "disabled")}", toMessageLog: false);
                break;

            case "binding1":
                PsuedoLocs.BINDING_ONE.OnCollect();
                break;

            case "binding2":
                PsuedoLocs.BINDING_TWO.OnCollect();
                break;

            case "binding3":
                PsuedoLocs.BINDING_THREE.OnCollect();
                break;

            case "binding4":
                PsuedoLocs.BINDING_FOUR.OnCollect();
                break;

            case "binding5":
                PsuedoLocs.BINDING_FIVE.OnCollect();
                break;

            case "unlockSpoiers":
                if (SeedController.Settings.RaceMode)
                {
                    return;                             // no cheat
                }
                UberSet.Bool(GameComplete, true);
                Print("spoiler unlocked", toMessageLog: false);
                break;

            case "tpCheat":
                if (SeedController.Settings.RaceMode)
                {
                    return;                             // no cheat
                }
                tpCheatToggle = !tpCheatToggle;
                Print($"TPCheat {(tpCheatToggle ? "enabled" : "disabled")}", toMessageLog: false);
                break;

            case "warpCredits":
                if (UberGet.Bool(GameComplete))
                {
                    InterOp.start_credits();
                }
                else
                {
                    Print($"Credit warp not unlocked!", toMessageLog: false);
                }
                break;

            case "printCoords":
                var pos = InterOp.get_position();
                Print($"{pos.X}, {pos.Y}", toMessageLog: false);
                break;

            case "nameSpoilerToggle":
                MapController.NameLabels = !MapController.NameLabels;
                Print($"Loc name labels {(MapController.NameLabels ? "enabled" : "disabled")}", toMessageLog: false);
                break;

            case "logicprovidertoggle":
                MapController.RustLogic = !MapController.RustLogic;
                Print($"Logic Provider: {(MapController.RustLogic ? "Rust" : "Java")}", toMessageLog: false);
                MapController.UpdateReachable();
                break;

            default:
                Randomizer.Log($"Recieved unknown signal {signal}");
                break;
            }
        }
 public override void Grant(bool skipBase = false)
 {
     UberStateController.SkipUberStateMapCount[Id] = SupCount;
     InterOp.set_uber_state_value(Id.GroupID, Id.ID, Modifier(UberGet.value(Id)));
 }
        public static void UpdateReachableAsync(int sleepTime = 30)
        {
            try {
                Thread.Sleep(sleepTime); // wait to let values update
                if (Updating)
                {
                    return;
                }
                Updating = true;
                var argsList = RustLogic ? new List <string> {
                    "reach-check",
                    // TODO maybe we won't pass these explicitly? since it's samefolder shit
                    "--areas",
                    $"\"{Randomizer.BasePath}areas.wotw\"",
                    "--locations",
                    $"\"{Randomizer.BasePath}loc_data.csv\"",
                    "--uber-states",
                    $"\"{Randomizer.BasePath}state_data.csv\"",
                } : new List <string> {
                    "-jar",
                    $"\"{Randomizer.BasePath}SeedGen.jar\" ",
                    "ReachCheck"
                };
                argsList.AddRange(new List <string> {
                    $"\"{SeedController.SeedFile}\"",
                    $"{InterOp.get_max_health()}",
                    $"{Convert.ToInt32(10*InterOp.get_max_energy())}",
                    $"{UberGet.value(6, 0).Int}",
                    $"{InterOp.get_ore()}",
                    $"{InterOp.get_experience()}",
                });
                if (RustLogic)
                {
                    argsList.AddRange(TrackedConds.Where(c => c.Met()).Select(t => $"u:{t.Id.GroupID},{t.Id.ID}"));
                }
                argsList.AddRange(SaveController.SkillsFound.Select((AbilityType at) => $"s:{(int)at}"));
                argsList.AddRange(Teleporter.TeleporterStates.Keys.Where(t => new Teleporter(t).Has()).Select(t => $"t:{(int)t}"));
                if (new QuestEvent(QuestEventType.Water).Has())
                {
                    argsList.Add("w:0");
                }
                argsList.AddRange(TrackedShards.Where(sh => new Shard(sh).Has()).Select(t => $"sh:{(int)t}"));
                var proc = new System.Diagnostics.Process();
                proc.StartInfo.FileName               = RustLogic ? @"seedgen.exe" : @"java.exe";
                proc.StartInfo.Arguments              = String.Join(" ", argsList);
                proc.StartInfo.CreateNoWindow         = true;
                proc.StartInfo.UseShellExecute        = false;
                proc.StartInfo.RedirectStandardOutput = true;
                proc.StartInfo.RedirectStandardError  = true;
                proc.StartInfo.WorkingDirectory       = Randomizer.BasePath;
                proc.Start();
                if (!proc.WaitForExit(10000))
                {
                    Randomizer.Warn("MapController.waitForProc", "timed out waiting for reach check", false);
                }
                Reachable.Clear();
                var rawOutput = proc.StandardOutput.ReadToEnd();
                if (rawOutput.Trim() != "")
                {
                    foreach (var rawCond in rawOutput.Split(','))
                    {
                        try {
                            var frags = rawCond.Split('|');
                            var cond  = new UberStateCondition(int.Parse(frags[0]), frags[1]);
                            if (cond.Loc().Type == LocType.Shop)
                            {
                                if (cond.Met() || hintTypes.Contains(cond.Pickup().Type))
                                {
                                    continue; // bought it or it's a hint. Either way it's known to be non progression, so it does not show on the map
                                }
                                if (ShopSlot.Twillen.Any(e => e.State.Equals(cond.Id)))
                                {
                                    Reachable.Add(new UberStateCondition(2, "20000"));
                                }
                                else if (ShopSlot.Opher.Any(e => e.State.Equals(cond.Id)))
                                {
                                    Reachable.Add(new UberStateCondition(1, "20000"));
                                }
                                else if (ShopSlot.LupoStore.Any(e => e.State.Equals(cond.Id)))
                                {
                                    Reachable.Add(new UberStateCondition(48248, "20000"));
                                }
                            }
                            Reachable.Add(cond);
                        }
                        catch (Exception e) { Randomizer.Error($"GetReachableAsync (post-return) while parsing |{rawCond}|", e); }
                    }
                }

                /*
                 * if(Randomizer.Dev)
                 * Randomizer.Log($"Reach check:\nseed_gen_cli.exe {String.Join(" ", argsList)}\n gave output: \n{rawOutput}\n stderr was {proc.StandardError.ReadToEnd()}\nReachable after: {String.Join(" ", Reachable.Select(r => r.ToString()))}", false);
                 */
                InterOp.refresh_inlogic_filter();
            }
            catch (Exception e) { Randomizer.Error("GetReachableAsync", e); }
            Updating = false;
        }
        public static void UpdateReachableAsync(int sleepTime = 30)
        {
            try {
                Thread.Sleep(sleepTime); // wait to let values update
                if (Updating)
                {
                    return;
                }
                Updating = true;
                var argsList = new List <string> {
                    "-jar",
                    $"{Randomizer.BasePath}SeedGen.jar ",
                    "ReachCheck",
                    $"\"{SeedController.SeedFile}\"",
                    $"{InterOp.get_max_health()}",
                    $"{Convert.ToInt32(10*InterOp.get_max_energy())}",
                    $"{UberGet.value(6, 0).Int}",
                    $"{InterOp.get_ore()}",
                    $"{InterOp.get_experience()}",
                };
                // ^ this should probably be an array at this point...
                // TODO: send which key doors are already open
                argsList.AddRange(SaveController.SkillsFound.Select((AbilityType at) => $"s:{(int)at}"));
                argsList.AddRange(Teleporter.TeleporterStates.Keys.Where(t => new Teleporter(t).Has()).Select(t => $"t:{(int)t}"));
                if (new QuestEvent(QuestEventType.Water).Has())
                {
                    argsList.Add("w:0");
                }
                var proc = new System.Diagnostics.Process();
                proc.StartInfo.FileName               = @"java.exe";
                proc.StartInfo.Arguments              = String.Join(" ", argsList);
                proc.StartInfo.CreateNoWindow         = true;
                proc.StartInfo.UseShellExecute        = false;
                proc.StartInfo.RedirectStandardOutput = true;
                proc.StartInfo.WorkingDirectory       = Randomizer.BasePath;
                proc.Start();
                if (!proc.WaitForExit(7500))
                {
                    Randomizer.Warn("MapController.waitForProc", "timed out waiting for reach check", false);
                }
                Reachable.Clear();
                var rawOutput = proc.StandardOutput.ReadToEnd();
                if (rawOutput.Trim() != "")
                {
                    foreach (var rawCond in rawOutput.Split(','))
                    {
                        try {
                            var frags = rawCond.Split('|');
                            var cond  = new UberStateCondition(int.Parse(frags[0]), frags[1]);
                            Reachable.Add(cond);
                        }
                        catch (Exception e) { Randomizer.Error($"GetReachableAsync (post-return) while parsing |{rawCond}|", e); }
                    }
                }
//        else
//          Randomizer.Log($"got output |{rawOutput}| from cmd. args: \"{String.Join(" ", argsList)}\" stderr was {proc.StandardError.ReadToEnd()}", false);
                InterOp.refresh_inlogic_filter();
            }
            catch (Exception e) { Randomizer.Error("GetReachableAsync", e); }
            Updating = false;
        }
Example #10
0
 public static string GetKeySkillHintTwo() => UberGet.value(SkillHintTwoState).Bool ?
 $"{AbilityType.Burrow.HintFrag()}, {AbilityType.WaterDash.HintFrag()}, {AbilityType.LightBurst.HintFrag()}, {AbilityType.Flash.HintFrag()}" : "";
Example #11
0
 public static void Byte(UberId id, byte val             = 1) => UberSet.Byte(id, (byte)(UberGet.value(id).Byte + val));
Example #12
0
 public static void Float(UberId id, float val           = 1) => UberSet.Float(id, UberGet.value(id).Float + val);
Example #13
0
 public static void Int(UberId id, int val               = 1) => UberSet.Int(id, UberGet.value(id).Int + val);
Example #14
0
 public static void Toggle(UberId id) => UberSet.Bool(id, UberGet.value(id).Bool);
 public static bool Upgraded(this AbilityType at) => UberGet.value(at.UpgradedState()).Bool;
 public static bool Bought(this ShardType st) => UberGet.value(st.BoughtState()).Bool;
 public static bool Have(this AbilityType at) => UberGet.Bool(at.State());