private void GameLoop_TimeChanged(object sender, TimeChangedEventArgs e) { this.StateMachine.Companion.clearSchedule(); if (e.NewTime >= 2200) { NPC companion = this.StateMachine.Companion; Dialogue dismissalDialogue = new Dialogue(DialogueHelper.GetDialogueString(companion, "companionDismissAuto"), companion); this.dismissalDialogue = dismissalDialogue; this.StateMachine.Companion.doEmote(24); this.StateMachine.Companion.updateEmote(Game1.currentGameTime); DialogueHelper.DrawDialogue(dismissalDialogue); } MineShaft mines = this.StateMachine.Companion.currentLocation as MineShaft; // Fix spawn ladder if area is infested and all monsters is killed but NPC following us if (mines != null && mines.mustKillAllMonstersToAdvance()) { var monsters = from c in mines.characters where c.IsMonster select c; if (monsters.Count() == 0) { Vector2 vector2 = this.StateMachine.Reflection.GetProperty <Vector2>(mines, "tileBeneathLadder").GetValue(); if (mines.getTileIndexAt(Utility.Vector2ToPoint(vector2), "Buildings") == -1) { mines.createLadderAt(vector2, "newArtifact"); } } } }
private void ReactOnAsk(NPC companion, Farmer leader, string action) { switch (action) { case "dismiss": Dialogue dismissalDialogue = new Dialogue(DialogueHelper.GetDialogueString(companion, "companionDismiss"), companion); this.dismissalDialogue = dismissalDialogue; DialogueHelper.DrawDialogue(dismissalDialogue); break; case "bag": Chest bag = this.StateMachine.Bag; this.StateMachine.Companion.currentLocation.playSound("openBox"); Game1.activeClickableMenu = new ItemGrabMenu(bag.items, false, true, new InventoryMenu.highlightThisItem(InventoryMenu.highlightAllItems), new ItemGrabMenu.behaviorOnItemSelect(bag.grabItemFromInventory), this.StateMachine.Companion.displayName, new ItemGrabMenu.behaviorOnItemSelect(bag.grabItemFromChest), false, true, true, true, true, 1, null, -1, this.StateMachine.Companion); break; } }
private void ReactOnAnswer(NPC n, Farmer leader) { if (leader.getFriendshipHeartLevelForNPC(n.Name) <= 4 || Game1.timeOfDay >= 2200) { Dialogue rejectionDialogue = new Dialogue( DialogueHelper.GetDialogueString( n, Game1.timeOfDay >= 2200 ? "companionRejectedNight" : "companionRejected"), n); this.rejectionDialogue = rejectionDialogue; DialogueHelper.DrawDialogue(rejectionDialogue); } else { Dialogue acceptalDialogue = new Dialogue(DialogueHelper.GetDialogueString(n, "companionAccepted"), n); this.acceptalDialogue = acceptalDialogue; DialogueHelper.DrawDialogue(acceptalDialogue); } }
private void GameLoop_TimeChanged(object sender, TimeChangedEventArgs e) { this.StateMachine.Companion.clearSchedule(); if (e.NewTime >= 2200) { NPC companion = this.StateMachine.Companion; Dialogue dismissalDialogue = new Dialogue(DialogueHelper.GetSpecificDialogueText(companion, this.StateMachine.CompanionManager.Farmer, "companionDismissAuto"), companion); this.dismissalDialogue = dismissalDialogue; this.StateMachine.Companion.doEmote(24); this.StateMachine.Companion.updateEmote(Game1.currentGameTime); DialogueHelper.DrawDialogue(dismissalDialogue); } // Fix spawn ladder if area is infested and all monsters is killed but NPC following us if (this.StateMachine.Companion.currentLocation is MineShaft mines && mines.mustKillAllMonstersToAdvance()) { var monsters = from c in mines.characters where c.IsMonster select c; if (monsters.Count() == 0) { Vector2 vector2 = this.StateMachine.Reflection.GetProperty <Vector2>(mines, "tileBeneathLadder").GetValue(); if (mines.getTileIndexAt(Utility.Vector2ToPoint(vector2), "Buildings") == -1) { mines.createLadderAt(vector2, "newArtifact"); } } } // Try to push new or change location dialogue randomly until or no location dialogue was pushed int until = this.dialoguePushTime + (Game1.random.Next(1, 3) * 10); if ((e.NewTime > until || this.currentLocationDialogue == null)) { this.TryPushLocationDialogue(this.StateMachine.Companion.currentLocation); } // Remove recruited dialogue if this dialogue not spoken until a hour from while companion was recruited if (this.recruitedDialogue != null && e.NewTime > this.timeOfRecruit + 100) { // TODO: Use here Remove old dialogue method when rebased onto branch or merged branch which has this util Stack <Dialogue> temp = new Stack <Dialogue>(this.StateMachine.Companion.CurrentDialogue.Count); while (this.StateMachine.Companion.CurrentDialogue.Count > 0) { Dialogue d = this.StateMachine.Companion.CurrentDialogue.Pop(); if (!d.Equals(this.recruitedDialogue)) { temp.Push(d); } else { this.monitor.Log($"Recruited dialogue was removed from {this.StateMachine.Name}'s stack due to NPC was recruited a hour ago and dialogue still not spoken."); } } while (temp.Count > 0) { this.StateMachine.Companion.CurrentDialogue.Push(temp.Pop()); } } }