public void Customizable() { using (Many<FarmersMarket>.ToMany<Farmer>.Setup().Connect( m => m.Vendors, EnsureContains, EnsureContainsNot, f => f.Outlets, EnsureContains, EnsureContainsNot)) { var farmer1 = new Farmer(); var market1 = new FarmersMarket(); farmer1.Outlets.Count.Should().Be(0); market1.Vendors.Count.Should().Be(0); farmer1.Outlets.Add(market1); farmer1.Outlets.Count.Should().Be(1); market1.Vendors.Count.Should().Be(1); var farmer2 = new Farmer(); var market2 = new FarmersMarket(); farmer2.Outlets.Count.Should().Be(0); market2.Vendors.Count.Should().Be(0); farmer1.Outlets.Count.Should().Be(1); market1.Vendors.Count.Should().Be(1); market2.Vendors.Add(farmer2); farmer2.Outlets.Count.Should().Be(1); market2.Vendors.Count.Should().Be(1); farmer1.Outlets.Count.Should().Be(1); market1.Vendors.Count.Should().Be(1); market2.Vendors.Add(farmer1); farmer2.Outlets.Count.Should().Be(1); market2.Vendors.Count.Should().Be(2); farmer1.Outlets.Count.Should().Be(2); market1.Vendors.Count.Should().Be(1); market2.Vendors.Remove(farmer1); farmer2.Outlets.Count.Should().Be(1); market2.Vendors.Count.Should().Be(1); farmer1.Outlets.Count.Should().Be(1); market1.Vendors.Count.Should().Be(1); farmer2.Outlets.Remove(market2); farmer2.Outlets.Count.Should().Be(0); market2.Vendors.Count.Should().Be(0); farmer1.Outlets.Count.Should().Be(1); market1.Vendors.Count.Should().Be(1); } }
public Form1() { InitializeComponent(); farmer = new Farmer(15, 30); UpdateLabel(); }
public static CompanionBuff InitializeBuffFromCompanionName(string companionName, Farmer farmer, CompanionsManager cm) { NPC n = Game1.getCharacterFromName(companionName); CompanionBuff companionBuff; switch (companionName) { case "Abigail": companionBuff = new Buffs.AbigailBuff(farmer, n, cm); break; case "Alex": companionBuff = new Buffs.AlexBuff(farmer, n, cm); break; case "Elliott": companionBuff = new Buffs.ElliottBuff(farmer, n, cm); break; case "Emily": companionBuff = new Buffs.EmilyBuff(farmer, n, cm); break; case "Haley": companionBuff = new Buffs.HaleyBuff(farmer, n, cm); break; case "Harvey": companionBuff = new Buffs.HarveyBuff(farmer, n, cm); break; case "Leah": companionBuff = new Buffs.LeahBuff(farmer, n, cm); break; case "Maru": companionBuff = new Buffs.MaruBuff(farmer, n, cm); break; case "Penny": companionBuff = new Buffs.PennyBuff(farmer, n, cm); break; case "Sam": companionBuff = new Buffs.SamBuff(farmer, n, cm); break; case "Sebastian": companionBuff = new Buffs.SebastianBuff(farmer, n, cm); break; case "Shane": companionBuff = new Buffs.ShaneBuff(farmer, n, cm); break; default: companionBuff = new Buffs.AbigailBuff(farmer, n, cm); break; } companionBuff.buff.millisecondsDuration = 1200000; Game1.buffsDisplay.addOtherBuff(companionBuff.buff); companionBuff.buff.which = -420; if (companionBuff.statBuffs != null) { foreach (Buff b in companionBuff.statBuffs) { if (b != null) { b.millisecondsDuration = 1200000; Game1.buffsDisplay.addOtherBuff(b); b.which = -420; } } } return(companionBuff); }
internal static bool InvokeBeforeReceiveObject(NPC npc, StardewValley.Object obj, Farmer farmer) { Log.trace("Event: BeforeReceiveObject"); if (BeforeGiftGiven == null) { return(false); } var arg = new EventArgsBeforeReceiveObject(npc, obj); return(Util.invokeEventCancelable("SpaceEvents.BeforeReceiveObject", BeforeGiftGiven.GetInvocationList(), farmer, arg)); }
/// <summary> /// Override to ajust the original tool tip for the pot. /// </summary> /// <param name="location"></param> /// <param name="item"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="f"></param> /// <param name="__result"></param> /// <returns></returns> public static bool PlayerCanPlaceItemHere(ref GameLocation location, Item item, ref int x, ref int y, ref Farmer f, ref bool __result) { if (item != null && item is Object object1 && IsGardenPot(object1) && object1.Stack == 1) { if ((Game1.eventUp || f.bathingClothes.Value) || !Utility.withinRadiusOfPlayer(x, y, 1, f) && (!Utility.withinRadiusOfPlayer(x, y, 2, f) || !Game1.isAnyGamePadButtonBeingPressed() || (double)Game1.mouseCursorTransparency != 0.0)) { return(true); } Vector2 tileLocation = new Vector2((float)(x / 64), (float)(y / 64)); if (!(object1 is HeldIndoorPot heldPot)) { if (location.isTileHoeDirt(tileLocation) && !location.objects.ContainsKey(tileLocation)) { HoeDirt hoeDirt = location.terrainFeatures[tileLocation] as HoeDirt; if (hoeDirt.crop != null) { __result = true; return(false); } } else if (location.terrainFeatures.ContainsKey(tileLocation) && IsValidTree(location.terrainFeatures[tileLocation]) && !location.objects.ContainsKey(tileLocation)) { __result = true; return(false); } }
/// <summary>Get parsed data about the friendship between a player and NPC.</summary> /// <param name="player">The player.</param> /// <param name="pet">The pet.</param> public FriendshipModel GetFriendshipForPet(Farmer player, Pet pet) { return(this.DataParser.GetFriendshipForPet(player, pet)); }
// Token: 0x060010DA RID: 4314 RVA: 0x00158D84 File Offset: 0x00156F84 public override bool checkAction(Location tileLocation, xTile.Dimensions.Rectangle viewport, Farmer who) { if (this.map.GetLayer("Buildings").Tiles[tileLocation] != null) { int tileIndex = this.map.GetLayer("Buildings").Tiles[tileLocation].TileIndex; if (tileIndex <= 1057) { if (tileIndex != 958) { if (tileIndex != 1057) { goto IL_2B1; } if (!Game1.player.mailReceived.Contains("ccVault")) { Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\Locations:BusStop_DesertOutOfService", new object[0])); return(true); } if (Game1.player.isRidingHorse() && Game1.player.getMount() != null) { Game1.player.getMount().checkAction(Game1.player, this); goto IL_2B1; } base.createQuestionDialogue(Game1.content.LoadString("Strings\\Locations:BusStop_BuyTicketToDesert", new object[0]), base.createYesNoResponses(), "Bus"); goto IL_2B1; } } else if (tileIndex != 1080 && tileIndex != 1081) { goto IL_2B1; } if (Game1.player.getMount() != null) { return(true); } if (Game1.player.mailReceived.Contains("ccBoilerRoom")) { if (!Game1.player.isRidingHorse() || Game1.player.getMount() == null) { Response[] destinations; if (Game1.player.mailReceived.Contains("ccCraftsRoom")) { destinations = new Response[] { new Response("Mines", Game1.content.LoadString("Strings\\Locations:MineCart_Destination_Mines", new object[0])), new Response("Town", Game1.content.LoadString("Strings\\Locations:MineCart_Destination_Town", new object[0])), new Response("Quarry", Game1.content.LoadString("Strings\\Locations:MineCart_Destination_Quarry", new object[0])), new Response("Cancel", Game1.content.LoadString("Strings\\Locations:MineCart_Destination_Cancel", new object[0])) }; } else { destinations = new Response[] { new Response("Mines", Game1.content.LoadString("Strings\\Locations:MineCart_Destination_Mines", new object[0])), new Response("Town", Game1.content.LoadString("Strings\\Locations:MineCart_Destination_Town", new object[0])), new Response("Cancel", Game1.content.LoadString("Strings\\Locations:MineCart_Destination_Cancel", new object[0])) }; } base.createQuestionDialogue(Game1.content.LoadString("Strings\\Locations:MineCart_ChooseDestination", new object[0]), destinations, "Minecart"); goto IL_2B1; } Game1.player.getMount().checkAction(Game1.player, this); } else { Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\Locations:MineCart_OutOfOrder", new object[0])); } return(true); } IL_2B1: return(base.checkAction(tileLocation, viewport, who)); }
internal static void InvokeFarmerChanged(Farmer priorFarmer, Farmer newFarmer) { FarmerChanged.Invoke(null, new EventArgsFarmerChanged(priorFarmer, newFarmer)); }
public override void DoFunction(GameLocation location, int x, int y, int power, Farmer who) { this.Refresh_Tools(); Tool tool; IDictionary <string, object> properties = this.Get_Properties(x, y); string toolName = ""; int xtile = (int)x / Game1.tileSize; int ytile = (int)y / Game1.tileSize; toolName = (string)properties["string_useTool"]; if (toolName == null) { if ((bool)properties["bool_canPlant"]) { try { if (Game1.player.CurrentItem != null) { HoeDirt dirt = (HoeDirt)properties["hoedirt_dirt"]; if (Game1.player.CurrentItem.Category == StardewValley.Object.SeedsCategory) { dirt.plant(Game1.player.CurrentItem.parentSheetIndex.Get(), xtile, ytile, Game1.player, false, Game1.currentLocation); Game1.player.consumeObject(Game1.player.CurrentItem.parentSheetIndex.Get(), 1); } else if (Game1.player.CurrentItem.Category == StardewValley.Object.fertilizerCategory) { dirt.plant(Game1.player.CurrentItem.parentSheetIndex.Get(), xtile, ytile, Game1.player, true, Game1.currentLocation); Game1.player.consumeObject(Game1.player.CurrentItem.parentSheetIndex.Get(), 1); } } else { location.checkAction(new Location(xtile, ytile), Game1.viewport, Game1.player); } } catch (System.Collections.Generic.KeyNotFoundException) { Game1.addHUDMessage(new HUDMessage($"{Game1.player.CurrentItem} {Game1.player.CurrentItem.parentSheetIndex.Get()} 201")); return; } } return; } try { tool = this.attachedTools[toolName]; } catch (System.Collections.Generic.KeyNotFoundException) { if (toolName == "grab") { location.checkAction(new Location(xtile, ytile), Game1.viewport, Game1.player); } else { Game1.addHUDMessage(new HUDMessage($"{toolName} not found")); } return; } if (toolName == "melee") { //TODO this doesn't land at the right location //this.scythe.DoDamage(Game1.currentLocation, x, y, 0, power, who); return; } else { tool.DoFunction(location, x, y, power, who); return; } }
/// <summary>Apply the tool to the given tile.</summary> /// <param name="tile">The tile to modify.</param> /// <param name="tileObj">The object on the tile.</param> /// <param name="tileFeature">The feature on the tile.</param> /// <param name="player">The current player.</param> /// <param name="tool">The tool selected by the player (if any).</param> /// <param name="item">The item selected by the player (if any).</param> /// <param name="location">The current location.</param> public override bool Apply(Vector2 tile, SObject tileObj, TerrainFeature tileFeature, Farmer player, Tool tool, Item item, GameLocation location) { // spawned forage if (this.Config.HarvestForage && tileObj?.IsSpawnedObject == true) { this.CheckTileAction(location, tile, player); return(true); } // crop or spring onion (if an object like a scarecrow isn't placed on top of it) if (this.TryGetHoeDirt(tileFeature, tileObj, out HoeDirt dirt, out bool dirtCoveredByObj)) { if (dirtCoveredByObj || dirt.crop == null) { return(false); } if (this.Config.ClearDeadCrops && dirt.crop.dead.Value) { this.UseToolOnTile(new Pickaxe(), tile); // clear dead crop return(true); } bool shouldHarvest = dirt.crop.programColored.Value // from Utility.findCloseFlower ? this.Config.HarvestFlowers : this.Config.HarvestCrops; if (shouldHarvest) { if (dirt.crop.harvestMethod.Value == Crop.sickleHarvest) { return(dirt.performToolAction(tool, 0, tile, location)); } else { this.CheckTileAction(location, tile, player); } } return(true); } // machines if (this.Config.HarvestMachines && tileObj != null && tileObj.readyForHarvest.Value && tileObj.heldObject.Value != null) { tileObj.checkForAction(Game1.player); return(true); } // fruit tree if (this.Config.HarvestFruitTrees && tileFeature is FruitTree tree && tree.fruitsOnTree.Value > 0) { tree.performUseAction(tile, location); return(true); } // grass if (this.Config.HarvestGrass && tileFeature is Grass) { location.terrainFeatures.Remove(tile); if (Game1.getFarm().tryToAddHay(1) == 0) // returns number left { Game1.addHUDMessage(new HUDMessage("Hay", HUDMessage.achievement_type, true, Color.LightGoldenrodYellow, new SObject(178, 1))); } return(true); } // weeds if (this.Config.ClearWeeds && this.IsWeed(tileObj)) { this.UseToolOnTile(tool, tile); // doesn't do anything to the weed, but sets up for the tool action (e.g. sets last user) tileObj.performToolAction(tool, location); // triggers weed drops, but doesn't remove weed location.removeObject(tile, false); return(true); } // bush Rectangle tileArea = this.GetAbsoluteTileArea(tile); if (this.Config.HarvestForage && location.largeTerrainFeatures.FirstOrDefault(p => p.getBoundingBox(p.tilePosition.Value).Intersects(tileArea)) is Bush bush) { if (!bush.townBush.Value && bush.tileSheetOffset.Value == 1 && bush.inBloom(Game1.currentSeason, Game1.dayOfMonth)) { bush.performUseAction(bush.tilePosition.Value, location); return(true); } } return(false); }
/// <summary>Get whether the tool is currently enabled.</summary> /// <param name="player">The current player.</param> /// <param name="tool">The tool selected by the player (if any).</param> /// <param name="item">The item selected by the player (if any).</param> /// <param name="location">The current location.</param> public override bool IsEnabled(Farmer player, Tool tool, Item item, GameLocation location) { return(tool is MeleeWeapon && tool.Name.ToLower().Contains("scythe")); }
private static bool Impl(IndoorPot this_, CustomObject dropInItem, bool probe, Farmer who) { if (who != null && dropInItem != null && this_.bush.Value == null && dropInItem.CanPlantThisSeedHere(this_.hoeDirt.Value, (int)this_.tileLocation.X, (int)this_.tileLocation.Y, dropInItem.Category == -19)) { //if ((int)dropInItem.parentSheetIndex == 805) //{ // if (!probe) // { // Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Object.cs.13053")); // } // return false; //} //if ((int)dropInItem.parentSheetIndex == 499) //{ // if (!probe) // { // Game1.playSound("cancel"); // Game1.showGlobalMessage(Game1.content.LoadString("Strings\\Objects:AncientFruitPot")); // } // return false; //} if (!probe) { if (!dropInItem.Plant(this_.hoeDirt.Value, (int)this_.tileLocation.X, (int)this_.tileLocation.Y, who, dropInItem.Category == -19, who.currentLocation)) { return(false); } } else { this_.heldObject.Value = new StardewValley.Object(); } return(true); } //if (who != null && dropInItem != null && this_.hoeDirt.Value.crop == null && this_.bush.Value == null && dropInItem is StardewValley.Object && !(dropInItem as StardewValley.Object).bigCraftable && (int)dropInItem.parentSheetIndex == 251) //{ // if (probe) // { // this_.heldObject.Value = new StardewValley.Object(); // } // else // { // this_.bush.Value = new Bush(this_.tileLocation, 3, who.currentLocation); // if (!who.currentLocation.IsOutdoors) // { // this_.bush.Value.greenhouseBush.Value = true; // this_.bush.Value.loadSprite(); // Game1.playSound("coin"); // } // } // return true; //} return(false); }
/********* ** Private methods *********/ /// <summary>The method to call before <see cref="IndoorPot.performObjectDropInAction"/>.</summary> /// <returns>Returns whether to run the original method.</returns> private static bool Before_PerformObjectDropInAction(IndoorPot __instance, Item dropInItem, bool probe, Farmer who, ref bool __result) { if (dropInItem is CustomObject obj && !string.IsNullOrEmpty(obj.Data.Plants)) { __result = IndoorPotPatcher.Impl(__instance, obj, probe, who); return(false); } return(true); }
/// <summary>Apply the tool to the given tile.</summary> /// <param name="tile">The tile to modify.</param> /// <param name="tileObj">The object on the tile.</param> /// <param name="tileFeature">The feature on the tile.</param> /// <param name="player">The current player.</param> /// <param name="tool">The tool selected by the player (if any).</param> /// <param name="item">The item selected by the player (if any).</param> /// <param name="location">The current location.</param> public override bool Apply(Vector2 tile, SObject tileObj, TerrainFeature tileFeature, Farmer player, Tool tool, Item item, GameLocation location) { // clear debris if (this.Config.ClearDebris && (this.IsTwig(tileObj) || this.IsWeed(tileObj))) { return(this.UseToolOnTile(tool, tile, player, location)); } // cut terrain features switch (tileFeature) { // cut non-fruit tree case Tree tree: return(this.ShouldCut(tree) && this.UseToolOnTile(tool, tile, player, location)); // cut fruit tree case FruitTree tree: return(this.ShouldCut(tree) && this.UseToolOnTile(tool, tile, player, location)); // cut bushes case Bush bush: return(this.ShouldCut(bush) && this.UseToolOnTile(tool, tile, player, location)); // clear crops case HoeDirt dirt when dirt.crop != null: if (this.Config.ClearDeadCrops && dirt.crop.dead.Value) { return(this.UseToolOnTile(tool, tile, player, location)); } if (this.Config.ClearLiveCrops && !dirt.crop.dead.Value) { return(this.UseToolOnTile(tool, tile, player, location)); } break; } // cut resource stumps if (this.Config.ClearDebris || this.Config.CutGiantCrops) { ResourceClump clump = this.GetResourceClumpCoveringTile(location, tile, player, out var applyTool); // giant crops if (this.Config.CutGiantCrops && clump is GiantCrop) { applyTool(tool); return(true); } // big stumps and fallen logs // This needs to check if the axe upgrade level is high enough first, to avoid spamming // 'need to upgrade your tool' messages. Based on ResourceClump.performToolAction. if (this.Config.ClearDebris && clump != null && this.ResourceUpgradeLevelsNeeded.ContainsKey(clump.parentSheetIndex.Value) && tool.UpgradeLevel >= this.ResourceUpgradeLevelsNeeded[clump.parentSheetIndex.Value]) { applyTool(tool); return(true); } } // cut bushes in large terrain features if (this.Config.CutBushes) { foreach (Bush bush in location.largeTerrainFeatures.OfType <Bush>().Where(p => p.tilePosition.Value == tile)) { if (this.ShouldCut(bush) && this.UseToolOnTile(tool, tile, player, location)) { return(true); } } } return(false); }
/// <summary>Get whether the tool is currently enabled.</summary> /// <param name="player">The current player.</param> /// <param name="tool">The tool selected by the player (if any).</param> /// <param name="item">The item selected by the player (if any).</param> /// <param name="location">The current location.</param> public override bool IsEnabled(Farmer player, Tool tool, Item item, GameLocation location) { return(tool is Axe); }
private void EnsureContains(FarmersMarket arg1, Farmer arg2) { if (!arg1.Vendors.Contains(arg2)) arg1.Vendors.Add(arg2); }
public static bool Prefix(Farmer __instance) { farmer = __instance; return false; }
public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f) { setTags(); base.drawWhenHeld(spriteBatch, objectPosition, f); }
//Läser data från xml-fil, skapar en representation av schackbräädet och returnerar det. public ChessPiece[,] LoadData() { if (!IsFileLocked()) { ChessPiece[,] board = new ChessPiece[8, 8]; XDocument doc = XDocument.Load(@".\chessdata\chessdata.xml"); var data = from item in doc.Descendants("ChessPiece") select new { posx = item.Element("posX").Value, posy = item.Element("posY").Value, color = item.Element("color").Value, type = item.Element("type").Value }; foreach (var c in data) { switch (c.type) { case "Chess2._0.King": ChessPiece king = new King(c.color, int.Parse(c.posx), int.Parse(c.posy)); board[int.Parse(c.posx), int.Parse(c.posy)] = king; break; case "Chess2._0.Queen": ChessPiece queen = new Queen(c.color, int.Parse(c.posx), int.Parse(c.posy)); board[int.Parse(c.posx), int.Parse(c.posy)] = queen; break; case "Chess2._0.Runner": ChessPiece runner = new Runner(c.color, int.Parse(c.posx), int.Parse(c.posy)); board[int.Parse(c.posx), int.Parse(c.posy)] = runner; break; case "Chess2._0.Horse": ChessPiece horse = new Horse(c.color, int.Parse(c.posx), int.Parse(c.posy)); board[int.Parse(c.posx), int.Parse(c.posy)] = horse; break; case "Chess2._0.Tower": ChessPiece tower = new Tower(c.color, int.Parse(c.posx), int.Parse(c.posy)); board[int.Parse(c.posx), int.Parse(c.posy)] = tower; break; case "Chess2._0.Farmer": ChessPiece farmer = new Farmer(c.color, int.Parse(c.posx), int.Parse(c.posy)); board[int.Parse(c.posx), int.Parse(c.posy)] = farmer; break; } } return board; } else { throw new Exception(); } }
public async Task <IActionResult> OnPostAsync(string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/"); if (ModelState.IsValid) { ApplicationUser user = new ApplicationUser(); if (Input.UserRole == "Analyst") { // Create new analyst and add role user = new Analyst(Input.FirstName, Input.LastName, Input.Email, Input.Phone, Input.Password); } else if (Input.UserRole == "Farmer") { // Create a new farmer and add role user = new Farmer(Input.FirstName, Input.LastName, Input.Email, Input.Phone, Input.Password, Input.FarmID); } else { // If no role is specified user = new ApplicationUser(Input.FirstName, Input.LastName, Input.Email, Input.Phone, Input.Password); } //var user = new ApplicationUser { UserName = Input.Email, Email = Input.Email }; var result = await _userManager.CreateAsync(user, Input.Password); if (result.Succeeded) { _logger.LogInformation("User created a new account with password."); if (Input.UserRole != "None") { await _userManager.AddToRoleAsync(user, Input.UserRole); } var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); var callbackUrl = Url.Page( "/Account/ConfirmEmail", pageHandler: null, values: new { userId = user.Id, code = code }, protocol: Request.Scheme); await _emailSender.SendEmailAsync(Input.Email, "Confirm your email", $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>."); //await _signInManager.SignInAsync(user, isPersistent: false); return(LocalRedirect(returnUrl)); } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } // If we got this far, something failed, redisplay form return(Page()); }
/// <summary>Get parsed data about the friendship between a player and NPC.</summary> /// <param name="player">The player.</param> /// <param name="npc">The NPC.</param> /// <param name="friendship">The current friendship data.</param> public FriendshipModel GetFriendshipForVillager(Farmer player, NPC npc, Friendship friendship) { return(this.DataParser.GetFriendshipForVillager(player, npc, friendship, this.Metadata)); }
/// <inheritdoc/> public bool Manual_PerformObjectDropInAction(SObject machine, SObject input, bool probe, Farmer who, MassProductionMachineDefinition mpm) { if (!probe && mpm != null) { try { InputInfo inputInfo = InputInfo.ConvertInput(input, 1); int inputQuantity = mpm.Settings.CalculateInputRequired(inputInfo); if (IsValidCrop(input) && input.Stack >= inputQuantity) { input.Stack -= inputQuantity; int seedID = SEED_LOOKUP[input.ParentSheetIndex]; Random random = new Random((int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame / 2 + (int)machine.TileLocation.X + (int)machine.TileLocation.Y * 77 + Game1.timeOfDay); int outputID = seedID; int outputQuantity = mpm.Settings.CalculateOutputProduced(random.Next(1, 4), inputInfo); if (random.NextDouble() < 0.005) { outputID = 499; outputQuantity = mpm.Settings.CalculateOutputProduced(1, inputInfo); } else if (random.NextDouble() < 0.02) { outputID = 770; outputQuantity = mpm.Settings.CalculateOutputProduced(random.Next(1, 5), inputInfo); } machine.heldObject.Value = new SObject(outputID, outputQuantity); machine.MinutesUntilReady = mpm.Settings.CalculateTimeRequired(20); return(true); } } catch (Exception e) { ModEntry.Instance.Monitor.Log($"{e}", StardewModdingAPI.LogLevel.Error); } } return(false); }
/// <summary>Get parsed data about the friendship between a player and NPC.</summary> /// <param name="player">The player.</param> /// <param name="animal">The farm animal.</param> public FriendshipModel GetFriendshipForAnimal(Farmer player, FarmAnimal animal) { return(this.DataParser.GetFriendshipForAnimal(player, animal, this.Metadata)); }
public override bool checkAction(Location tileLocation, xTile.Dimensions.Rectangle viewport, Farmer who) { int num = (this.map.GetLayer("Buildings").Tiles[tileLocation] != null) ? this.map.GetLayer("Buildings").Tiles[tileLocation].TileIndex : -1; if (num <= 1292) { if (num != 1291 && num != 1292) { goto IL_91; } } else { if (num == 1306) { this.showMonsterKillList(); return(true); } switch (num) { case 1355: case 1356: case 1357: case 1358: break; default: goto IL_91; } } this.gil(); return(true); IL_91: return(base.checkAction(tileLocation, viewport, who)); }
internal static void SummonCompanions(CompanionModel model, int numberToSummon, RingModel summoningRing, Farmer who, GameLocation location) { if (location.characters is null) { CustomCompanions.monitor.Log($"Unable to summon {model.Name} due to the location {location.Name} not having an instantiated GameLocation.characters!"); return; } List <Companion> companions = new List <Companion>(); for (int x = 0; x < numberToSummon; x++) { Companion companion = new Companion(model, who); location.characters.Add(companion); companions.Add(companion); } activeCompanions.Add(new BoundCompanions(summoningRing, companions)); }
// Token: 0x06000ABE RID: 2750 RVA: 0x000DF7C1 File Offset: 0x000DD9C1 public override bool performDropDownAction(Farmer who) { this.resetOnPlayerEntry((who == null) ? Game1.currentLocation : who.currentLocation); return(false); }
public CompanionBuff(Farmer farmer, NPC npc, CompanionsManager manager) { buffOwner = farmer; buffGranter = npc; this.manager = manager; }
// Token: 0x06000AD0 RID: 2768 RVA: 0x000E0410 File Offset: 0x000DE610 public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) { if (location is DecoratableLocation) { Point anchor = new Point(x / Game1.tileSize, y / Game1.tileSize); List <Rectangle> walls; if (location is FarmHouse) { walls = FarmHouse.getWalls((location as FarmHouse).upgradeLevel); } else { walls = DecoratableLocation.getWalls(); } this.tileLocation = new Vector2((float)anchor.X, (float)anchor.Y); bool paintingAtRightPlace = false; if (this.furniture_type == 6 || this.furniture_type == 13 || this.parentSheetIndex == 1293) { int offset = (this.parentSheetIndex == 1293) ? 3 : 0; bool foundWall = false; foreach (Rectangle w in walls) { if ((this.furniture_type == 6 || this.furniture_type == 13 || offset != 0) && w.Y + offset == anchor.Y && w.Contains(anchor.X, anchor.Y - offset)) { foundWall = true; break; } } if (!foundWall) { Game1.showRedMessage("Must be placed on wall"); return(false); } paintingAtRightPlace = true; } for (int furnitureX = anchor.X; furnitureX < anchor.X + this.getTilesWide(); furnitureX++) { for (int furnitureY = anchor.Y; furnitureY < anchor.Y + this.getTilesHigh(); furnitureY++) { if (location.doesTileHaveProperty(furnitureX, furnitureY, "NoFurniture", "Back") != null) { Game1.showRedMessage("Furniture can't be placed here"); return(false); } if (!paintingAtRightPlace && Utility.pointInRectangles(walls, furnitureX, furnitureY)) { Game1.showRedMessage("Can't place on wall"); return(false); } if (location.getTileIndexAt(furnitureX, furnitureY, "Buildings") != -1) { return(false); } } } this.boundingBox = new Rectangle(x / Game1.tileSize * Game1.tileSize, y / Game1.tileSize * Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height); foreach (Furniture f in (location as DecoratableLocation).furniture) { if (f.furniture_type == 11 && f.heldObject == null && f.getBoundingBox(f.tileLocation).Intersects(this.boundingBox)) { f.performObjectDropInAction(this, false, (who == null) ? Game1.player : who); bool result = true; return(result); } } using (List <Farmer> .Enumerator enumerator3 = location.getFarmers().GetEnumerator()) { while (enumerator3.MoveNext()) { if (enumerator3.Current.GetBoundingBox().Intersects(this.boundingBox)) { Game1.showRedMessage("Can't place on top of a person."); bool result = false; return(result); } } } this.updateDrawPosition(); return(base.placementAction(location, x, y, who)); } Game1.showRedMessage("Can only be placed in House"); return(false); }
private void DamageFarmer(Farmer who, GameLocation location) { who.takeDamage(GetDamage(location as DeepWoods), false, null); }
// Token: 0x06000ADD RID: 2781 RVA: 0x00002834 File Offset: 0x00000A34 public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f) { }
public EventArgsFarmerChanged(Farmer priorFarmer, Farmer newFarmer) { NewFarmer = NewFarmer; PriorFarmer = PriorFarmer; }
public PlayerEquipmentInfo(Farmer player, Vector2 position) { var inventory = new InventoryPage(0, 0, 0, 0); inventory.equipmentIcons = null; }
private void EnsureContainsNot(FarmersMarket arg1, Farmer arg2) { if (arg1.Vendors.Contains(arg2)) arg1.Vendors.Remove(arg2); }
public static bool ManorHouse_performAction_Prefix(ManorHouse __instance, string action, Farmer who, ref bool __result) { try { if (action != null && who.IsLocalPlayer && Game1.player.isMarried()) { string a = action.Split(new char[] { ' ' })[0]; if (a == "DivorceBook") { string s2 = Game1.content.LoadStringReturnNullIfNotFound("Strings\\Locations:ManorHouse_DivorceBook_Question_" + Game1.player.spouse); if (s2 == null) { s2 = Game1.content.LoadStringReturnNullIfNotFound("Strings\\Locations:ManorHouse_DivorceBook_Question"); } List <Response> responses = new List <Response>(); responses.Add(new Response("divorce_Yes", Game1.content.LoadString("Strings\\Lexicon:QuestionDialogue_Yes"))); responses.Add(new Response("divorce_Complex", ModEntry.PHelper.Translation.Get("divorce_complex"))); responses.Add(new Response("divorce_No", Game1.content.LoadString("Strings\\Lexicon:QuestionDialogue_No"))); __instance.createQuestionDialogue(s2, responses.ToArray(), ModEntry.AnswerDialogue); __result = true; return(false); } } } catch (Exception ex) { Monitor.Log($"Failed in {nameof(ManorHouse_performAction_Prefix)}:\n{ex}", LogLevel.Error); } return(true); }
public ChessBoard(DataStorage dataS) { ds = dataS; //Om det finns ett sparat spel, läs in det if (File.Exists(@".\chessdata\chessdata.xml")) { this.board = ds.LoadData(); ds.SaveData(board); } else { //Skapar vita pjäser ChessPiece whiteKing = new King("white", 4, 0); ChessPiece whiteQueen = new Queen("white", 3, 0); ChessPiece whiteRunner1 = new Runner("white", 2, 0); ChessPiece whiteRunner2 = new Runner("white", 5, 0); ChessPiece whiteHorse1 = new Horse("white", 1, 0); ChessPiece whiteHorse2 = new Horse("white", 6, 0); ChessPiece whiteTower1 = new Tower("white", 0, 0); ChessPiece whiteTower2 = new Tower("white", 7, 0); ChessPiece whiteFarmer1 = new Farmer("white", 0, 1); ChessPiece whiteFarmer2 = new Farmer("white", 1, 1); ChessPiece whiteFarmer3 = new Farmer("white", 2, 1); ChessPiece whiteFarmer4 = new Farmer("white", 3, 1); ChessPiece whiteFarmer5 = new Farmer("white", 4, 1); ChessPiece whiteFarmer6 = new Farmer("white", 5, 1); ChessPiece whiteFarmer7 = new Farmer("white", 6, 1); ChessPiece whiteFarmer8 = new Farmer("white", 7, 1); //Skapar svarta pjäser ChessPiece blackKing = new King("black", 4, 7); ChessPiece blackQueen = new Queen("black", 3, 7); ChessPiece blackRunner1 = new Runner("black", 2, 7); ChessPiece blackRunner2 = new Runner("black", 5, 7); ChessPiece blackHorse1 = new Horse("black", 1, 7); ChessPiece blackHorse2 = new Horse("black", 6, 7); ChessPiece blackTower1 = new Tower("black", 0, 7); ChessPiece blackTower2 = new Tower("black", 7, 7); ChessPiece blackFarmer1 = new Farmer("black", 0, 6); ChessPiece blackFarmer2 = new Farmer("black", 1, 6); ChessPiece blackFarmer3 = new Farmer("black", 2, 6); ChessPiece blackFarmer4 = new Farmer("black", 3, 6); ChessPiece blackFarmer5 = new Farmer("black", 4, 6); ChessPiece blackFarmer6 = new Farmer("black", 5, 6); ChessPiece blackFarmer7 = new Farmer("black", 6, 6); ChessPiece blackFarmer8 = new Farmer("black", 7, 6); //Lägg till pjäser i tvådimensionell array som representerar schackbrädet board[4, 0] = whiteKing; board[3, 0] = whiteQueen; board[2, 0] = whiteRunner1; board[5, 0] = whiteRunner2; board[1, 0] = whiteHorse1; board[6, 0] = whiteHorse2; board[0, 0] = whiteTower1; board[7, 0] = whiteTower2; board[0, 1] = whiteFarmer1; board[1, 1] = whiteFarmer2; board[2, 1] = whiteFarmer3; board[3, 1] = whiteFarmer4; board[4, 1] = whiteFarmer5; board[5, 1] = whiteFarmer6; board[6, 1] = whiteFarmer7; board[7, 1] = whiteFarmer8; board[4, 7] = blackKing; board[3, 7] = blackQueen; board[2, 7] = blackRunner1; board[5, 7] = blackRunner2; board[1, 7] = blackHorse1; board[6, 7] = blackHorse2; board[0, 7] = blackTower1; board[7, 7] = blackTower2; board[0, 6] = blackFarmer1; board[1, 6] = blackFarmer2; board[2, 6] = blackFarmer3; board[3, 6] = blackFarmer4; board[4, 6] = blackFarmer5; board[5, 6] = blackFarmer6; board[6, 6] = blackFarmer7; board[7, 6] = blackFarmer8; ds.SaveData(board); } }
internal static void StealAttempt(MineShaft shaft, string action, Location tileLocation, Farmer who) { monitor.Log($"Attempting to steal from altar"); string[] parts = action.Split('_').Skip(1).ToArray(); Vector2 spot = new Vector2(int.Parse(parts[0]), int.Parse(parts[1])); shaft.setMapTileIndex((int)spot.X - 1, (int)spot.Y + 1, OfferingPuzzles.offerIdx, "Buildings"); shaft.setMapTileIndex((int)spot.X + 1, (int)spot.Y + 1, OfferingPuzzles.offerIdx, "Buildings"); shaft.setMapTileIndex((int)spot.X - 1, (int)spot.Y - 1, 244, "Front"); shaft.setMapTileIndex((int)spot.X + 1, (int)spot.Y - 1, 244, "Front"); shaft.removeTileProperty((int)spot.X - 1, (int)spot.Y + 1, "Buildings", "Action"); shaft.removeTileProperty((int)spot.X + 1, (int)spot.Y + 1, "Buildings", "Action"); Traps.TriggerRandomTrap(shaft, new Vector2(who.getTileLocation().X, who.getTileLocation().Y), false); }
public Form1() { _farmer = new Farmer(15, 30); InitializeComponent(); }
internal static void OfferObject(MineShaft shaft, string action, Location tileLocation, Farmer who) { monitor.Log($"Attempting to offer to altar"); string[] parts = action.Split('_').Skip(1).ToArray(); Vector2 spot = new Vector2(int.Parse(parts[1]), int.Parse(parts[2])); if (ores[int.Parse(parts[0])] == who.ActiveObject.ParentSheetIndex) { monitor.Log($"Made acceptable offering to altar"); who.reduceActiveItemByOne(); shaft.setMapTileIndex(tileLocation.X, tileLocation.Y, OfferingPuzzles.offerIdx + 1 + int.Parse(parts[0]), "Buildings"); shaft.setMapTileIndex(tileLocation.X, tileLocation.Y - 2, 245, "Front"); shaft.setTileProperty((int)spot.X - 1, (int)spot.Y + 1, "Buildings", "Action", $"offerPuzzleSteal_{parts[1]}_{parts[2]}"); shaft.setTileProperty((int)spot.X + 1, (int)spot.Y + 1, "Buildings", "Action", $"offerPuzzleSteal_{parts[1]}_{parts[2]}"); Utils.DropChest(shaft, spot); } else { monitor.Log($"Made unacceptable offering to altar"); who.reduceActiveItemByOne(); shaft.setMapTileIndex((int)spot.X - 1, (int)spot.Y + 1, OfferingPuzzles.offerIdx, "Buildings"); shaft.setMapTileIndex((int)spot.X + 1, (int)spot.Y + 1, OfferingPuzzles.offerIdx, "Buildings"); shaft.removeTileProperty((int)spot.X - 1, (int)spot.Y + 1, "Buildings", "Action"); shaft.removeTileProperty((int)spot.X + 1, (int)spot.Y + 1, "Buildings", "Action"); Traps.TriggerRandomTrap(shaft, new Vector2(who.getTileLocation().X, who.getTileLocation().Y), false); } }
public bool CanAffordAction(FarmerActionType action, ICollection<Farmer.FarmerAction> includedPendingActions = null, Farmer.FarmerAction includedCurrentAction = null) { if (!actionCostDict.ContainsKey(action)) { return true; } int pendingCost = 0; if (includedPendingActions != null) { foreach (Farmer.FarmerAction actionPair in includedPendingActions) { if (actionCostDict.ContainsKey(actionPair.type)) { pendingCost += actionCostDict[actionPair.type]; } } } if (includedCurrentAction != null && actionCostDict.ContainsKey(includedCurrentAction.type)) { pendingCost += actionCostDict[includedCurrentAction.type]; } Counter pt = FindObjectOfType<Toolbar>().poopCounter; return pt.amount >= actionCostDict[action] + pendingCost; }
public override int takeDamage(int damage, int xTrajectory, int yTrajectory, bool isBomb, double addedPrecision, Farmer who) { int actualDamage = Math.Max(1, damage - (int)resilience); if ((int)reviveTimer > 0) { if (isBomb) { base.Health = 0; Utility.makeTemporarySpriteJuicier(new TemporaryAnimatedSprite(44, base.Position, Color.BlueViolet, 10) { holdLastFrame = true, alphaFade = 0.01f, interval = 70f }, base.currentLocation); base.currentLocation.playSound("ghost"); return(999); } return(-1); } if (Game1.random.NextDouble() < (double)missChance - (double)missChance * addedPrecision) { actualDamage = -1; } else { base.Slipperiness = 2; base.Health -= actualDamage; setTrajectory(xTrajectory, yTrajectory); base.currentLocation.playSound("shadowHit"); base.currentLocation.playSound("skeletonStep"); base.IsWalkingTowardPlayer = true; if (base.Health <= 0) { if (!isBomb && who.CurrentTool is MeleeWeapon && (who.CurrentTool as MeleeWeapon).hasEnchantmentOfType <CrusaderEnchantment>()) { Utility.makeTemporarySpriteJuicier(new TemporaryAnimatedSprite(44, base.Position, Color.BlueViolet, 10) { holdLastFrame = true, alphaFade = 0.01f, interval = 70f }, base.currentLocation); base.currentLocation.playSound("ghost"); } else { reviveTimer.Value = 10000; base.Health = base.MaxHealth; deathAnimation(); } } } return(actualDamage); }