/// <summary>Open the customisation menu if the player activated the dresser.</summary> private void CheckForAction() { if (Game1.player.UsingTool || Game1.pickingTool || Game1.menuUp || (Game1.eventUp && !Game1.currentLocation.currentEvent.playerControlSequence) || Game1.nameSelectUp || Game1.numberOfSelectedItems != -1 || Game1.fadeToBlack || Game1.activeClickableMenu != null) { return; } // get the activated tile 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(); } // check tile action xTile.Tiles.Tile tile = Game1.currentLocation.map.GetLayer("Buildings").PickTile(new xTile.Dimensions.Location((int)grabTile.X * Game1.tileSize, (int)grabTile.Y * Game1.tileSize), Game1.viewport.Size); xTile.ObjectModel.PropertyValue propertyValue = null; tile?.Properties.TryGetValue("Action", out propertyValue); if (propertyValue?.ToString() != "GetDressed") { return; } // open menu Game1.playSound("bigDeSelect"); Game1.activeClickableMenu = new CharacterCustomizationMenu(this.ContentHelper, this.Helper, this.ModManifest.Version, this.GlobalConfig, this.PlayerConfig, Game1.options.zoomLevel); }
private void CheckAction(object sender, EventArgsInput e) { if (Context.IsPlayerFree && e.IsActionButton) { Vector2 grabTile = new Vector2((float)(Game1.getOldMouseX() + Game1.viewport.X), (float)(Game1.getOldMouseY() + Game1.viewport.Y)) / (float)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 xTile.Dimensions.Location((int)grabTile.X * Game1.tileSize, (int)grabTile.Y * Game1.tileSize), Game1.viewport.Size); xTile.ObjectModel.PropertyValue propertyValue = null; if (tile != null) { tile.Properties.TryGetValue("Action", out propertyValue); } if (propertyValue != null) { if (propertyValue == "TokenMachine") { Response basic = new Response("Basic", $"Basic Tier ({Config.basicBoxCost} Tokens)"); Response premium = new Response("Premium", $"Premium Tier ({Config.premiumBoxCost} Tokens)"); Response cancel = new Response("Cancel", "Cancel"); Response[] answers = { basic, premium, cancel, }; Game1.player.currentLocation.createQuestionDialogue($"Would you like to spend your tokens to receive a random item? You currently have {totalTokens} tokens.", answers, AfterQuestion, null); } } } }
/// <summary> /// Checks the given action. Currently does not work as Game2.getHook() does not work. /// </summary> /// <param name="tileLocation">Tile location to check action on.</param> /// <param name="viewport">Current viewport</param> /// <param name="who">Which Farmer</param> /// <returns>true if checkaction works correctly.</returns> public override bool checkAction(Location tileLocation, Rectangle viewport, Farmer who) { if (Game1.player.houseUpgradeLevel > 2) { if (mod != null) { mod.Monitor.Log("Successfully intercepted checkAction.", LogLevel.Debug); } // @TODO: Fix Game2.getHook() return(Game2.getHook().OnGameLocation_CheckAction(this, tileLocation, viewport, who, delegate { if (who.IsLocalPlayer && who.currentUpgrade != null && name.Equals("Farm") && tileLocation.Equals(new Location((int)(who.currentUpgrade.positionOfCarpenter.X + 32f) / 64, (int)(who.currentUpgrade.positionOfCarpenter.Y + 32f) / 64))) { if (who.currentUpgrade.daysLeftTillUpgradeDone == 1) { Game1.drawDialogue(Game1.getCharacterFromName("Robin", false), Game1.content.LoadString("Data\\ExtraDialogue:Farm_RobinWorking_ReadyTomorrow")); } else { Game1.drawDialogue(Game1.getCharacterFromName("Robin", false), Game1.content.LoadString("Data\\ExtraDialogue:Farm_RobinWorking" + (Game1.random.Next(2) + 1))); } } Microsoft.Xna.Framework.Vector2 vector = new Microsoft.Xna.Framework.Vector2((float)tileLocation.X, (float)tileLocation.Y); xTile.ObjectModel.PropertyValue propertyValue = null; xTile.Tiles.Tile tile = map.GetLayer("Buildings").PickTile(new Location(tileLocation.X * 64, tileLocation.Y * 64), viewport.Size); tile?.Properties.TryGetValue("Action", out propertyValue); if (propertyValue != null && (currentEvent != null || isCharacterAtTile(vector + new Microsoft.Xna.Framework.Vector2(0f, 1f)) == null)) { return this.performAction(propertyValue, who, tileLocation); } return false; })); } return(base.checkAction(tileLocation, viewport, who)); }
/// <summary>Check if the dresser is in the location.</summary> /// <param name="pos">The tile location.</param> public bool IsDresser(Vector2 pos) { xTile.Tiles.Tile tile = Game1.currentLocation.map.GetLayer("Buildings").PickTile(new xTile.Dimensions.Location((int)pos.X * Game1.tileSize, (int)pos.Y * Game1.tileSize), Game1.viewport.Size); xTile.ObjectModel.PropertyValue propertyValue = null; tile?.Properties.TryGetValue("Action", out propertyValue); if (propertyValue?.ToString() != "Kisekae") { return(false); } return(true); }
/********* ** Private methods *********/ /// <summary>Open the customisation menu if the player activated the dresser.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event data.</param> private void Events_ButtonPressed(object sender, ButtonPressedEventArgs e) { if (!m_isLoaded) { return; } // check if current input activate the dresser if (e.Button.IsActionButton()) { if (Game1.player.UsingTool || Game1.pickingTool || Game1.menuUp || (Game1.eventUp && !Game1.currentLocation.currentEvent.playerControlSequence) || Game1.nameSelectUp || Game1.numberOfSelectedItems != -1 || Game1.fadeToBlack || Game1.activeClickableMenu != null) { return; } // check if the activated tile is the Dresser or Wizard Shrine 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(); } xTile.ObjectModel.PropertyValue propertyValue = null; Game1.currentLocation.map.GetLayer("Buildings").PickTile(new xTile.Dimensions.Location((int)grabTile.X * 64, (int)grabTile.Y * 64), Game1.viewport.Size)?.Properties.TryGetValue("Action", out propertyValue); if ((propertyValue != null && propertyValue == "WizardShrine")) { Game1.currentLocation.afterQuestion = Answer_WizardShrine; Game1.currentLocation.createQuestionDialogue(Game1.content.LoadString("Strings\\Locations:WizardTower_WizardShrine").Replace('\n', '^'), Game1.currentLocation.createYesNoResponses(), "WizardShrine"); this.Helper.Input.Suppress(e.Button); return; } if (!m_dresser.IsDresser(grabTile)) { return; } } else if (m_globalConfig.MenuAccessKey != SButton.None && e.Button == m_globalConfig.MenuAccessKey && Game1.activeClickableMenu == null) { } else { return; } // open menu Game1.playSound("bigDeSelect"); OpenMenu(); //e.SuppressButton(); this.Helper.Input.Suppress(e.Button); }
public static bool IsTilePassable(xTile.Dimensions.Location tileLocation, xTile.Dimensions.Rectangle viewport, GameLocation location) { xTile.ObjectModel.PropertyValue propertyValue = (xTile.ObjectModel.PropertyValue)null; Tile tile1 = location.map.GetLayer("Back").PickTile(new xTile.Dimensions.Location(tileLocation.X * 64, tileLocation.Y * 64), viewport.Size); tile1?.TileIndexProperties.TryGetValue("Passable", out propertyValue); Tile tile2 = location.map.GetLayer("Buildings").PickTile(new xTile.Dimensions.Location(tileLocation.X * 64, tileLocation.Y * 64), viewport.Size); if (propertyValue == null && tile2 == null) { return(tile1 != null); } return(false); }
//Slightly modified default game code, necessary for having control over the placement rules for rugs internal bool isTilePassableForRugs(FarmHouse house, xTile.Dimensions.Location tileLocation, xTile.Dimensions.Rectangle viewport) { xTile.ObjectModel.PropertyValue propertyValue = (xTile.ObjectModel.PropertyValue)null; xTile.Tiles.Tile tile1 = house.map.GetLayer("Back").PickTile(tileLocation, viewport.Size); if (tile1 != null) { tile1.TileIndexProperties.TryGetValue("Passable", out propertyValue); } xTile.Tiles.Tile tile2 = house.map.GetLayer("Buildings").PickTile(tileLocation, viewport.Size); if (propertyValue == null && tile2 == null) { return(tile1 != null); } return(false); }
public bool isTilePassableOverride(Location tileLocation, xTile.Dimensions.Rectangle viewport) { xTile.ObjectModel.PropertyValue passable = null; xTile.Tiles.Tile tmp = gameLocation.map.GetLayer("Back").PickTile(new Location(tileLocation.X * Game1.tileSize, tileLocation.Y * Game1.tileSize), viewport.Size); if (tmp != null) { tmp.TileIndexProperties.TryGetValue("Passable", out passable); } xTile.ObjectModel.PropertyValue passableBuilding = null; xTile.Tiles.Tile tile = gameLocation.map.GetLayer("Buildings").PickTile(new Location(tileLocation.X * Game1.tileSize, tileLocation.Y * Game1.tileSize), viewport.Size); if (tile != null) { passableBuilding = tile.TileIndexProperties.TryGetValue("Passable", out passableBuilding); } return(passable == null && (tile == null || (passableBuilding != null && passableBuilding)) && tmp != null); }
internal static void React(StardewValley.Farmer who, string[] arguments, Vector2 tile) { int interval = Convert.ToInt32(arguments[0]); int[] indexes = arguments[1].Split(',').Select(e => Convert.ToInt32(e)).ToArray(); var layer = who.currentLocation.Map.GetLayer("Buildings"); var source = layer.Tiles[(int)tile.X, (int)tile.Y]; xTile.ObjectModel.PropertyValue property = EntoFramework.GetLocationHelper().GetTileProperty(who.currentLocation, "Buildings", (int)tile.X, (int)tile.Y, "Action"); int delay = interval * indexes.Length; EntoFramework.GetLocationHelper().SetAnimatedTile(who.currentLocation, "Buildings", (int)tile.X, (int)tile.Y, indexes, interval, source.TileSheet.Id); System.Threading.Timer timer = null; timer = new System.Threading.Timer((obj) => { EntoFramework.GetLocationHelper().SetStaticTile(who.currentLocation, "Buildings", (int)tile.X, (int)tile.Y, source.TileIndex, source.TileSheet.Id); EntoFramework.GetLocationHelper().SetTileProperty(who.currentLocation, "Buildings", (int)tile.X, (int)tile.Y, "Action", property); timer.Dispose(); }, null, delay, System.Threading.Timeout.Infinite); }
public static bool Prefix(GameTime time, xTile.Dimensions.Rectangle viewport, GameLocation currentLocation, Farmer __instance) { try { Layer slope = currentLocation.map.GetLayer("Slope" + Pseudo3D.LevelHandler.getLevelSuffixForCharacter(__instance)); if (slope != null && slope.Tiles[__instance.getTileX(), __instance.getTileY()] != null) { SlopeHandler.modifyVelocity(__instance, slope.Tiles[__instance.getTileX(), __instance.getTileY()]); } } catch (NullReferenceException) { } string currentLevel = Pseudo3D.LevelHandler.getLevelForCharacter(__instance); string backLayer = "Back" + Pseudo3D.LevelHandler.getLevelSuffixForCharacter(__instance); if (currentLocation.map.GetLayer(backLayer).Tiles[__instance.getTileX(), __instance.getTileY()] != null) { xTile.Tiles.Tile currentTile = currentLocation.map.GetLayer(backLayer).Tiles[__instance.getTileX(), __instance.getTileY()]; if (currentTile.Properties.ContainsKey("Level")) { Logger.log("Checking level..."); xTile.ObjectModel.PropertyValue layerSwitch = currentLocation.map.GetLayer(backLayer).Tiles[__instance.getTileX(), __instance.getTileY()].Properties["Level"]; string layer = layerSwitch.ToString(); if (layer.Equals("0")) { layer = "Base"; } if (!currentLevel.Equals(layer)) { Logger.log("Applying level " + layer + "..."); //Pseudo3D.MapHandler.setPassableTiles(currentLocation, layer); Pseudo3D.LevelHandler.setLevelForCharacter(__instance, layer); } } } //Logger.log("Colliding position? " + currentLocation.isCollidingPosition(__instance.nextPosition(__instance.facingDirection), viewport, true, 0, false, (Character)__instance).ToString()); return(true); }
/********* ** Private methods *********/ /// <summary>The method to call after <see cref="Farmer.moveRaft"/>.</summary> public static void After_MoveRaft(Farmer __instance, GameLocation currentLocation, GameTime time) { __instance.position.X += __instance.xVelocity; __instance.position.Y += __instance.yVelocity; Rectangle r = new Rectangle((int)(__instance.Position.X), (int)(__instance.Position.Y + 16), 64, 64); // 2 - down, 0 - up, 3 - left, 1 - right //Log.trace( "meow: " + ( __instance.movementDirections.Count > 0 ?__instance.movementDirections[0]:-1)); if (__instance.movementDirections.Contains(2) || __instance.movementDirections.Contains(0)) { Vector2 pos = new Vector2(r.X + r.Width / 2, r.Y + r.Height); var xPos = new xTile.Dimensions.Location((int)pos.X, (int)pos.Y); xTile.ObjectModel.PropertyValue propVal = null; currentLocation.map.GetLayer("Back").PickTile(xPos, Game1.viewport.Size)?.TileIndexProperties.TryGetValue("Water", out propVal); if (propVal == null) { if (currentLocation.isTileLocationOpen(xPos)) { Game1.player.isRafting = false; Game1.player.Position = pos; //Game1.player.position.Y -= 64 + 16; Game1.player.setTrajectory(0, 0); } return; } pos = new Vector2(r.X + r.Width / 2, r.Y); xPos = new xTile.Dimensions.Location((int)pos.X, (int)pos.Y); propVal = null; currentLocation.map.GetLayer("Back").PickTile(xPos, Game1.viewport.Size)?.TileIndexProperties.TryGetValue("Water", out propVal); if (propVal == null) { if (currentLocation.isTileLocationOpen(xPos)) { Game1.player.isRafting = false; Game1.player.Position = pos; Game1.player.position.Y -= 64 + 16; Game1.player.setTrajectory(0, 0); } return; } } if (__instance.movementDirections.Contains(3)) { Vector2 pos = new Vector2(r.X, r.Y + r.Height / 2); var xPos = new xTile.Dimensions.Location((int)pos.X, (int)pos.Y); xTile.ObjectModel.PropertyValue propVal = null; currentLocation.map.GetLayer("Back").PickTile(xPos, Game1.viewport.Size)?.TileIndexProperties.TryGetValue("Water", out propVal); if (propVal == null) { if (currentLocation.isTileLocationOpen(xPos)) { Game1.player.isRafting = false; Game1.player.Position = pos; Game1.player.position.Y -= 64 + 16; Game1.player.setTrajectory(0, 0); } return; } pos = new Vector2(r.X + r.Width, r.Y + r.Height / 2); xPos = new xTile.Dimensions.Location((int)pos.X, (int)pos.Y); propVal = null; currentLocation.map.GetLayer("Back").PickTile(xPos, Game1.viewport.Size)?.TileIndexProperties.TryGetValue("Water", out propVal); if (propVal == null) { if (currentLocation.isTileLocationOpen(xPos)) { Game1.player.isRafting = false; Game1.player.Position = pos; Game1.player.position.Y -= 64 + 16; Game1.player.setTrajectory(0, 0); } return; } } }