public void dismount(bool from_demolish = false) { mutex.ReleaseLock(); rider.mount = null; if (base.currentLocation == null) { return; } Stable stable = null; foreach (Building building in Game1.getFarm().buildings) { if (building is Stable && (building as Stable).HorseId == HorseId) { stable = building as Stable; break; } } if (stable != null && !from_demolish && !base.currentLocation.characters.Where((NPC c) => c is Horse && (c as Horse).HorseId == HorseId).Any()) { base.currentLocation.characters.Add(this); } SyncPositionToRider(); rider.TemporaryPassableTiles.Add(new Rectangle((int)dismountTile.X * 64, (int)dismountTile.Y * 64, 64, 64)); rider.freezePause = -1; dismounting.Value = false; rider.isAnimatingMount = false; rider.canMove = true; rider.forceCanMove(); rider.xOffset = 0f; rider = null; Halt(); farmerPassesThrough = false; }
public override bool checkForAction(Farmer who, bool justCheckingForActivity = false) { if (justCheckingForActivity) { return(true); } mutex.RequestLock(delegate { List <Item> list = heldItems.ToList(); list.Sort(SortItems); Dictionary <ISalable, int[]> dictionary = new Dictionary <ISalable, int[]>(); foreach (Item current in list) { dictionary[current] = new int[2] { 0, 1 }; } Game1.activeClickableMenu = new ShopMenu(dictionary, 0, null, onDresserItemWithdrawn, onDresserItemDeposited, "Dresser") { source = this, behaviorBeforeCleanup = delegate { mutex.ReleaseLock(); } }; }); return(true); }
public virtual void GiveReward() { Game1.createItemDebris(new Object(73, 1), new Vector2(4.5f, 4f) * 64f, 3, this); Game1.createItemDebris(new Object(73, 1), new Vector2(4.5f, 4f) * 64f, 1, this); Game1.createItemDebris(new Object(73, 1), new Vector2(4.5f, 4f) * 64f, 1, this); Game1.createItemDebris(new Object(73, 1), new Vector2(4.5f, 4f) * 64f, 1, this); Game1.createItemDebris(new Object(73, 1), new Vector2(4.5f, 4f) * 64f, 1, this); gourmandRequestsFulfilled.Value++; Game1.player.team.MarkCollectedNut("IslandGourmand" + gourmandRequestsFulfilled.Value); gourmandMutex.ReleaseLock(); }
public virtual void Cleanup() { if (upgradeMutex.IsLockHeld()) { upgradeMutex.ReleaseLock(); } if (isPlayerNearby) { Game1.specialCurrencyDisplay.ShowCurrency(null); isPlayerNearby = false; } }
public virtual void ShowChestMenu() { Game1.activeClickableMenu = new ItemGrabMenu(heldItems, reverseGrab: false, showReceivingMenu: true, InventoryMenu.highlightAllItems, GrabItemFromInventory, null, GrabItemFromChest, snapToBottom: false, canBeExitedWithKey: true, playRightClickSound: true, allowRightClick: true, showOrganizeButton: true, 1, this, -1, this) { behaviorBeforeCleanup = delegate { mutex.ReleaseLock(); OnMenuClose(); } }; Game1.playSound("dwop"); }
public override bool performToolAction(Tool t, GameLocation location) { if (t != null && t.getLastFarmerToUse() != null && t.getLastFarmerToUse() != Game1.player) { return(false); } if ((bool)playerChest) { if (t == null) { return(false); } if (t is MeleeWeapon || !t.isHeavyHitter()) { return(false); } if (base.performToolAction(t, location)) { Farmer player = t.getLastFarmerToUse(); if (player != null) { Vector2 c = player.GetToolLocation() / 64f; c.X = (int)c.X; c.Y = (int)c.Y; mutex.RequestLock(delegate { clearNulls(); if (items.Count == 0) { performRemoveAction(tileLocation, location); if (location.Objects.Remove(c) && type.Equals("Crafting") && (int)fragility != 2) { location.debris.Add(new Debris(bigCraftable ? (-base.ParentSheetIndex) : base.ParentSheetIndex, player.GetToolLocation(), new Vector2(player.GetBoundingBox().Center.X, player.GetBoundingBox().Center.Y))); } } else if (t != null && t.isHeavyHitter() && !(t is MeleeWeapon)) { location.playSound("hammer"); shakeTimer = 100; } mutex.ReleaseLock(); }); } } return(false); } if (t != null && t is Pickaxe && currentLidFrame == 503 && (int)frameCounter == -1 && items.Count == 0) { return(true); } return(false); }
public override void updateEvenIfFarmerIsntHere(GameTime time, bool skipWasUpdatedFlush = false) { base.updateEvenIfFarmerIsntHere(time, skipWasUpdatedFlush); inventoryMutex.Update(Game1.getOnlineFarmers()); if (inventoryMutex.IsLockHeld() && !(Game1.activeClickableMenu is ItemGrabMenu)) { inventoryMutex.ReleaseLock(); } }
public override bool answerDialogueAction(string questionAndAnswer, string[] questionParams) { if (questionAndAnswer == null) { return(false); } if (!(questionAndAnswer == "Museum_Collect")) { if (!(questionAndAnswer == "Museum_Donate")) { if (questionAndAnswer == "Museum_Rearrange_Yes" && !mutex.IsLocked()) { mutex.RequestLock(delegate { Game1.activeClickableMenu = new MuseumMenu(InventoryMenu.highlightNoItems) { exitFunction = delegate { mutex.ReleaseLock(); } }; }); } } else { mutex.RequestLock(delegate { Game1.activeClickableMenu = new MuseumMenu(isItemSuitableForDonation) { exitFunction = delegate { mutex.ReleaseLock(); } }; }); } } else { Game1.activeClickableMenu = new ItemGrabMenu(getRewardsForPlayer(Game1.player), reverseGrab: false, showReceivingMenu: true, null, null, "Rewards", collectedReward, snapToBottom: false, canBeExitedWithKey: true, playRightClickSound: false, allowRightClick: false, showOrganizeButton: false, 0, null, -1, this); } return(base.answerDialogueAction(questionAndAnswer, questionParams)); }
public override void updateEvenIfFarmerIsntHere(GameTime time, bool ignoreWasUpdatedFlush = false) { base.updateEvenIfFarmerIsntHere(time, ignoreWasUpdatedFlush); bundleMutex.Update(this); if (bundleMutex.IsLockHeld() && Game1.activeClickableMenu == null) { bundleMutex.ReleaseLock(); } restoreAreaCutsceneEvent.Poll(); }
public virtual void Update() { _AddSpecialRulesIfNecessary(); if (_objectiveRegistrationDirty) { _objectiveRegistrationDirty = false; _UpdateObjectiveRegistration(); } if (!readyForRemoval.Value) { if (questState.Value == QuestState.InProgress && !participants.ContainsKey(Game1.player.UniqueMultiplayerID)) { participants[Game1.player.UniqueMultiplayerID] = true; } else if (questState.Value == QuestState.Complete) { if (unclaimedRewards.ContainsKey(Game1.player.UniqueMultiplayerID)) { unclaimedRewards.Remove(Game1.player.UniqueMultiplayerID); Game1.stats.QuestsCompleted++; Game1.playSound("questcomplete"); Game1.dayTimeMoneyBox.questsDirty = true; foreach (OrderReward reward in rewards) { reward.Grant(); } } if (participants.ContainsKey(Game1.player.UniqueMultiplayerID) && GetMoneyReward() <= 0) { RemoveFromParticipants(); } } } donateMutex.Update(Game1.getOnlineFarmers()); if (donateMutex.IsLockHeld() && Game1.activeClickableMenu == null) { donateMutex.ReleaseLock(); } if (Game1.activeClickableMenu == null) { _highlightLookup = null; } if (Game1.IsMasterGame && questState.Value != 0) { MarkForRemovalIfEmpty(); if (readyForRemoval.Value) { _RemoveSpecialRuleIfNecessary(); Game1.player.team.specialOrders.Remove(this); } } }
public override bool performObjectDropInAction(Item drop_in_item, bool probe, Farmer who) { if (locked.Value) { return(false); } if (!drop_in_item.canBeTrashed()) { return(false); } if (heldObject.Value != null) { DropObject(who); return(false); } if (drop_in_item.GetType() == typeof(Object)) { if (probe) { return(true); } Object placed_object = drop_in_item.getOne() as Object; itemModifyMutex.RequestLock(delegate { who.currentLocation.playSound("woodyStep"); heldObject.Value = placed_object; UpdateItemMatch(); itemModifyMutex.ReleaseLock(); }, delegate { if (placed_object != heldObject.Value) { Game1.createItemDebris(placed_object, (base.TileLocation + new Vector2(0.5f, 0.5f)) * 64f, -1, who.currentLocation); } }); return(true); } return(false); }
public void Update() { requestMovieEndEvent.Poll(); endMovieEvent.Poll(); festivalPropRemovalEvent.Poll(); demolishStableEvent.Poll(); requestSpouseSleepEvent.Poll(); requestPetWarpHomeEvent.Poll(); grangeMutex.Update(Game1.getOnlineFarmers()); demolishLock.Update(); buildLock.Update(Game1.getOnlineFarmers()); movieMutex.Update(Game1.getOnlineFarmers()); if (grangeMutex.IsLockHeld() && Game1.activeClickableMenu == null) { grangeMutex.ReleaseLock(); } foreach (ReadyCheck value in readyChecks.Values) { value.Update(); } if (Game1.IsMasterGame && proposals.Count() > 0) { proposals.Filter((KeyValuePair <long, Proposal> pair) => playerIsOnline(pair.Key) && playerIsOnline(pair.Value.receiver.UID)); } Proposal proposal = GetIncomingProposal(); if (proposal != null && proposal.canceled.Value) { proposal.cancelConfirmed.Value = true; } if (Game1.dialogueUp) { return; } if (proposal != null) { if (!handleIncomingProposal(proposal)) { proposal.responseMessageKey.Value = genderedKey("Strings\\UI:Proposal_PlayerBusy", Game1.player); proposal.response.Value = ProposalResponse.Rejected; } } else if (Game1.activeClickableMenu == null && GetOutgoingProposal() != null) { Game1.activeClickableMenu = new PendingProposalDialog(); } }
public override void updateWhenCurrentLocation(GameTime time, GameLocation environment) { FixLidFrame(); base.updateWhenCurrentLocation(time, environment); Mutex.Update(environment); if (FrameCounter.Value > -1 && _currentLidFrame <= (int)TileIndex.Freezer_LidEnd) { --FrameCounter.Value; if (FrameCounter.Value > 0 || !Mutex.IsLockHeld()) { return; } if (_currentLidFrame == (int)TileIndex.Freezer_LidEnd) { Game1.activeClickableMenu = _GetFreezerMenu(); FrameCounter.Value = -1; } else { FrameCounter.Value = 5; ++_currentLidFrame; } } else { if (FrameCounter.Value != -1 || _currentLidFrame <= (int)TileIndex.Freezer_LidStart || (Game1.activeClickableMenu != null || !Mutex.IsLockHeld())) { return; } Mutex.ReleaseLock(); _currentLidFrame = (int)TileIndex.Freezer_LidEnd; FrameCounter.Value = 2; environment.localSound("doorCreakReverse"); } }
public void CheckReturnedDonations() { returnedDonationsMutex.RequestLock(delegate { Dictionary <ISalable, int[]> dictionary = new Dictionary <ISalable, int[]>(); foreach (Item current in returnedDonations) { dictionary[current] = new int[2] { 0, current.Stack }; } Game1.activeClickableMenu = new ShopMenu(dictionary, 0, null, OnDonatedItemWithdrawn, OnReturnedDonationDeposited, "ReturnedDonations") { source = this, behaviorBeforeCleanup = delegate { returnedDonationsMutex.ReleaseLock(); } }; }); }
public override bool checkAction(Farmer who, GameLocation l) { if (!lastPetDay.ContainsKey(who.UniqueMultiplayerID)) { lastPetDay.Add(who.UniqueMultiplayerID, -1); } if (lastPetDay[who.UniqueMultiplayerID] != Game1.Date.TotalDays) { lastPetDay[who.UniqueMultiplayerID] = Game1.Date.TotalDays; mutex.RequestLock(delegate { if (!grantedFriendshipForPet.Value) { grantedFriendshipForPet.Set(newValue: true); friendshipTowardFarmer.Set(Math.Min(1000, (int)friendshipTowardFarmer + 12)); } mutex.ReleaseLock(); }); doEmote(20); playContentSound(); return(true); } return(false); }
public override bool answerDialogueAction(string questionAndAnswer, string[] questionParams) { if (questionAndAnswer == null) { return(false); } switch (questionAndAnswer) { case "Safari_Hint": { int bone = getRandomUnfoundBoneIndex(); if (bone == 823) { bone = 824; } Game1.drawDialogue(safariGuy, Game1.content.LoadString("Data\\ExtraDialogue:ProfessorSnail_Hint_" + bone)); break; } case "Safari_Collect": { Game1.activeClickableMenu = new ItemGrabMenu(new List <Item>(uncollectedRewards), reverseGrab: false, showReceivingMenu: true, null, null, "Rewards", OnCollectReward, snapToBottom: false, canBeExitedWithKey: true, playRightClickSound: false, allowRightClick: false, showOrganizeButton: false, 0, null, -1, this); IClickableMenu activeClickableMenu2 = Game1.activeClickableMenu; activeClickableMenu2.exitFunction = (IClickableMenu.onExit)Delegate.Combine(activeClickableMenu2.exitFunction, (IClickableMenu.onExit) delegate { safariGuyMutex.ReleaseLock(); }); break; } case "Safari_Donate": { Game1.activeClickableMenu = new FieldOfficeMenu(this); IClickableMenu activeClickableMenu = Game1.activeClickableMenu; activeClickableMenu.exitFunction = (IClickableMenu.onExit)Delegate.Combine(activeClickableMenu.exitFunction, (IClickableMenu.onExit) delegate { safariGuyMutex.ReleaseLock(); }); break; } case "Safari_Leave": safariGuyMutex.ReleaseLock(); break; case "Survey_Yes": if (!plantsRestoredLeft) { List <Response> responses2 = new List <Response>(); for (int j = 18; j < 25; j++) { responses2.Add(new Response((j == 22) ? "Correct" : "Wrong", string.Concat(j))); } responses2.Add(new Response("No", Game1.content.LoadString("Strings\\Locations:MineCart_Destination_Cancel")).SetHotKey(Keys.Escape)); createQuestionDialogue(Game1.content.LoadString("Strings\\Locations:IslandFieldOffice_Survey_PurpleFlower_Question"), responses2.ToArray(), "PurpleFlowerSurvey"); } else if (!plantsRestoredRight) { List <Response> responses = new List <Response>(); for (int i = 11; i < 19; i++) { responses.Add(new Response((i == 18) ? "Correct" : "Wrong", string.Concat(i))); } responses.Add(new Response("No", Game1.content.LoadString("Strings\\Locations:MineCart_Destination_Cancel")).SetHotKey(Keys.Escape)); createQuestionDialogue(Game1.content.LoadString("Strings\\Locations:IslandFieldOffice_Survey_PurpleStarfish_Question"), responses.ToArray(), "PurpleStarfishSurvey"); } break; case "PurpleFlowerSurvey_Correct": Game1.drawDialogue(safariGuy, Game1.content.LoadString("Strings\\Locations:IslandFieldOffice_Survey_PurpleFlower_Correct")); plantsRestoredLeft.Value = true; Game1.multiplayer.globalChatInfoMessage("FinishedSurvey", Game1.player.name); break; case "PurpleFlowerSurvey_Wrong": Game1.drawDialogue(safariGuy, Game1.content.LoadString("Strings\\Locations:IslandFieldOffice_Survey_PurpleFlower_Wrong")); hasFailedSurveyToday.Value = true; break; case "PurpleStarfishSurvey_Correct": Game1.drawDialogue(safariGuy, Game1.content.LoadString("Strings\\Locations:IslandFieldOffice_Survey_PurpleFlower_Correct")); plantsRestoredRight.Value = true; Game1.multiplayer.globalChatInfoMessage("FinishedSurvey", Game1.player.name); break; case "PurpleStarfishSurvey_Wrong": Game1.drawDialogue(safariGuy, Game1.content.LoadString("Strings\\Locations:IslandFieldOffice_Survey_PurpleFlower_Wrong")); hasFailedSurveyToday.Value = true; break; } if (!Game1.player.hasOrWillReceiveMail("fieldOfficeFinale") && isRangeAllTrue(0, 11) && plantsRestoredRight.Value && plantsRestoredLeft.Value) { triggerFinaleCutscene(); } return(base.answerDialogueAction(questionAndAnswer, questionParams)); }
public void Update() { requestLeoMove.Poll(); requestMovieEndEvent.Poll(); endMovieEvent.Poll(); ringPhoneEvent.Poll(); festivalPropRemovalEvent.Poll(); demolishStableEvent.Poll(); requestSpouseSleepEvent.Poll(); requestHorseWarpEvent.Poll(); kickOutOfMinesEvent.Poll(); requestPetWarpHomeEvent.Poll(); requestNutDrop.Poll(); requestAddCharacterEvent.Poll(); addCharacterEvent.Poll(); addQiGemsToTeam.Poll(); grangeMutex.Update(Game1.getOnlineFarmers()); returnedDonationsMutex.Update(Game1.getOnlineFarmers()); ordersBoardMutex.Update(Game1.getOnlineFarmers()); qiChallengeBoardMutex.Update(Game1.getOnlineFarmers()); junimoChestMutex.Update(Game1.getOnlineFarmers()); demolishLock.Update(); buildLock.Update(Game1.getOnlineFarmers()); movieMutex.Update(Game1.getOnlineFarmers()); goldenCoconutMutex.Update(Game1.getOnlineFarmers()); if (grangeMutex.IsLockHeld() && Game1.activeClickableMenu == null) { grangeMutex.ReleaseLock(); } foreach (SpecialOrder specialOrder in specialOrders) { specialOrder.Update(); } foreach (ReadyCheck value in readyChecks.Values) { value.Update(); } if (Game1.IsMasterGame && proposals.Count() > 0) { proposals.Filter((KeyValuePair <long, Proposal> pair) => playerIsOnline(pair.Key) && playerIsOnline(pair.Value.receiver.UID)); } Proposal proposal = GetIncomingProposal(); if (proposal != null && proposal.canceled.Value) { proposal.cancelConfirmed.Value = true; } if (Game1.dialogueUp) { return; } if (proposal != null) { if (!handleIncomingProposal(proposal)) { proposal.responseMessageKey.Value = genderedKey("Strings\\UI:Proposal_PlayerBusy", Game1.player); proposal.response.Value = ProposalResponse.Rejected; } } else if (Game1.activeClickableMenu == null && GetOutgoingProposal() != null) { Game1.activeClickableMenu = new PendingProposalDialog(); } }
public override void dayUpdate(int dayOfMonth) { resetForNewDay(dayOfMonth); mutex.ReleaseLock(); moveUp = false; moveDown = false; moveLeft = false; moveRight = false; int parent_unique_id = (int)Game1.MasterPlayer.UniqueMultiplayerID; if (Game1.currentLocation is FarmHouse) { FarmHouse farm_house2 = Game1.currentLocation as FarmHouse; if (farm_house2.owner != null) { parent_unique_id = (int)farm_house2.owner.UniqueMultiplayerID; } } Random r = new Random(Game1.Date.TotalDays + (int)Game1.uniqueIDForThisGame / 2 + parent_unique_id * 2); daysOld.Value += 1; if (daysOld.Value >= 55) { base.Age = 3; base.speed = 4; } else if (daysOld.Value >= 27) { base.Age = 2; } else if (daysOld.Value >= 13) { base.Age = 1; } if ((int)age == 0 || (int)age == 1) { base.Position = new Vector2(16f, 4f) * 64f + new Vector2(0f, -24f); } if (base.Age == 2) { base.speed = 1; Point p2 = (base.currentLocation as FarmHouse).getRandomOpenPointInHouse(r, 1, 60); if (!p2.Equals(Point.Zero)) { setTilePosition(p2); } else { base.Position = new Vector2(16f, 4f) * 64f + new Vector2(0f, -24f); } Sprite.CurrentAnimation = null; } if (base.Age == 3) { Point p = (base.currentLocation as FarmHouse).getRandomOpenPointInHouse(r, 1, 60); if (!p.Equals(Point.Zero)) { setTilePosition(p); } else { FarmHouse farm_house = base.currentLocation as FarmHouse; setTilePosition(farm_house.getChildBed(base.Gender)); } Sprite.CurrentAnimation = null; } reloadSprite(); if (base.Age == 2) { setCrawlerInNewDirection(); } }
public override bool checkForAction(Farmer who, bool justCheckingForActivity = false) { if (justCheckingForActivity) { return(true); } List <Chest> nearby_chests = new List <Chest>(); Vector2[] neighbor_tiles = new Vector2[8] { new Vector2(-1f, 1f), new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(-1f, 0f), new Vector2(1f, 0f), new Vector2(-1f, -1f), new Vector2(0f, -1f), new Vector2(1f, -1f) }; for (int i = 0; i < neighbor_tiles.Length; i++) { if (who.currentLocation is FarmHouse && who.currentLocation.getTileIndexAt((int)(tileLocation.X + neighbor_tiles[i].X), (int)(tileLocation.Y + neighbor_tiles[i].Y), "Buildings") == 173) { nearby_chests.Add((who.currentLocation as FarmHouse).fridge.Value); continue; } if (who.currentLocation is IslandFarmHouse && who.currentLocation.getTileIndexAt((int)(tileLocation.X + neighbor_tiles[i].X), (int)(tileLocation.Y + neighbor_tiles[i].Y), "Buildings") == 173) { nearby_chests.Add((who.currentLocation as IslandFarmHouse).fridge.Value); continue; } Vector2 tile_location = new Vector2((int)(tileLocation.X + neighbor_tiles[i].X), (int)(tileLocation.Y + neighbor_tiles[i].Y)); Object neighbor_object = null; if (who.currentLocation.objects.ContainsKey(tile_location)) { neighbor_object = who.currentLocation.objects[tile_location]; } if (neighbor_object != null && neighbor_object is Chest && (neighbor_object as Chest).SpecialChestType == Chest.SpecialChestTypes.None) { nearby_chests.Add(neighbor_object as Chest); } } List <NetMutex> muticies = new List <NetMutex>(); foreach (Chest chest in nearby_chests) { muticies.Add(chest.mutex); } if (!mutex.IsLocked()) { MultipleMutexRequest multipleMutexRequest = null; multipleMutexRequest = new MultipleMutexRequest(muticies, delegate { mutex.RequestLock(delegate { Vector2 topLeftPositionForCenteringOnScreen = Utility.getTopLeftPositionForCenteringOnScreen(800 + IClickableMenu.borderWidth * 2, 600 + IClickableMenu.borderWidth * 2); Game1.activeClickableMenu = new CraftingPage((int)topLeftPositionForCenteringOnScreen.X, (int)topLeftPositionForCenteringOnScreen.Y, 800 + IClickableMenu.borderWidth * 2, 600 + IClickableMenu.borderWidth * 2, cooking: false, standalone_menu: true, nearby_chests); Game1.activeClickableMenu.exitFunction = delegate { mutex.ReleaseLock(); multipleMutexRequest.ReleaseLocks(); }; }, delegate { multipleMutexRequest.ReleaseLocks(); }); }, delegate { Game1.showRedMessage(Game1.content.LoadString("Strings\\UI:Workbench_Chest_Warning")); }); } return(true); }
public override void DayUpdate(GameLocation location) { base.DayUpdate(location); mutex.ReleaseLock(); }