public static bool ShouldPatch(StardewValley.Object obj, out ArcadeMachineSpecs machine) { var search = Machines.FirstOrDefault(m => obj.netName.Value.Equals(m.ObjectName)); machine = search; return(machine != null); }
public static void Add(ArcadeMachineSpecs specs, IPlatoHelper helper) { if (!Machines.Contains(specs)) { Machines.Add(specs); if (helper.ModHelper.ModRegistry.GetApi <IArcadeApi>("spacechase0.ArcadeRoom") is IArcadeApi arcade) { specs.Spot = arcade.ReserveMachineSpot(); } Setup(helper, specs); } }
public static void Setup(IPlatoHelper helper, ArcadeMachineSpecs specs) { if (!Patched) { var instance = new Harmony("PlatoTK.ArcadeMachine"); instance.Patch( original: AccessTools.Method(typeof(StardewValley.Object), nameof(StardewValley.Object.checkForAction)), postfix: new HarmonyMethod(AccessTools.Method(typeof(ArcadeMachinePreset), nameof(CheckForActionPatch)))); helper.Events.CallingTileAction += Events_CallingTileAction; if (helper.ModHelper.ModRegistry.GetApi <IArcadeApi>("spacechase0.ArcadeRoom") is IArcadeApi arcade) { arcade.OnRoomSetup += (x, y) => { if (Game1.getLocationFromName("Arcade") is GameLocation a) { AddArcades(a); } helper.ModHelper.Events.Player.Warped += (s, e) => { if (e.NewLocation is GameLocation l && l.Name == "Arcade") { AddArcades(e.NewLocation); } }; } } ; Patched = true; } if (helper.ModHelper.ModRegistry.GetApi <IMobilePhoneApi>("aedenthorn.MobilePhone") is IMobilePhoneApi phone) { Texture2D appIcon = helper.ModHelper.Content.Load <Texture2D>(specs.Icon, StardewModdingAPI.ContentSource.GameContent); bool success = phone.AddApp(specs.Id, specs.Name, () => { specs.Start(); }, appIcon); } }