/// <summary>Raised after the game state is updated (≈60 times per second).</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnUpdateTicked(object sender, UpdateTickedEventArgs e) { this.EnforceSerializer(); if (!Context.IsWorldReady) { return; } if (Game1.player.CurrentItem == null && this.PrevItem != null || Game1.player.CurrentItem != null && !Game1.player.CurrentItem.Equals(this.PrevItem)) { ItemEvents.FireActiveItemChanged(new EventArgsActiveItemChanged(this.PrevItem, Game1.player.CurrentItem)); this.PrevItem = Game1.player.CurrentItem; } IModHelperExtensions.PlayerModifierHelper.UpdateTick(); if (Context.IsPlayerFree) { Vector2 playerPos = new Vector2(Game1.player.getStandingX() / Game1.tileSize, Game1.player.getStandingY() / Game1.tileSize); if (EntoaroxFrameworkMod.LastTouchAction != playerPos) { string text = Game1.currentLocation.doesTileHaveProperty((int)playerPos.X, (int)playerPos.Y, "TouchAction", "Back"); EntoaroxFrameworkMod.LastTouchAction = playerPos; if (text != null) { string[] split = text.Split(' '); string[] args = new string[split.Length - 1]; Array.Copy(split, 1, args, 0, args.Length); this.ActionInfo = new EventArgsActionTriggered(Game1.player, split[0], args, playerPos); MoreEvents.FireTouchActionTriggered(this.ActionInfo); } } } }
private void GameEvents_UpdateTick(object s, EventArgs e) { EnforceSerializer(); if (!Context.IsWorldReady) { return; } if ((Game1.player.CurrentItem == null && this.prevItem != null) || (Game1.player.CurrentItem != null && !Game1.player.CurrentItem.Equals(this.prevItem))) { ItemEvents.FireActiveItemChanged(new EventArgsActiveItemChanged(this.prevItem, Game1.player.CurrentItem)); this.prevItem = Game1.player.CurrentItem; } PlayerModifierHelper._UpdateModifiers(); Vector2 playerPos = new Vector2(Game1.player.getStandingX() / Game1.tileSize, Game1.player.getStandingY() / Game1.tileSize); if (LastTouchAction == playerPos) { return; } string text = Game1.currentLocation.doesTileHaveProperty((int)playerPos.X, (int)playerPos.Y, "TouchAction", "Back"); LastTouchAction = playerPos; if (text == null) { return; } string[] split = (text).Split(' '); string[] args = new string[split.Length - 1]; Array.Copy(split, 1, args, 0, args.Length); this.ActionInfo = new EventArgsActionTriggered(Game1.player, split[0], args, playerPos); MoreEvents.FireTouchActionTriggered(this.ActionInfo); }
private void ControlEvents_ControllerButtonReleased(object sender, EventArgsControllerButtonReleased e) { if (this.ActionInfo != null && e.ButtonReleased == Buttons.A) { MoreEvents.FireActionTriggered(this.ActionInfo); this.ActionInfo = null; } }
/// <summary>Raised after the player releases a button on the keyboard, controller, or mouse.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnButtonReleased(object sender, ButtonReleasedEventArgs e) { if (this.ActionInfo != null && (e.Button == SButton.ControllerA || e.Button == SButton.MouseRight)) { MoreEvents.FireActionTriggered(this.ActionInfo); this.ActionInfo = null; } }
private void ControlEvents_ControllerButtonReleased(object sender, EventArgsControllerButtonReleased e) { if (this.ActionInfo == null || e.ButtonReleased != Buttons.A) { return; } MoreEvents.FireActionTriggered(this.ActionInfo); this.ActionInfo = null; }
private void ControlEvents_MouseChanged(object sender, EventArgsMouseStateChanged e) { if (e.NewState.RightButton == ButtonState.Pressed && e.PriorState.RightButton != ButtonState.Pressed) { CheckForAction(); } if (this.ActionInfo != null && e.NewState.RightButton == ButtonState.Released) { MoreEvents.FireActionTriggered(this.ActionInfo); this.ActionInfo = null; } }
/********* ** Protected methods *********/ /// <summary>Raised after the player releases a button on the keyboard, controller, or mouse.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnButtonReleased(object sender, ButtonReleasedEventArgs e) { if (e.Button.IsActionButton() && Game1.activeClickableMenu == null && !Game1.player.UsingTool && !Game1.pickingTool && !Game1.menuUp && (!Game1.eventUp || Game1.currentLocation.currentEvent.playerControlSequence) && !Game1.nameSelectUp && Game1.numberOfSelectedItems == -1 && !Game1.fadeToBlack) { this.ActionInfo = null; Vector2 grabTile = new Vector2(Game1.getOldMouseX() + Game1.viewport.X, Game1.getOldMouseY() + Game1.viewport.Y) / Game1.tileSize; if (!Utility.tileWithinRadiusOfPlayer((int)grabTile.X, (int)grabTile.Y, 1, Game1.player)) { grabTile = Game1.player.GetGrabTile(); } Tile tile = Game1.currentLocation.map.GetLayer("Buildings").PickTile(new Location((int)grabTile.X * Game1.tileSize, (int)grabTile.Y * Game1.tileSize), Game1.viewport.Size); PropertyValue propertyValue = null; tile?.Properties.TryGetValue("Action", out propertyValue); if (propertyValue != null) { string[] split = ((string)propertyValue).Split(' '); string[] args = new string[split.Length - 1]; Array.Copy(split, 1, args, 0, args.Length); MoreEvents.FireActionTriggered(new EventArgsActionTriggered(Game1.player, split[0], args, grabTile)); } } }