public MailDeliveryService(MailGenerator generator) { events = ModEntry.CommonServices.Events; reflectionHelper = ModEntry.CommonServices.ReflectionHelper; monitor = ModEntry.CommonServices.Monitor; mailGenerator = generator ?? throw new ArgumentNullException(nameof(generator)); running = false; }
//private bool wasGoingOver = false; public Jump(StardewValley.Farmer thePlayer, IModEvents events) { player = thePlayer; this.events = events; prevJumpVel = player.yJumpVelocity; player.synchronizedJump(8); events.GameLoop.UpdateTicked += onUpdateTicked; }
internal AI_StateMachine(CompanionStateMachine csm, CompanionDisplay hud, IModEvents events, IMonitor monitor) { this.npc = csm.Companion; this.player = csm.CompanionManager.Farmer; this.events = events ?? throw new ArgumentException(nameof(events)); this.Monitor = monitor ?? throw new ArgumentNullException(nameof(monitor)); this.Csm = csm; this.hud = hud; this.loader = csm.ContentLoader; }
//private bool wasGoingOver = false; public Jump(Farmer thePlayer, IModEvents events) { this.Player = thePlayer; this.Events = events; this.PrevJumpVel = this.Player.yJumpVelocity; this.Player.synchronizedJump(8); events.GameLoop.UpdateTicked += this.OnUpdateTicked; }
public CommonServices(IMonitor monitor, IModEvents events, ITranslationHelper translationHelper, IReflectionHelper reflectionHelper, IContentHelper contentHelper, IDataHelper dataHelper) { Monitor = monitor ?? throw new ArgumentNullException(nameof(monitor)); Events = events ?? throw new ArgumentNullException(nameof(events)); TranslationHelper = translationHelper ?? throw new ArgumentNullException(nameof(translationHelper)); ReflectionHelper = reflectionHelper ?? throw new ArgumentNullException(nameof(reflectionHelper)); ContentHelper = contentHelper ?? throw new ArgumentNullException(nameof(contentHelper)); DataHelper = dataHelper ?? throw new ArgumentNullException(nameof(dataHelper)); }
public StuffDriver(IModEvents events, IDataHelper dataHelper, IMonitor monitor) { events.GameLoop.Saving += this.GameLoop_Saving; events.GameLoop.SaveLoaded += this.GameLoop_SaveLoaded; events.GameLoop.Saved += this.GameLoop_Saved; this.DataHelper = dataHelper; this.DumpedBags = new List <BagDumpInfo>(); this.Monitor = monitor; }
/********* ** Public methods *********/ /// <summary>The mod entry point, called after the mod is first loaded.</summary> /// <param name="helper">Provides simplified APIs for writing mods.</param> public override void Entry(IModHelper helper) { // read config this.Config = helper.ReadConfig <ModConfig>(); this.Keys = this.Config.Controls.ParseControls(helper.Input, this.Monitor); // init tractor logic { IModRegistry modRegistry = this.Helper.ModRegistry; IReflectionHelper reflection = this.Helper.Reflection; StandardAttachmentsConfig toolConfig = this.Config.StandardAttachments; this.TractorManager = new TractorManager(this.Config, this.Keys, this.Helper.Translation, this.Helper.Reflection, attachments: new IAttachment[] { new CustomAttachment(this.Config.CustomAttachments, modRegistry, reflection), // should be first so it can override default attachments new AxeAttachment(toolConfig.Axe, modRegistry, reflection), new FertilizerAttachment(toolConfig.Fertilizer, modRegistry, reflection), new GrassStarterAttachment(toolConfig.GrassStarter, modRegistry, reflection), new HoeAttachment(toolConfig.Hoe, modRegistry, reflection), new MeleeWeaponAttachment(toolConfig.MeleeWeapon, modRegistry, reflection), new MilkPailAttachment(toolConfig.MilkPail, modRegistry, reflection), new PickaxeAttachment(toolConfig.PickAxe, modRegistry, reflection), new ScytheAttachment(toolConfig.Scythe, modRegistry, reflection), new SeedAttachment(toolConfig.Seeds, modRegistry, reflection), new SeedBagAttachment(toolConfig.SeedBagMod, modRegistry, reflection), new ShearsAttachment(toolConfig.Shears, modRegistry, reflection), new SlingshotAttachment(toolConfig.Slingshot, modRegistry, reflection), new WateringCanAttachment(toolConfig.WateringCan, modRegistry, reflection) }); } // hook events IModEvents events = helper.Events; events.GameLoop.GameLaunched += this.OnGameLaunched; events.GameLoop.SaveLoaded += this.OnSaveLoaded; events.GameLoop.DayStarted += this.OnDayStarted; events.GameLoop.DayEnding += this.OnDayEnding; events.GameLoop.Saving += this.OnSaving; if (this.Config.HighlightRadius) { events.Display.Rendered += this.OnRendered; } events.Display.MenuChanged += this.OnMenuChanged; events.Input.ButtonPressed += this.OnButtonPressed; events.World.NpcListChanged += this.OnNpcListChanged; events.World.LocationListChanged += this.OnLocationListChanged; events.GameLoop.UpdateTicked += this.OnUpdateTicked; events.Multiplayer.ModMessageReceived += this.OnModMessageReceived; // validate translations if (!helper.Translation.GetTranslations().Any()) { this.Monitor.Log("The translation files in this mod's i18n folder seem to be missing. The mod will still work, but you'll see 'missing translation' messages. Try reinstalling the mod to fix this.", LogLevel.Warn); } }
private void Start() { base.ModHelper.Events.Subscribe <Flashlight>(Events.AfterStart); IModEvents events = base.ModHelper.Events; events.OnEvent = (Action <MonoBehaviour, Events>)Delegate.Combine(events.OnEvent, new Action <MonoBehaviour, Events>(this.OnEvent)); //GlobalMessenger.AddListener("WakeUp", OnWakeUp); SceneManager.sceneLoaded += OnSceneLoaded; }
private void RegisterGameEvents(IModEvents events) { events.Input.ButtonPressed += OnButtonPressed; events.Input.CursorMoved += OnCursorMoved; events.Display.RenderedActiveMenu += OnRenderedActiveMenu; events.GameLoop.GameLaunched += OnGameLaunched; events.GameLoop.UpdateTicked += OnUpdateTicked; events.GameLoop.DayStarted += OnDayStarted; events.GameLoop.SaveLoaded += OnSaveLoaded; events.GameLoop.ReturnedToTitle += OnReturnedToTitle; }
public ModMenus(IModConsole console, IModEvents events) { MainMenu = new ModMainMenu(console); PauseMenu = new ModPauseMenu(console); ModsMenu = new ModsMenu(console, this); InputMenu = new ModInputMenu(console); events.Subscribe <SettingsManager>(Common.Events.AfterStart); events.Subscribe <TitleScreenManager>(Common.Events.AfterStart); events.OnEvent += OnEvent; }
public override void Entry(IModHelper helper) { ModMonitor = Monitor; Events = helper.Events; new DataLoader(helper); var harmony = HarmonyInstance.Create("Digus.CustomCrystalariumMod"); var utilityTryToPlaceItem = typeof(Utility).GetMethod("tryToPlaceItem"); var objectOverridesTryToPlaceItem = typeof(TransplantOverrides).GetMethod("TryToPlaceItem"); harmony.Patch(utilityTryToPlaceItem, new HarmonyMethod(objectOverridesTryToPlaceItem), null); var utilityCanGrabSomethingFromHere = typeof(Utility).GetMethod("canGrabSomethingFromHere"); var objectOverridesCanGrabSomethingFromHere = typeof(TransplantOverrides).GetMethod("CanGrabSomethingFromHere"); harmony.Patch(utilityCanGrabSomethingFromHere, new HarmonyMethod(objectOverridesCanGrabSomethingFromHere), null); var utilityPlayerCanPlaceItemHere = typeof(Utility).GetMethod("playerCanPlaceItemHere"); var objectOverridesPlayerCanPlaceItemHere = typeof(TransplantOverrides).GetMethod("PlayerCanPlaceItemHere"); harmony.Patch(utilityPlayerCanPlaceItemHere, new HarmonyMethod(objectOverridesPlayerCanPlaceItemHere), null); var hoeDirtPerformUseAction = typeof(HoeDirt).GetMethod("performUseAction"); var objectOverridesPerformUseAction = typeof(TransplantOverrides).GetMethod("PerformUseAction"); harmony.Patch(hoeDirtPerformUseAction, new HarmonyMethod(objectOverridesPerformUseAction), null); var fruitTreePerformUseAction = typeof(FruitTree).GetMethod("performUseAction"); var transplantOverridesFruitTreePerformUseAction = typeof(TransplantOverrides).GetMethod("FruitTreePerformUseAction"); harmony.Patch(fruitTreePerformUseAction, null, new HarmonyMethod(transplantOverridesFruitTreePerformUseAction)); var game1PressUseToolButton = typeof(Game1).GetMethod("pressUseToolButton"); var objectOverridesPressUseToolButton = typeof(TransplantOverrides).GetMethod("PressUseToolButton"); harmony.Patch(game1PressUseToolButton, new HarmonyMethod(objectOverridesPressUseToolButton), null); if (DataLoader.ModConfig.EnableSoilTileUnderTrees) { var treeDraw = typeof(Tree).GetMethod("draw"); var transplantOverridesPreTreeDraw = typeof(TransplantOverrides).GetMethod("PreTreeDraw"); harmony.Patch(treeDraw, new HarmonyMethod(transplantOverridesPreTreeDraw), null); } helper.Events.GameLoop.Saving += (sender, e) => { if (Game1.player.ActiveObject is HeldIndoorPot) { Game1.player.ActiveObject = TransplantOverrides.RegularPotObject; TransplantOverrides.CurrentHeldIndoorPot = null; } }; }
/********* ** Public methods *********/ public AdoptQuestion(bool cat, int skin, IModEvents events) { this.Cat = cat; this.Skin = skin; this.Events = events; this.Sprite = new AnimatedSprite(ModEntry.SHelper.Content.GetActualAssetKey($"assets/skins/{(cat ? "cat" : "dog")}_{skin}.png"), 28, 32, 32) { loop = true }; }
private void RegisterEvents(IModEvents events) { events.GameLoop.SaveLoaded += this.GameLoop_SaveLoaded; events.Specialized.LoadStageChanged += this.Specialized_LoadStageChanged; events.GameLoop.ReturnedToTitle += this.GameLoop_ReturnedToTitle; events.GameLoop.DayEnding += this.GameLoop_DayEnding; events.GameLoop.DayStarted += this.GameLoop_DayStarted; events.GameLoop.GameLaunched += this.GameLoop_GameLaunched; events.GameLoop.UpdateTicked += this.GameLoop_UpdateTicked; events.Display.RenderingHud += this.Display_RenderingHud;; }
private void RegisterEvents(IModEvents events) { events.GameLoop.SaveLoaded += this.GameLoop_SaveLoaded; events.GameLoop.Saving += this.GameLoop_Saving; events.GameLoop.ReturnedToTitle += this.GameLoop_ReturnedToTitle; events.GameLoop.DayEnding += this.GameLoop_DayEnding; events.GameLoop.DayStarted += this.GameLoop_DayStarted; events.GameLoop.GameLaunched += this.GameLoop_GameLaunched; events.GameLoop.UpdateTicked += this.GameLoop_UpdateTicked; events.Display.RenderingHud += this.Display_RenderingHud; events.Player.Warped += this.Player_Warped; }
public ModOptionsPage(List <ModOptionsElement> options, IModEvents events) : base(Game1.activeClickableMenu.xPositionOnScreen, Game1.activeClickableMenu.yPositionOnScreen + 10, Width, Game1.activeClickableMenu.height) { _options = options; _upArrow = new ClickableTextureComponent( new Rectangle( xPositionOnScreen + width + Game1.tileSize / 4, yPositionOnScreen + Game1.tileSize, 11 * Game1.pixelZoom, 12 * Game1.pixelZoom), Game1.mouseCursors, new Rectangle(421, 459, 11, 12), Game1.pixelZoom); _downArrow = new ClickableTextureComponent( new Rectangle( _upArrow.bounds.X, yPositionOnScreen + height - Game1.tileSize, _upArrow.bounds.Width, _upArrow.bounds.Height), Game1.mouseCursors, new Rectangle(421, 472, 11, 12), Game1.pixelZoom); _scrollBar = new ClickableTextureComponent( new Rectangle( _upArrow.bounds.X + Game1.pixelZoom * 3, _upArrow.bounds.Y + _upArrow.bounds.Height + Game1.pixelZoom, 6 * Game1.pixelZoom, 10 * Game1.pixelZoom), Game1.mouseCursors, new Rectangle(435, 463, 6, 10), Game1.pixelZoom); _scrollBarRunner = new Rectangle(_scrollBar.bounds.X, _scrollBar.bounds.Y, _scrollBar.bounds.Width, height - Game1.tileSize * 2 - _upArrow.bounds.Height - Game1.pixelZoom * 2); for (int i = 0; i < 7; ++i) { _optionSlots.Add(new ClickableComponent( new Rectangle( xPositionOnScreen + Game1.tileSize / 4, yPositionOnScreen + Game1.tileSize * 5 / 4 + Game1.pixelZoom + i * (height - Game1.tileSize * 2) / 7, width - Game1.tileSize / 2, (height - Game1.tileSize * 2) / 7 + Game1.pixelZoom), i.ToString())); } events.Display.MenuChanged += OnMenuChanged; }
public override void Entry(IModHelper helper) { events = helper.Events; open = "open".toMD5Hash(); Guid.NewGuid(); config = Helper.ReadConfig <FHConfig>(); helper.Events.GameLoop.DayStarted += StartFarmHubServer; // new ConsoleCommand("menu", "Lists the available servers", (s, p) => Game1.activeClickableMenu = new FarmHubMenu(Game1.game1,Helper)).register(); new ConsoleCommand("farmhub", "Lists the available servers", (s, p) => populateList(writeListToConsole)).register(); new ConsoleCommand("join", "Join a server by name. Name and password have to use _ instead of spaces. Usage: join [name] [password if required]", (s, p) => populateList((l) => findServer(l, p))).register(); }
/********* ** Protected methods *********/ /**** ** Implementation ****/ /// <summary>Construct an instance.</summary> /// <param name="events">The SMAPI events available for mods.</param> /// <param name="inputHelper">An API for checking and changing input state.</param> /// <param name="keepAlive">Indicates whether to keep the overlay active. If <c>null</c>, the overlay is kept until explicitly disposed.</param> protected InterfaceHost(IModEvents events, IInputHelper inputHelper, Func <bool> keepAlive = null) { _events = events; InputHelper = inputHelper; _keepAliveCheck = keepAlive; _lastViewport = new Rectangle(Game1.viewport.X, Game1.viewport.Y, Game1.viewport.Width, Game1.viewport.Height); events.Display.RenderedActiveMenu += OnRendered; events.GameLoop.UpdateTicked += OnUpdateTicked; events.Input.ButtonPressed += OnButtonPressed; events.Input.CursorMoved += OnCursorMoved; events.Input.MouseWheelScrolled += OnMouseWheelScrolled; }
/********* ** Protected methods *********/ /**** ** Implementation ****/ /// <summary>Construct an instance.</summary> /// <param name="events">The SMAPI events available for mods.</param> /// <param name="inputHelper">An API for checking and changing input state.</param> /// <param name="keepAlive">Indicates whether to keep the overlay active. If <c>null</c>, the overlay is kept until explicitly disposed.</param> protected BaseOverlay(IModEvents events, IInputHelper inputHelper, Func <bool> keepAlive = null) { this.Events = events; this.InputHelper = inputHelper; this.KeepAliveCheck = keepAlive; this.LastViewport = new Rectangle(Game1.viewport.X, Game1.viewport.Y, Game1.viewport.Width, Game1.viewport.Height); events.Display.Rendered += this.OnRendered; events.GameLoop.UpdateTicked += this.OnUpdateTicked; events.Input.ButtonPressed += this.OnButtonPressed; events.Input.CursorMoved += this.OnCursorMoved; events.Input.MouseWheelScrolled += this.OnMouseWheelScrolled; }
internal static void init(IModEvents events) { events.GameLoop.SaveLoaded += onSaveLoaded; events.GameLoop.Saving += onSaving; events.GameLoop.Saved += onSaved; events.Display.MenuChanged += onMenuChanged; events.Player.Warped += onWarped; events.Display.RenderedHud += onRenderedHud; SpaceEvents.ShowNightEndMenus += showLevelMenu; SpaceEvents.ServerGotClient += clientJoined; Networking.RegisterMessageHandler(MSG_DATA, onDataMessage); Networking.RegisterMessageHandler(MSG_EXPERIENCE, onExpMessage); }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="events">The SMAPI events available for mods.</param> /// <param name="inputHelper">An API for checking and changing input state.</param> /// <param name="reflection">Simplifies access to private code.</param> /// <param name="machineGroups">The machine groups to display.</param> public OverlayMenu(IModEvents events, IInputHelper inputHelper, IReflectionHelper reflection, IEnumerable <MachineGroup> machineGroups) : base(events, inputHelper, reflection) { // init machine groups machineGroups = machineGroups.ToArray(); this.GroupTiles = ( from machineGroup in machineGroups from tile in machineGroup.Tiles select new { tile, machineGroup } ) .ToDictionary(p => p.tile, p => p.machineGroup); }
private void RegisterEvents(IModEvents events) { events.GameLoop.Saving += this.OnSaving; events.GameLoop.Saved += this.OnSaved; events.GameLoop.SaveLoaded += this.OnSaveLoaded; events.GameLoop.ReturnedToTitle += this.OnReturnedToTitle; events.GameLoop.DayStarted += this.OnDayStarted; events.GameLoop.TimeChanged += this.OnTimeChanged; events.GameLoop.UpdateTicked += this.OnUpdateTicked; events.GameLoop.GameLaunched += this.OnGameLaunched; events.Display.Rendered += this.OnRendered; events.Multiplayer.ModMessageReceived += this.OnModMessageReceived; }
public ModOptionsPageButton(IModEvents events) { //_optionsPageHandler = optionsPageHandler; width = 64; height = 64; GameMenu activeClickableMenu = Game1.activeClickableMenu as GameMenu; xPositionOnScreen = activeClickableMenu.xPositionOnScreen + activeClickableMenu.width - 200; yPositionOnScreen = activeClickableMenu.yPositionOnScreen + 16; Bounds = new Rectangle(xPositionOnScreen, yPositionOnScreen, width, height); events.Input.ButtonPressed += OnButtonPressed; events.Display.MenuChanged += OnMenuChanged; }
public QuestLogWatchdog(IModEvents modEvents, EventManager eventManager, StatsManager statsManager, IMonitor monitor) { this.EventManager = eventManager; this.StatsManager = statsManager; this.Monitor = monitor; // QuestLog reference only for andoroid, // other platform uses ElementChanged event on NetObjectList if (Constants.TargetPlatform == GamePlatform.Android) { modEvents.GameLoop.UpdateTicked += this.OnUpdateTicked; modEvents.GameLoop.ReturnedToTitle += this.OnReturnedToTitle; } }
public ForageController(AI_StateMachine ai, IModEvents events) { this.ai = ai; this.ignoreList = new List <TerrainFeature>(); this.pathFinder = new PathFinder(this.Forager.currentLocation, this.Forager, this.ai.player); this.joystick = new NpcMovementController(this.Forager, this.pathFinder); this.joystick.EndOfRouteReached += this.Joystick_EndOfRouteReached; this.ai.LocationChanged += this.Ai_LocationChanged; this.r = new Random((int)Game1.uniqueIDForThisGame + (int)Game1.stats.DaysPlayed); this.foragedObjects = new Stack <Item>(); this.forages = this.LoadForages(); events.GameLoop.TimeChanged += this.GameLoop_TimeChanged; }
public ModHelper(IModLogger logger, IModConsole console, IHarmonyHelper harmonyHelper, IModEvents events, IModAssets assets, IModStorage storage, IModMenus menus, IModManifest manifest, IModConfig config, IOwmlConfig owmlConfig, IModInteraction interaction) { Logger = logger; Console = console; HarmonyHelper = harmonyHelper; Events = events; Assets = assets; Storage = storage; Menus = menus; Manifest = manifest; Config = config; OwmlConfig = owmlConfig; Interaction = interaction; }
//internal static ITranslationHelper Translation; // internal static IMonitor Logger; public override void Entry(IModHelper helper) { ModHelper = helper; Events = helper.Events; Reflection = helper.Reflection; Config = helper.ReadConfig <ModConfig>(); SkullElevator.Setup(); LadderFinder.Setup(); EasyHorse.Setup(); DontAskToEat.Setup(); }
public ModMenus(IModConsole console, IModEvents events, IModInputHandler inputHandler, IModManifest owmlManifest, IOwmlConfig owmlConfig, IOwmlConfig owmlDefaultConfig) { MainMenu = new ModMainMenu(console); PauseMenu = new ModPauseMenu(console); ModsMenu = new ModsMenu(console, this, inputHandler); OwmlMenu = new OwmlConfigMenu(console, owmlManifest, owmlConfig, owmlDefaultConfig); InputMenu = new ModInputMenu(console); InputCombinationElementMenu = new ModInputCombinationElementMenu(console, inputHandler); InputCombinationMenu = new ModInputCombinationMenu(console); events.Subscribe <SettingsManager>(Common.Events.AfterStart); events.Subscribe <TitleScreenManager>(Common.Events.AfterStart); events.OnEvent += OnEvent; }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="events">The SMAPI events available for mods.</param> /// <param name="inputHelper">An API for checking and changing input state.</param> /// <param name="layers">The data layers to render.</param> /// <param name="drawOverlay">Get whether the overlay should be drawn.</param> /// <param name="combineOverlappingBorders">When two groups of the same color overlap, draw one border around their edges instead of their individual borders.</param> public DataLayerOverlay(IModEvents events, IInputHelper inputHelper, ILayer[] layers, Func <bool> drawOverlay, bool combineOverlappingBorders) : base(events, inputHelper) { if (!layers.Any()) { throw new InvalidOperationException("Can't initialise the data layers overlay with no data layers."); } this.Layers = layers.OrderBy(p => p.Name).ToArray(); this.DrawOverlay = drawOverlay; this.LegendColorSize = (int)Game1.smallFont.MeasureString("X").Y; this.BoxContentWidth = this.GetMaxContentWidth(this.Layers, this.LegendColorSize); this.CombineOverlappingBorders = combineOverlappingBorders; this.SetLayer(this.Layers.First()); }
public MuseumInteractionDialogService() { gunther = Game1.getCharacterFromName(StardewMods.Common.StardewValley.Constants.NPC_GUNTHER_NAME); if (gunther == null) { ModEntry.CommonServices.Monitor.Log("Error: NPC [Gunther] not found!", LogLevel.Error); throw new Exception("Error: NPC [Gunther] not found!"); } translationHelper = ModEntry.CommonServices.TranslationHelper; monitor = ModEntry.CommonServices.Monitor; events = ModEntry.CommonServices.Events; running = false; }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="events">The SMAPI events available for mods.</param> /// <param name="inputHelper">An API for checking and changing input state.</param> /// <param name="reflection">Simplifies access to private code.</param> /// <param name="layers">The data layers to render.</param> /// <param name="drawOverlay">Get whether the overlay should be drawn.</param> /// <param name="combineOverlappingBorders">When two groups of the same color overlap, draw one border around their edges instead of their individual borders.</param> /// <param name="showGrid">Whether to show a tile grid when a layer is open.</param> public DataLayerOverlay(IModEvents events, IInputHelper inputHelper, IReflectionHelper reflection, ILayer[] layers, Func <bool> drawOverlay, bool combineOverlappingBorders, bool showGrid) : base(events, inputHelper, reflection) { if (!layers.Any()) { throw new InvalidOperationException("Can't initialize the data layers overlay with no data layers."); } this.Layers = layers.OrderBy(p => p.Name).ToArray(); this.DrawOverlay = drawOverlay; this.CombineOverlappingBorders = combineOverlappingBorders; this.ShowGrid = showGrid; this.SetLayer(this.Layers.First()); }