/// <summary>Wraps the the method so it only executes if this button is pressed and adds it to <see cref="IInputEvents.ButtonPressed"/>.</summary> /// <returns>Returns the wrapped method.</returns> public static EventHandler <ButtonPressedEventArgs> onClick(this ButtonClick t, Action <ButtonPressedEventArgs> handler) { EventHandler <ButtonPressedEventArgs> d = delegate(object sender, ButtonPressedEventArgs e) { bool isButton = t.Equals(ButtonClick.UseToolButton) ? e.Button.IsUseToolButton() : e.Button.IsActionButton(); if (isButton) { handler.Invoke(e); } }; PyEvents.Events.Input.ButtonPressed += d; return(d); }
/// <summary>Wraps the the method so it only executes if the player clicks on the specified tile and adds it to <see cref="IInputEvents.ButtonPressed"/>.</summary> /// <returns>Returns the wrapped method.</returns> public static EventHandler <ButtonPressedEventArgs> onClick(this ButtonClick t, Vector2 tile, GameLocation location, Action <Vector2> handler) { EventHandler <ButtonPressedEventArgs> d = delegate(object sender, ButtonPressedEventArgs e) { bool isButton = t.Equals(ButtonClick.UseToolButton) ? e.Button.IsUseToolButton() : e.Button.IsActionButton(); if (isButton && Game1.currentLocation == location && location.getTileAtMousePosition() == tile) { handler.Invoke(location.getTileAtMousePosition()); } }; PyEvents.Events.Input.ButtonPressed += d; return(d); }
/// <summary>Wraps the the method so it only executes if an object of the requested type is clicked on and adds it to <see cref="IInputEvents.ButtonPressed"/>.</summary> /// <returns>Returns the wrapped method.</returns> public static EventHandler <ButtonPressedEventArgs> onFurnitureClick <T>(this ButtonClick t, Action <T> handler) where T : Furniture { EventHandler <ButtonPressedEventArgs> d = delegate(object sender, ButtonPressedEventArgs e) { bool isButton = t.Equals(ButtonClick.UseToolButton) ? e.Button.IsUseToolButton() : e.Button.IsActionButton(); if (isButton && Game1.currentLocation is GameLocation location && location.getTileAtMousePosition().furnitureOnMap <T>() is T obj) { handler.Invoke(obj); } }; PyEvents.Events.Input.ButtonPressed += d; return(d); }
/// <summary>Wraps the the method so it only executes if this button is pressed and adds it to InputEvents.ButtonPressed.</summary> /// <returns>Returns the wrapped method.</returns> public static EventHandler <EventArgsInput> onClick(this ButtonClick t, Action <EventArgsInput> handler) { EventHandler <EventArgsInput> d = delegate(object sender, EventArgsInput e) { bool isButton = t.Equals(ButtonClick.UseToolButton) ? e.IsUseToolButton : e.IsActionButton; if (isButton) { handler.Invoke(e); } }; InputEvents.ButtonPressed += d; return(d); }
/// <summary>Wraps the the method so it only executes if an object of the requested type is clicked on and adds it to InputEvents.ButtonPressed.</summary> /// <returns>Returns the wrapped method.</returns> public static EventHandler <EventArgsInput> onTerrainClick <T>(this ButtonClick t, EventHandler <T> handler) where T : TerrainFeature { EventHandler <EventArgsInput> d = delegate(object sender, EventArgsInput e) { bool isButton = t.Equals(ButtonClick.UseToolButton) ? e.IsUseToolButton : e.IsActionButton; if (isButton && Game1.currentLocation is GameLocation location && location.getTileAtMousePosition().terrainOnMap <T>() is T obj) { handler.Invoke(sender, obj); } }; InputEvents.ButtonPressed += d; return(d); }
/// <summary>Wraps the the method so it only executes if the player clickes on the specified tileposition and adds it to InputEvents.ButtonPressed.</summary> /// <returns>Returns the wrapped method.</returns> public static EventHandler <EventArgsInput> onClick(this ButtonClick t, TileLocationSelector tile, Action <Vector2> handler) { EventHandler <EventArgsInput> d = delegate(object sender, EventArgsInput e) { bool isButton = t.Equals(ButtonClick.UseToolButton) ? e.IsUseToolButton : e.IsActionButton; if (isButton && Game1.currentLocation is GameLocation location && tile.predicate(location, location.getTileAtMousePosition())) { handler.Invoke(location.getTileAtMousePosition()); } }; InputEvents.ButtonPressed += d; return(d); }
/// <summary>Wraps the the method so it only executes if the player clicks on the screen area and adds it to <see cref="IInputEvents.ButtonPressed"/>.</summary> /// <returns>Returns the wrapped method.</returns> public static EventHandler <ButtonPressedEventArgs> onClick(this ButtonClick t, Rectangle area, Action <Point> handler) { EventHandler <ButtonPressedEventArgs> d = delegate(object sender, ButtonPressedEventArgs e) { bool isButton = t.Equals(ButtonClick.UseToolButton) ? e.Button.IsUseToolButton() : e.Button.IsActionButton(); Point mousePosition = Game1.getMousePosition(); if (isButton && area.Contains(mousePosition)) { handler.Invoke(mousePosition); } }; PyEvents.Events.Input.ButtonPressed += d; return(d); }
/// <summary>Wraps the the method so it only executes if the player clicks on the screen position and adds it to InputEvents.ButtonPressed.</summary> /// <returns>Returns the wrapped method.</returns> public static EventHandler <EventArgsInput> onClick(this ButtonClick t, Point position, Action <Point> handler) { EventHandler <EventArgsInput> d = delegate(object sender, EventArgsInput e) { bool isButton = t.Equals(ButtonClick.UseToolButton) ? e.IsUseToolButton : e.IsActionButton; Point mousePosition = Game1.getMousePosition(); if (isButton && mousePosition == position) { handler.Invoke(position); } }; InputEvents.ButtonPressed += d; return(d); }