예제 #1
0
        public async Task <IActionResult> Create([Bind("MovieTheaterNumber,Number,QtdRow,QtdCol,AddressCompanyId")] MovieTheater movieTheater)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    _context.Add(movieTheater);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException e)
                {
                    Debug.Write(e);
                    return(RedirectToAction(nameof(Create)));
                }
                catch (DbUpdateException e)
                {
                    Debug.Write(e);
                    TempData["erro"] = "Already exist, try another";
                    return(RedirectToAction(nameof(Create)));
                }

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AddressCompanyId"] = new SelectList(_context.AddressCompanies, "Id", "Name", movieTheater.AddressCompanyId);
            return(View(movieTheater));
        }
예제 #2
0
        static void Main(string[] args)
        {
            var mt = new MovieTheater(10, 10);

            mt.AddChair(new Chair(5, 5));
            mt.AddChair(new Chair(3, 6, true));

            Console.Write(mt);

            var movie = new Movie
            {
                Title       = "It, a coisa",
                ReleaseDate = new DateTime(2019, 09, 5),
                Genre       = "Terror, Thriller",
                Rating      = new Rating("NC-17", 17),
                Synopsis    = "Vinte e sete anos depos, o clube dos perdedores cresceu e se mudou, depois de um telefonema devastador eles irão retornar."
            };

            movie.ArtistList.Add(new Artist("james McAvoy"));
            movie.ArtistList.Add(new Artist("Javier Botet"));
            movie.ArtistList.Add(new Artist("Jessica Chastain"));
            movie.DirectorList.Add(new Artist("Andy Muschietti"));
            Console.WriteLine(movie);
            Console.WriteLine("UnB Cine Flix");
        }
예제 #3
0
 public async Task <IActionResult> CreateChair([Bind("MovieTheaterNumber,AddressCompanyId,Row,Col")] Chair chair)
 {
     if (ModelState.IsValid)
     {
         try
         {
             var movieTheater = new MovieTheater(await _context.MovieTheaters
                                                 .Include(m => m.Chairs)
                                                 .FirstOrDefaultAsync(m => (m.AddressCompanyId == chair.AddressCompanyId && m.MovieTheaterNumber == chair.MovieTheaterNumber)));
             movieTheater.AddChair(chair);
             _context.Add(chair);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateException e)
         {
             Debug.Write(e);
             TempData["erro"] = e.Message;
             return(RedirectToAction(nameof(CreateChair), new { chair.AddressCompanyId, chair.MovieTheaterNumber }));
         }
         catch (ArgumentException e)
         {
             Debug.Write(e);
             TempData["erro"] = e.Message;
             return(RedirectToAction(nameof(CreateChair), new { chair.AddressCompanyId, chair.MovieTheaterNumber }));
         }
         TempData["mensage"] = "Chair Create Success";
         return(RedirectToAction(nameof(Details), new { chair.AddressCompanyId, chair.MovieTheaterNumber }));
     }
     //ViewData["AddressCompanyId"] = new SelectList(_context.AddressCompanies, "Id", "Name", movieTheater.AddressCompanyId);
     return(View());
 }
예제 #4
0
        // Lists the current and next movie and crane game status as of the
        // given date.
        public static Prediction PredictForDate(SDate date)
        {
            Utilities.CheckWorldReady();
            if (!IsAvailable)
            {
                throw new UnavailableException("movies");
            }

            Prediction prediction = new ()
            {
                effectiveDate        = date,
                currentMovie         = MovieTheater.GetMovieForDate(date.ToWorldDate()),
                firstDateOfNextMovie = Utilities.GetNextSeasonStart(date),
            };

            prediction.nextMovie = MovieTheater.GetMovieForDate
                                       (prediction.firstDateOfNextMovie.ToWorldDate());

            // Logic from StardewValley.Locations.MovieTheater.addRandomNPCs()
            // as implemented in Stardew Predictor by MouseyPounds.
            if (Game1.getLocationFromName("MovieTheater") is MovieTheater theater)
            {
                Random rng = new ((int)Game1.uniqueIDForThisGame +
                                  date.DaysSinceStart - 1);
                prediction.craneGameAvailable = !(rng.NextDouble() < 0.25) &&
                                                theater.dayFirstEntered.Value != -1 &&
                                                theater.dayFirstEntered.Value != date.DaysSinceStart - 1;
            }

            return(prediction);
        }
        public void Repository_MovieTheater_deveria_gravar_uma_nova_sala()
        {
            //Arrange
            MovieTheater result = _repository.Add(_movieTheater);

            result.Id.Should().BeGreaterThan(0);
        }
예제 #6
0
        private static bool BeforePerformTouchAction(MovieTheater __instance, string fullActionString)
        {
            if (fullActionString.Split(' ')[0] == "Theater_Exit")
            {
                ClickToMoveManager.GetOrCreate(__instance).Reset();
            }

            return(true);
        }
예제 #7
0
 public Bird(Point point, MovieTheater location, int bird_type = 0)
 {
     startPosition.X     = (endPosition.X = point.X);
     startPosition.Y     = (endPosition.Y = point.Y);
     position.X          = ((float)startPosition.X + 0.5f) * 64f;
     position.Y          = ((float)startPosition.Y + 0.5f) * 64f;
     theater             = location;
     birdType            = bird_type;
     framesUntilNextMove = Game1.random.Next(100, 300);
     peckDirection       = Game1.random.Next(0, 2);
 }
        public void Repository_MovieTheater_deveria_retornar_uma_sala()
        {
            //Arrange
            MovieTheater movieTheater = _repository.Add(_movieTheater);

            //Action
            MovieTheater result = _repository.GetById(movieTheater.Id);

            //Assert
            result.Name.Should().Be(movieTheater.Name);
            result.Id.Should().Be(movieTheater.Id);
        }
        public void Repository_MovieTheater_deveria_deletar_uma_sala()
        {
            //Arrange
            MovieTheater newMovieTheater = _repository.Add(_movieTheater);

            //Action
            _repository.Delete(newMovieTheater.Id);

            //Assert
            MovieTheater result = _repository.GetById(newMovieTheater.Id);

            result.Should().BeNull();
        }
예제 #10
0
        public List <ShowTimeViewModel> GetAllShowTimeByMovieTheater(int movieId, int theaterId)
        {
            List <ShowTimeViewModel> showtimeList     = new List <ShowTimeViewModel>();
            MovieTheater             movietheaterItem = _movietheaterRepository.FindSingle(x => x.MovieId == movieId && x.TheaterId == theaterId && x.Movie.Status == Data.Enums.Status.NowShowing);

            if (movietheaterItem != null)
            {
                var query  = _showtimeRepository.FindAll(x => x.MovieTheaterId == movietheaterItem.Id).OrderBy(x => x.TimeShowing);
                var result = _mapper.Map <List <ShowTimeViewModel> >(query.ToList());
                return(result);
            }
            return(showtimeList);
        }
예제 #11
0
        /// <summary>Get how much each NPC likes watching this week's movie.</summary>
        public IEnumerable <KeyValuePair <NPC, GiftTaste> > GetMovieTastes()
        {
            foreach (NPC npc in this.GetAllCharacters())
            {
                if (!this.IsSocialVillager(npc))
                {
                    continue;
                }

                GiftTaste taste = (GiftTaste)Enum.Parse(typeof(GiftTaste), MovieTheater.GetResponseForMovie(npc), ignoreCase: true);
                yield return(new KeyValuePair <NPC, GiftTaste>(npc, taste));
            }
        }
        public void SetUp()
        {
            var connection = DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString());

            Context       = new FakeDbContext(connection);
            _repository   = new MovieTheatersRepository(Context);
            _movieTheater = ObjectMother.movieTheaterDefault;

            _movieTheaterSeed = ObjectMother.movieTheaterDefault;

            Context.MovieTheaters.Add(_movieTheaterSeed);
            Context.SaveChanges();
        }
예제 #13
0
        /// <summary>Get the data to display for this subject.</summary>
        public override IEnumerable <ICustomField> GetData()
        {
            MovieConcession item = this.Target;

            // date's taste
            NPC date = Game1.player.team.movieInvitations.FirstOrDefault(p => p.farmer == Game1.player)?.invitedNPC;

            if (date != null)
            {
                string taste = MovieTheater.GetConcessionTasteForCharacter(date, item);
                yield return(new GenericField(this.GameHelper, L10n.MovieSnack.Preference(), L10n.MovieSnack.ForTaste(taste, date.Name)));
            }
        }
예제 #14
0
        public static void GetMovieForDate(ref MovieData __result, WorldDate date)
        {
            bool next = false;

            if (date != new WorldDate(Game1.Date))
            {
                date.TotalDays -= 21;
                next            = true;
            }

            int r = date.TotalDays / 7;

            var data = MovieTheater.GetMovieData();

            string season = Game1.currentSeason;

            if (next && Game1.dayOfMonth > 21)
            {
                switch (season)
                {
                case "spring": season = "summer"; break;

                case "summer": season = "fall"; break;

                case "fall": season = "winter"; break;

                case "winter": season = "spring"; break;
                }
            }

            List <MovieData> movies = data.Values.Where(m => m.ID.StartsWith(season)).ToList();

            __result = movies[r % movies.Count];

            if (__result.Tags.Contains("CustomMovie"))
            {
                CMVAssetEditor.CurrentMovie = allTheMovies[__result.Tags.Find(t => t.StartsWith("CMovieID:")).Split(':')[1]];
            }
            else
            {
                CMVAssetEditor.CurrentMovie = null;
            }

            if (lastMovie != CMVAssetEditor.CurrentMovie)
            {
                cmHelper.Content.InvalidateCache(@"LooseSprites\Movies");
            }

            lastMovie = CMVAssetEditor.CurrentMovie;
        }
        public void Repository_MovieTheater_deveria_alterar_uma_nova_sala()
        {
            //Arrange
            MovieTheater newMovieTheater = _repository.Add(_movieTheater);

            newMovieTheater.Name = "Name";

            //Action
            _repository.Update(newMovieTheater);

            //Assert
            MovieTheater result = _repository.GetById(newMovieTheater.Id);

            result.Name.Should().Be(newMovieTheater.Name);
        }
예제 #16
0
        // GET: MovieTheaters/Details/5
        public async Task <IActionResult> Details(int addressCompanyId, int movieTheaterNumber)
        {
            ViewData["mensage"] = TempData["mensage"];
            var movieTheater = new MovieTheater(await _context.MovieTheaters
                                                .Include(m => m.Chairs)
                                                .Include(m => m.AddressCompany)
                                                .FirstOrDefaultAsync(m => (m.MovieTheaterNumber == movieTheaterNumber && m.AddressCompanyId == addressCompanyId)));

            if (movieTheater == null)
            {
                return(NotFound());
            }

            return(View(movieTheater));
        }
예제 #17
0
        public void ApplService_MovieTheater_deveria_retornar_sala_de_cinema()
        {
            //Arrange
            MovieTheater movieTheater = ObjectMother.movieTheaterDefault;

            _repository.Setup(x => x.GetById(It.IsAny <long>())).Returns(movieTheater);

            //Action
            MovieTheater movieTheaterResult = _appService.GetById(movieTheater.Id);

            //Assert
            _repository.Verify(p => p.GetById(It.IsAny <long>()), Times.Once());
            movieTheaterResult.Should().NotBeNull();
            movieTheaterResult.Id.Should().Be(movieTheater.Id);
            _repository.VerifyNoOtherCalls();
        }
예제 #18
0
        public void loadContentPacks()
        {
            Dictionary <string, MovieData> movieData        = MovieTheater.GetMovieData();
            List <MovieCharacterReaction>  genericReactions = MovieTheater.GetMovieReactions();

            foreach (var pack in Helper.ContentPacks.GetOwned())
            {
                CustomMoviePack cPack = pack.ReadJsonFile <CustomMoviePack>("content.json");

                foreach (var movie in cPack.Movies)
                {
                    movie.LoadTexture(pack);
                    movie._pack = pack;

                    int y = 0;

                    while (movieData.ContainsKey(movie.Season + "_movie_" + y))
                    {
                        y++;
                    }

                    movie.FixedMovieID = movie.FixedMovieID == null ? movie.Season + "_movie_" + y : movie.FixedMovieID;
                    Monitor.Log("Added " + movie.Title + " as " + movie.FixedMovieID);
                    MovieData fixedData = movie.GetData(y);
                    fixedData.ID = movie.FixedMovieID;
                    movieData.AddOrReplace(fixedData.ID, fixedData);
                    allTheMovies.AddOrReplace(movie.Id, movie);
                }

                typeof(MovieTheater).GetField("_movieData", BindingFlags.NonPublic | BindingFlags.Static).SetValue(null, movieData);

                foreach (var reaction in cPack.Reactions)
                {
                    foreach (var r in reaction.Reactions)
                    {
                        if (r.Tag != null && allTheMovies.ContainsKey(r.Tag))
                        {
                            r.Tag = "CMovieID:" + r.Tag;
                        }
                    }

                    allTheReactions.AddOrReplace(new TranslatableMovieReactions(reaction, pack));
                }
            }
        }
예제 #19
0
 protected void _ParseResponse(StringBuilder sb, MovieScene scene = null)
 {
     if (_responseOrder.ContainsKey(currentResponse))
     {
         sb.Append("/pause 500");
         Character responding_character = _responseOrder[currentResponse];
         bool      hadUniqueScript      = false;
         if (!_whiteListDependencyLookup.ContainsKey(responding_character))
         {
             MovieCharacterReaction reaction = MovieTheater.GetReactionsForCharacter(responding_character as NPC);
             if (reaction != null)
             {
                 foreach (MovieReaction movie_reaction in reaction.Reactions)
                 {
                     if (movie_reaction.ShouldApplyToMovie(movieData, MovieTheater.GetPatronNames(), MovieTheater.GetResponseForMovie(responding_character as NPC)) && movie_reaction.SpecialResponses != null && movie_reaction.SpecialResponses.DuringMovie != null && (movie_reaction.SpecialResponses.DuringMovie.ResponsePoint == null || movie_reaction.SpecialResponses.DuringMovie.ResponsePoint == "" || (scene != null && movie_reaction.SpecialResponses.DuringMovie.ResponsePoint == scene.ResponsePoint) || movie_reaction.SpecialResponses.DuringMovie.ResponsePoint == currentResponse.ToString() || movie_reaction.Whitelist.Count > 0))
                     {
                         if (movie_reaction.SpecialResponses.DuringMovie.Script != "")
                         {
                             sb.Append(movie_reaction.SpecialResponses.DuringMovie.Script);
                             hadUniqueScript = true;
                         }
                         if (movie_reaction.SpecialResponses.DuringMovie.Text != "")
                         {
                             sb.Append("/speak " + responding_character.name + " \"" + movie_reaction.SpecialResponses.DuringMovie.Text + "\"");
                         }
                         break;
                     }
                 }
             }
         }
         _ParseCharacterResponse(sb, responding_character, hadUniqueScript);
         foreach (Character key in _whiteListDependencyLookup.Keys)
         {
             if (_whiteListDependencyLookup[key] == responding_character)
             {
                 _ParseCharacterResponse(sb, key);
             }
         }
     }
     currentResponse++;
 }
예제 #20
0
 /// <summary>Allows generic interactions with NPCs in <see cref="MovieTheater"/> under certain conditions.</summary>
 /// <param name="__instance">The <see cref="MovieTheater"/> instance.</param>
 /// <param name="tileLocation">The tile targeted by this action.</param>
 /// <param name="viewport">The viewport of the player performing this action.</param>
 /// <param name="who">The player performing this action.</param>
 /// <param name="____playerInvitedPatrons">The list of NPCs invited by the player. Non-public field for this <see cref="MovieTheater"/> instance.</param>
 /// <param name="____characterGroupLookup">The list of NPC patrons currently present. Non-public field for this <see cref="MovieTheater"/> instance.</param>
 /// <param name="__result">The result of the original method.</param>
 private static void MovieTheater_checkAction(MovieTheater __instance,
                                              Location tileLocation,
                                              xTile.Dimensions.Rectangle viewport,
                                              Farmer who,
                                              NetStringDictionary <int, NetInt> ____playerInvitedPatrons,
                                              NetStringDictionary <bool, NetBool> ____characterGroupLookup,
                                              ref bool __result)
 {
     try
     {
         if (__result == true) //if the original method return true
         {
             PropertyValue action = null;
             __instance.map.GetLayer("Buildings").PickTile(new Location(tileLocation.X * 64, tileLocation.Y * 64), viewport.Size)?.Properties.TryGetValue("Action", out action); //get this tile's Action property if it exists
             if (action == null)                                                                                                                                                 //if this tile does NOT have an Action property
             {
                 Microsoft.Xna.Framework.Rectangle tileRect = new Microsoft.Xna.Framework.Rectangle(tileLocation.X * 64, tileLocation.Y * 64, 64, 64);                           //get this tile's pixel area
                 foreach (NPC npc in __instance.characters)                                                                                                                      //for each NPC in this location
                 {
                     if (npc.isVillager() && npc.GetBoundingBox().Intersects(tileRect))                                                                                          //if this NPC is a villager and targeted by this action
                     {
                         string npcName = npc.Name;
                         if (____playerInvitedPatrons.ContainsKey(npcName) == false && ____characterGroupLookup.ContainsKey(npcName) == false) //if this NPC is NOT here as a patron (i.e. does not have patron-specific dialogue or behavior)
                         {
                             __result = npc.checkAction(who, __instance);                                                                      //check action on this NPC (i.e. talk/give gifts/etc) and override the result
                             return;
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Monitor.LogOnce($"Harmony patch \"{nameof(HarmonyPatch_MovieTheaterNPCs)}\" has encountered an error. Postfix \"{nameof(MovieTheater_checkAction)}\" might malfunction or revert to default behavior. Full error message: \n{ex.ToString()}", LogLevel.Error);
         return; //run the original method
     }
 }
 public bool Update(MovieTheater movieTheater)
 {
     Context.Entry(movieTheater).State = EntityState.Modified;
     return(Context.SaveChanges() > 0);
 }
예제 #22
0
        public async Task <IActionResult> Edit(int addressCompanyId, int movieTheaterNumber, [Bind("MovieTheaterNumber,QtdRow,QtdCol,AddressCompanyId")] MovieTheater movieTheater)
        {
            if (addressCompanyId != movieTheater.AddressCompanyId && movieTheaterNumber != movieTheater.MovieTheaterNumber)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(movieTheater);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MovieTheaterExists(movieTheater.AddressCompanyId, movieTheater.MovieTheaterNumber))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw new Exception("Impossible to Update");
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AddressCompanyId"] = new SelectList(_context.AddressCompanies, "Id", "Name", movieTheater.AddressCompanyId);
            return(View(movieTheater));
        }
예제 #23
0
        public MovieTheater Add(string name, int numberOfRows, int numberOfColumns)
        {
            var movieTheater = MovieTheater.Create(name, numberOfRows, numberOfColumns);

            return(movieTheaterRepository.Add(movieTheater));
        }
예제 #24
0
        /// <summary>Get the data to display for this subject.</summary>
        public override IEnumerable <ICustomField> GetData()
        {
            // get data
            Item    item          = this.Target;
            SObject?obj           = item as SObject;
            bool    isCrop        = this.FromCrop != null;
            bool    isSeed        = this.SeedForCrop != null;
            bool    isDeadCrop    = this.FromCrop?.dead.Value == true;
            bool    canSell       = obj?.canBeShipped() == true || this.Metadata.Shops.Any(shop => shop.BuysCategories.Contains(item.Category));
            bool    isMovieTicket = obj?.ParentSheetIndex == 809 && !obj.bigCraftable.Value;

            // get overrides
            bool showInventoryFields = !this.IsSpawnedStoneNode();

            {
                ObjectData?objData = this.Metadata.GetObject(item, this.Context);
                if (objData != null)
                {
                    this.Name = objData.NameKey != null?I18n.GetByKey(objData.NameKey) : this.Name;

                    this.Description = objData.DescriptionKey != null?I18n.GetByKey(objData.DescriptionKey) : this.Description;

                    this.Type = objData.TypeKey != null?I18n.GetByKey(objData.TypeKey) : this.Type;

                    showInventoryFields = objData.ShowInventoryFields ?? showInventoryFields;
                }
            }

            // don't show data for dead crop
            if (isDeadCrop)
            {
                yield return(new GenericField(I18n.Crop_Summary(), I18n.Crop_Summary_Dead()));

                yield break;
            }

            // crop fields
            foreach (ICustomField field in this.GetCropFields(this.FromDirt, this.FromCrop ?? this.SeedForCrop, isSeed))
            {
                yield return(field);
            }

            // indoor pot crop
            if (obj is IndoorPot pot)
            {
                Crop?potCrop = pot.hoeDirt.Value.crop;
                Bush?potBush = pot.bush.Value;

                if (potCrop != null)
                {
                    Item drop = this.GameHelper.GetObjectBySpriteIndex(potCrop.indexOfHarvest.Value);
                    yield return(new LinkField(I18n.Item_Contents(), drop.DisplayName, () => this.GetCropSubject(potCrop, ObjectContext.World, pot.hoeDirt.Value)));
                }

                if (potBush != null)
                {
                    ISubject?subject = this.Codex.GetByEntity(potBush, this.Location ?? potBush.currentLocation);
                    if (subject != null)
                    {
                        yield return(new LinkField(I18n.Item_Contents(), subject.Name, () => subject));
                    }
                }
            }

            // machine output
            foreach (ICustomField field in this.GetMachineOutputFields(obj))
            {
                yield return(field);
            }

            // music blocks
            if (obj?.Name == "Flute Block")
            {
                yield return(new GenericField(I18n.Item_MusicBlock_Pitch(), I18n.Generic_Ratio(value: obj.preservedParentSheetIndex.Value, max: 2300)));
            }
            else if (obj?.Name == "Drum Block")
            {
                yield return(new GenericField(I18n.Item_MusicBlock_DrumType(), I18n.Generic_Ratio(value: obj.preservedParentSheetIndex.Value, max: 6)));
            }

            // item
            if (showInventoryFields)
            {
                // needed for
                foreach (ICustomField field in this.GetNeededForFields(obj))
                {
                    yield return(field);
                }

                // sale data
                if (canSell && !isCrop)
                {
                    // sale price
                    string?saleValueSummary = GenericField.GetSaleValueString(this.GetSaleValue(item, this.KnownQuality), item.Stack);
                    yield return(new GenericField(I18n.Item_SellsFor(), saleValueSummary));

                    // sell to
                    List <string> buyers = new();
                    if (obj?.canBeShipped() == true)
                    {
                        buyers.Add(I18n.Item_SellsTo_ShippingBox());
                    }
                    buyers.AddRange(
                        from shop in this.Metadata.Shops
                        where shop.BuysCategories.Contains(item.Category)
                        let name = I18n.GetByKey(shop.DisplayKey).ToString()
                                   orderby name
                                   select name
                        );
                    yield return(new GenericField(I18n.Item_SellsTo(), string.Join(", ", buyers)));
                }

                // clothing
                if (item is Clothing clothing)
                {
                    yield return(new GenericField(I18n.Item_CanBeDyed(), this.Stringify(clothing.dyeable.Value)));
                }

                // gift tastes
                if (!isMovieTicket)
                {
                    IDictionary <GiftTaste, GiftTasteModel[]> giftTastes = this.GetGiftTastes(item);
                    yield return(new ItemGiftTastesField(I18n.Item_LovesThis(), giftTastes, GiftTaste.Love, onlyRevealed: this.ProgressionMode, highlightUnrevealed: this.HighlightUnrevealedGiftTastes));

                    yield return(new ItemGiftTastesField(I18n.Item_LikesThis(), giftTastes, GiftTaste.Like, onlyRevealed: this.ProgressionMode, highlightUnrevealed: this.HighlightUnrevealedGiftTastes));

                    if (this.ProgressionMode || this.HighlightUnrevealedGiftTastes || this.ShowAllGiftTastes)
                    {
                        yield return(new ItemGiftTastesField(I18n.Item_NeutralAboutThis(), giftTastes, GiftTaste.Neutral, onlyRevealed: this.ProgressionMode, highlightUnrevealed: this.HighlightUnrevealedGiftTastes));

                        yield return(new ItemGiftTastesField(I18n.Item_DislikesThis(), giftTastes, GiftTaste.Dislike, onlyRevealed: this.ProgressionMode, highlightUnrevealed: this.HighlightUnrevealedGiftTastes));

                        yield return(new ItemGiftTastesField(I18n.Item_HatesThis(), giftTastes, GiftTaste.Hate, onlyRevealed: this.ProgressionMode, highlightUnrevealed: this.HighlightUnrevealedGiftTastes));
                    }
                }
            }

            // recipes
            if (showInventoryFields)
            {
                RecipeModel[] recipes =
                    // recipes that take this item as ingredient
                    this.GameHelper.GetRecipesForIngredient(this.DisplayItem)
                    .Concat(this.GameHelper.GetRecipesForIngredient(item))

                    // recipes which produce this item
                    .Concat(this.GameHelper.GetRecipesForOutput(this.DisplayItem))
                    .Concat(this.GameHelper.GetRecipesForOutput(item))

                    // recipes for a machine
                    .Concat(this.GameHelper.GetRecipesForMachine(this.DisplayItem as SObject))
                    .Concat(this.GameHelper.GetRecipesForMachine(item as SObject))
                    .ToArray();

                if (recipes.Any())
                {
                    yield return(new ItemRecipesField(this.GameHelper, I18n.Item_Recipes(), item, recipes.ToArray()));
                }
            }

            // fish spawn rules
            if (item.Category == SObject.FishCategory)
            {
                yield return(new FishSpawnRulesField(this.GameHelper, I18n.Item_FishSpawnRules(), item.ParentSheetIndex));
            }

            // fish pond data
            // derived from FishPond::doAction and FishPond::isLegalFishForPonds
            if (!item.HasContextTag("fish_legendary") && (item.Category == SObject.FishCategory || Utility.IsNormalObjectAtParentSheetIndex(item, 393 /*coral*/) || Utility.IsNormalObjectAtParentSheetIndex(item, 397 /*sea urchin*/)))
            {
                foreach (FishPondData fishPondData in Game1.content.Load <List <FishPondData> >("Data\\FishPondData"))
                {
                    if (!fishPondData.RequiredTags.All(item.HasContextTag))
                    {
                        continue;
                    }

                    int    minChanceOfAnyDrop = (int)Math.Round(Utility.Lerp(0.15f, 0.95f, 1 / 10f) * 100);
                    int    maxChanceOfAnyDrop = (int)Math.Round(Utility.Lerp(0.15f, 0.95f, FishPond.MAXIMUM_OCCUPANCY / 10f) * 100);
                    string preface            = I18n.Building_FishPond_Drops_Preface(chance: I18n.Generic_Range(min: minChanceOfAnyDrop, max: maxChanceOfAnyDrop));
                    yield return(new FishPondDropsField(this.GameHelper, I18n.Item_FishPondDrops(), -1, fishPondData, preface));

                    break;
                }
            }

            // fence
            if (item is Fence fence)
            {
                string healthLabel = I18n.Item_FenceHealth();

                // health
                if (Game1.getFarm().isBuildingConstructed(Constant.BuildingNames.GoldClock))
                {
                    yield return(new GenericField(healthLabel, I18n.Item_FenceHealth_GoldClock()));
                }
                else
                {
                    float  maxHealth = fence.isGate.Value ? fence.maxHealth.Value * 2 : fence.maxHealth.Value;
                    float  health    = fence.health.Value / maxHealth;
                    double daysLeft  = Math.Round(fence.health.Value * this.Constants.FenceDecayRate / 60 / 24);
                    double percent   = Math.Round(health * 100);
                    yield return(new PercentageBarField(healthLabel, (int)fence.health.Value, (int)maxHealth, Color.Green, Color.Red, I18n.Item_FenceHealth_Summary(percent: (int)percent, count: (int)daysLeft)));
                }
            }

            // movie ticket
            if (isMovieTicket)
            {
                MovieData movie = MovieTheater.GetMovieForDate(Game1.Date);
                if (movie == null)
                {
                    yield return(new GenericField(I18n.Item_MovieTicket_MovieThisWeek(), I18n.Item_MovieTicket_MovieThisWeek_None()));
                }
                else
                {
                    // movie this week
                    yield return(new GenericField(I18n.Item_MovieTicket_MovieThisWeek(), new IFormattedText[]
                    {
                        new FormattedText(movie.Title, bold: true),
                        new FormattedText(Environment.NewLine),
                        new FormattedText(movie.Description)
                    }));

                    // movie tastes
                    const GiftTaste rejectKey = (GiftTaste)(-1);
                    IDictionary <GiftTaste, string[]> tastes = this.GameHelper.GetMovieTastes()
                                                               .GroupBy(entry => entry.Value ?? rejectKey)
                                                               .ToDictionary(group => group.Key, group => group.Select(p => p.Key.Name).OrderBy(p => p).ToArray());

                    yield return(new MovieTastesField(I18n.Item_MovieTicket_LovesMovie(), tastes, GiftTaste.Love));

                    yield return(new MovieTastesField(I18n.Item_MovieTicket_LikesMovie(), tastes, GiftTaste.Like));

                    yield return(new MovieTastesField(I18n.Item_MovieTicket_DislikesMovie(), tastes, GiftTaste.Dislike));

                    yield return(new MovieTastesField(I18n.Item_MovieTicket_RejectsMovie(), tastes, rejectKey));
                }
            }

            // dyes
            if (showInventoryFields)
            {
                yield return(new ColorField(I18n.Item_ProducesDye(), item));
            }

            // owned and times cooked/crafted
            if (showInventoryFields && !isCrop)
            {
                // owned
                yield return(new GenericField(I18n.Item_NumberOwned(), I18n.Item_NumberOwned_Summary(count: this.GameHelper.CountOwnedItems(item))));

                // times crafted
                RecipeModel[] recipes = this.GameHelper
                                        .GetRecipes()
                                        .Where(recipe => recipe.OutputItemIndex == this.Target.ParentSheetIndex && recipe.OutputItemType == this.Target.GetItemType())
                                        .ToArray();
                if (recipes.Any())
                {
                    string label        = recipes.First().Type == RecipeType.Cooking ? I18n.Item_NumberCooked() : I18n.Item_NumberCrafted();
                    int    timesCrafted = recipes.Sum(recipe => recipe.GetTimesCrafted(Game1.player));
                    if (timesCrafted >= 0) // negative value means not available for this recipe type
                    {
                        yield return(new GenericField(label, I18n.Item_NumberCrafted_Summary(count: timesCrafted)));
                    }
                }
            }

            // see also crop
            bool seeAlsoCrop =
                isSeed &&
                item.ParentSheetIndex != this.SeedForCrop !.indexOfHarvest.Value && // skip seeds which produce themselves (e.g. coffee beans)
                item.ParentSheetIndex is not(495 or 496 or 497) &&  // skip random seasonal seeds
                item.ParentSheetIndex != 770;    // skip mixed seeds

            if (seeAlsoCrop)
            {
                Item drop = this.GameHelper.GetObjectBySpriteIndex(this.SeedForCrop !.indexOfHarvest.Value);
                yield return(new LinkField(I18n.Item_SeeAlso(), drop.DisplayName, () => this.GetCropSubject(this.SeedForCrop, ObjectContext.Inventory, null)));
            }
        }
예제 #25
0
        /// <summary>Get the data to display for this subject.</summary>
        public override IEnumerable <ICustomField> GetData()
        {
            // get data
            Item    item       = this.Target;
            SObject obj        = item as SObject;
            bool    isCrop     = this.FromCrop != null;
            bool    isSeed     = this.SeedForCrop != null;
            bool    isDeadCrop = this.FromCrop?.dead.Value == true;
            bool    canSell    = obj?.canBeShipped() == true || this.Metadata.Shops.Any(shop => shop.BuysCategories.Contains(item.Category));

            // get overrides
            bool showInventoryFields = true;

            {
                ObjectData objData = this.Metadata.GetObject(item, this.Context);
                if (objData != null)
                {
                    this.Name = objData.NameKey != null?L10n.GetRaw(objData.NameKey) : this.Name;

                    this.Description = objData.DescriptionKey != null?L10n.GetRaw(objData.DescriptionKey) : this.Description;

                    this.Type = objData.TypeKey != null?L10n.GetRaw(objData.TypeKey) : this.Type;

                    showInventoryFields = objData.ShowInventoryFields ?? true;
                }
            }

            // don't show data for dead crop
            if (isDeadCrop)
            {
                yield return(new GenericField(this.GameHelper, L10n.Crop.Summary(), L10n.Crop.SummaryDead()));

                yield break;
            }

            // crop fields
            foreach (ICustomField field in this.GetCropFields(this.FromCrop ?? this.SeedForCrop, isSeed))
            {
                yield return(field);
            }

            // indoor pot crop
            if (obj is IndoorPot pot)
            {
                Crop potCrop = pot.hoeDirt.Value.crop;
                if (potCrop != null)
                {
                    Item drop = this.GameHelper.GetObjectBySpriteIndex(potCrop.indexOfHarvest.Value);
                    yield return(new LinkField(this.GameHelper, L10n.Item.Contents(), drop.DisplayName, () => this.Codex.GetCrop(potCrop, ObjectContext.World)));
                }
            }

            // machine output
            foreach (ICustomField field in this.GetMachineOutputFields(obj))
            {
                yield return(field);
            }

            // item
            if (showInventoryFields)
            {
                // needed for
                foreach (ICustomField field in this.GetNeededForFields(obj))
                {
                    yield return(field);
                }

                // sale data
                if (canSell && !isCrop)
                {
                    // sale price
                    string saleValueSummary = GenericField.GetSaleValueString(this.GetSaleValue(item, this.KnownQuality), item.Stack, this.Text);
                    yield return(new GenericField(this.GameHelper, L10n.Item.SellsFor(), saleValueSummary));

                    // sell to
                    List <string> buyers = new List <string>();
                    if (obj?.canBeShipped() == true)
                    {
                        buyers.Add(L10n.Item.SellsToShippingBox());
                    }
                    buyers.AddRange(
                        from shop in this.Metadata.Shops
                        where shop.BuysCategories.Contains(item.Category)
                        let name = L10n.GetRaw(shop.DisplayKey).ToString()
                                   orderby name
                                   select name
                        );
                    yield return(new GenericField(this.GameHelper, L10n.Item.SellsTo(), string.Join(", ", buyers)));
                }

                // clothing
                if (item is Clothing clothing)
                {
                    yield return(new GenericField(this.GameHelper, L10n.Item.CanBeDyed(), this.Stringify(clothing.dyeable.Value)));
                }

                // gift tastes
                IDictionary <GiftTaste, GiftTasteModel[]> giftTastes = this.GetGiftTastes(item);
                yield return(new ItemGiftTastesField(this.GameHelper, L10n.Item.LovesThis(), giftTastes, GiftTaste.Love, onlyRevealed: this.ProgressionMode, highlightUnrevealed: this.HighlightUnrevealedGiftTastes));

                yield return(new ItemGiftTastesField(this.GameHelper, L10n.Item.LikesThis(), giftTastes, GiftTaste.Like, onlyRevealed: this.ProgressionMode, highlightUnrevealed: this.HighlightUnrevealedGiftTastes));

                if (this.ProgressionMode || this.HighlightUnrevealedGiftTastes)
                {
                    yield return(new ItemGiftTastesField(this.GameHelper, L10n.Item.NeutralAboutThis(), giftTastes, GiftTaste.Neutral, onlyRevealed: this.ProgressionMode, highlightUnrevealed: this.HighlightUnrevealedGiftTastes));

                    yield return(new ItemGiftTastesField(this.GameHelper, L10n.Item.DislikesThis(), giftTastes, GiftTaste.Dislike, onlyRevealed: this.ProgressionMode, highlightUnrevealed: this.HighlightUnrevealedGiftTastes));

                    yield return(new ItemGiftTastesField(this.GameHelper, L10n.Item.HatesThis(), giftTastes, GiftTaste.Hate, onlyRevealed: this.ProgressionMode, highlightUnrevealed: this.HighlightUnrevealedGiftTastes));
                }
            }

            // recipes
            switch (item.GetItemType())
            {
            // for ingredient
            case ItemType.Object:
            {
                RecipeModel[] recipes = this.GameHelper.GetRecipesForIngredient(this.DisplayItem).ToArray();
                if (recipes.Any())
                {
                    yield return(new RecipesForIngredientField(this.GameHelper, L10n.Item.Recipes(), item, recipes));
                }
            }
            break;

            // for machine
            case ItemType.BigCraftable:
            {
                RecipeModel[] recipes = this.GameHelper.GetRecipesForMachine(this.DisplayItem as SObject).ToArray();
                if (recipes.Any())
                {
                    yield return(new RecipesForMachineField(this.GameHelper, L10n.Item.Recipes(), recipes));
                }
            }
            break;
            }

            // fish
            if (item.Category == SObject.FishCategory)
            {
                // spawn rules
                yield return(new FishSpawnRulesField(this.GameHelper, L10n.Item.FishSpawnRules(), item.ParentSheetIndex, this.Text));

                // fish pond data
                foreach (FishPondData fishPondData in Game1.content.Load <List <FishPondData> >("Data\\FishPondData"))
                {
                    if (!fishPondData.RequiredTags.All(item.HasContextTag))
                    {
                        continue;
                    }

                    int    minChanceOfAnyDrop = (int)Math.Round(Utility.Lerp(0.15f, 0.95f, 1 / 10f) * 100);
                    int    maxChanceOfAnyDrop = (int)Math.Round(Utility.Lerp(0.15f, 0.95f, FishPond.MAXIMUM_OCCUPANCY / 10f) * 100);
                    string preface            = L10n.Building.FishPondDropsPreface(chance: L10n.Generic.Range(min: minChanceOfAnyDrop, max: maxChanceOfAnyDrop));
                    yield return(new FishPondDropsField(this.GameHelper, L10n.Item.FishPondDrops(), -1, fishPondData, preface));

                    break;
                }
            }

            // fence
            if (item is Fence fence)
            {
                string healthLabel = L10n.Item.FenceHealth();

                // health
                if (Game1.getFarm().isBuildingConstructed(Constant.BuildingNames.GoldClock))
                {
                    yield return(new GenericField(this.GameHelper, healthLabel, L10n.Item.FenceHealthGoldClock()));
                }
                else
                {
                    float  maxHealth = fence.isGate.Value ? fence.maxHealth.Value * 2 : fence.maxHealth.Value;
                    float  health    = fence.health.Value / maxHealth;
                    double daysLeft  = Math.Round(fence.health.Value * this.Constants.FenceDecayRate / 60 / 24);
                    double percent   = Math.Round(health * 100);
                    yield return(new PercentageBarField(this.GameHelper, healthLabel, (int)fence.health.Value, (int)maxHealth, Color.Green, Color.Red, L10n.Item.FenceHealthSummary(percent: (int)percent, count: (int)daysLeft)));
                }
            }

            // movie ticket
            if (obj?.ParentSheetIndex == 809 && !obj.bigCraftable.Value)
            {
                MovieData movie = MovieTheater.GetMovieForDate(Game1.Date);
                if (movie == null)
                {
                    yield return(new GenericField(this.GameHelper, L10n.MovieTicket.MovieThisWeek(), L10n.MovieTicket.NoMovieThisWeek()));
                }
                else
                {
                    // movie this week
                    yield return(new GenericField(this.GameHelper, L10n.MovieTicket.MovieThisWeek(), new IFormattedText[]
                    {
                        new FormattedText(movie.Title, bold: true),
                        new FormattedText(Environment.NewLine),
                        new FormattedText(movie.Description)
                    }));

                    // movie tastes
                    IDictionary <GiftTaste, string[]> tastes = this.GameHelper.GetMovieTastes()
                                                               .GroupBy(entry => entry.Value)
                                                               .ToDictionary(group => group.Key, group => group.Select(p => p.Key.Name).OrderBy(p => p).ToArray());

                    yield return(new MovieTastesField(this.GameHelper, L10n.MovieTicket.LovesMovie(), tastes, GiftTaste.Love));

                    yield return(new MovieTastesField(this.GameHelper, L10n.MovieTicket.LikesMovie(), tastes, GiftTaste.Like));

                    yield return(new MovieTastesField(this.GameHelper, L10n.MovieTicket.DislikesMovie(), tastes, GiftTaste.Dislike));
                }
            }

            // dyes
            yield return(new ColorField(this.GameHelper, L10n.Item.ProducesDye(), item));

            // owned and times cooked/crafted
            if (showInventoryFields && !isCrop)
            {
                // owned
                yield return(new GenericField(this.GameHelper, L10n.Item.Owned(), L10n.Item.OwnedSummary(count: this.GameHelper.CountOwnedItems(item))));

                // times crafted
                RecipeModel[] recipes = this.GameHelper
                                        .GetRecipes()
                                        .Where(recipe => recipe.OutputItemIndex == this.Target.ParentSheetIndex)
                                        .ToArray();
                if (recipes.Any())
                {
                    string label        = recipes.First().Type == RecipeType.Cooking ? L10n.Item.Cooked() : L10n.Item.Crafted();
                    int    timesCrafted = recipes.Sum(recipe => recipe.GetTimesCrafted(Game1.player));
                    if (timesCrafted >= 0) // negative value means not available for this recipe type
                    {
                        yield return(new GenericField(this.GameHelper, label, L10n.Item.CraftedSummary(count: timesCrafted)));
                    }
                }
            }

            // see also crop
            bool seeAlsoCrop =
                isSeed &&
                item.ParentSheetIndex != this.SeedForCrop.indexOfHarvest.Value && // skip seeds which produce themselves (e.g. coffee beans)
                !(item.ParentSheetIndex >= 495 && item.ParentSheetIndex <= 497) && // skip random seasonal seeds
                item.ParentSheetIndex != 770;    // skip mixed seeds

            if (seeAlsoCrop)
            {
                Item drop = this.GameHelper.GetObjectBySpriteIndex(this.SeedForCrop.indexOfHarvest.Value);
                yield return(new LinkField(this.GameHelper, L10n.Item.SeeAlso(), drop.DisplayName, () => this.Codex.GetCrop(this.SeedForCrop, ObjectContext.Inventory)));
            }
        }
예제 #26
0
        protected void _ParseCharacterResponse(StringBuilder sb, Character responding_character, bool ignoreScript = false)
        {
            string response = MovieTheater.GetResponseForMovie(responding_character as NPC);

            if (_whiteListDependencyLookup.ContainsKey(responding_character))
            {
                response = MovieTheater.GetResponseForMovie(_whiteListDependencyLookup[responding_character] as NPC);
            }
            if (!(response == "love"))
            {
                if (!(response == "like"))
                {
                    if (response == "dislike")
                    {
                        sb.Append("/friendship " + responding_character.Name + " " + 0);
                        if (!ignoreScript)
                        {
                            sb.Append("/playSound newArtifact/emote " + (string)responding_character.name + " " + 24 + "/message \"" + Game1.content.LoadString("Strings\\Characters:MovieTheater_DislikeMovie", responding_character.displayName) + "\"");
                        }
                    }
                }
                else
                {
                    sb.Append("/friendship " + responding_character.Name + " " + 100);
                    if (!ignoreScript)
                    {
                        sb.Append("/playSound give_gift/emote " + (string)responding_character.name + " " + 56 + "/message \"" + Game1.content.LoadString("Strings\\Characters:MovieTheater_LikeMovie", responding_character.displayName) + "\"");
                    }
                }
            }
            else
            {
                sb.Append("/friendship " + responding_character.Name + " " + 200);
                if (!ignoreScript)
                {
                    sb.Append("/playSound reward/emote " + (string)responding_character.name + " " + 20 + "/message \"" + Game1.content.LoadString("Strings\\Characters:MovieTheater_LoveMovie", responding_character.displayName) + "\"");
                }
            }
            if (_concessionsData != null && _concessionsData.ContainsKey(responding_character))
            {
                MovieConcession             concession          = _concessionsData[responding_character];
                string                      concession_response = MovieTheater.GetConcessionTasteForCharacter(responding_character, concession);
                string                      gender_tag          = "";
                Dictionary <string, string> NPCDispositions     = Game1.content.Load <Dictionary <string, string> >("Data\\NPCDispositions");
                if (NPCDispositions.ContainsKey(responding_character.name))
                {
                    string[] disposition = NPCDispositions[responding_character.name].Split('/');
                    if (disposition[4] == "female")
                    {
                        gender_tag = "_Female";
                    }
                    else if (disposition[4] == "male")
                    {
                        gender_tag = "_Male";
                    }
                }
                string sound = "eat";
                if (concession.tags != null && concession.tags.Contains("Drink"))
                {
                    sound = "gulp";
                }
                if (!(concession_response == "love"))
                {
                    if (!(concession_response == "like"))
                    {
                        if (concession_response == "dislike")
                        {
                            sb.Append("/friendship " + responding_character.Name + " " + 0);
                            sb.Append("/playSound croak/pause 1000");
                            sb.Append("/playSound newArtifact/emote " + (string)responding_character.name + " " + 40 + "/message \"" + Game1.content.LoadString("Strings\\Characters:MovieTheater_DislikeConcession" + gender_tag, responding_character.displayName, concession.DisplayName) + "\"");
                        }
                    }
                    else
                    {
                        sb.Append("/friendship " + responding_character.Name + " " + 25);
                        sb.Append("/tossConcession " + responding_character.Name + " " + concession.id + "/pause 1000");
                        sb.Append("/playSound " + sound + "/shake " + responding_character.Name + " 500/pause 1000");
                        sb.Append("/playSound give_gift/emote " + (string)responding_character.name + " " + 56 + "/message \"" + Game1.content.LoadString("Strings\\Characters:MovieTheater_LikeConcession" + gender_tag, responding_character.displayName, concession.DisplayName) + "\"");
                    }
                }
                else
                {
                    sb.Append("/friendship " + responding_character.Name + " " + 50);
                    sb.Append("/tossConcession " + responding_character.Name + " " + concession.id + "/pause 1000");
                    sb.Append("/playSound " + sound + "/shake " + responding_character.Name + " 500/pause 1000");
                    sb.Append("/playSound reward/emote " + (string)responding_character.name + " " + 20 + "/message \"" + Game1.content.LoadString("Strings\\Characters:MovieTheater_LoveConcession" + gender_tag, responding_character.displayName, concession.DisplayName) + "\"");
                }
            }
            _characterResponses[responding_character] = response;
        }
 public MovieTheater Add(MovieTheater movieTheater)
 {
     Context.MovieTheaters.Add(movieTheater);
     Context.SaveChanges();
     return(movieTheater);
 }
예제 #28
0
        public Event getMovieEvent(string movieID, List <List <Character> > player_and_guest_audience_groups, List <List <Character> > npcOnlyAudienceGroups, Dictionary <Character, MovieConcession> concessions_data = null)
        {
            _concessionsData           = concessions_data;
            _responseOrder             = new Dictionary <int, Character>();
            _whiteListDependencyLookup = new Dictionary <Character, Character>();
            _characterResponses        = new Dictionary <Character, string>();
            movieData = MovieTheater.GetMovieData()[movieID];
            playerAndGuestAudienceGroups = player_and_guest_audience_groups;
            currentResponse = 0;
            StringBuilder sb            = new StringBuilder();
            Random        theaterRandom = new Random((int)(Game1.stats.DaysPlayed + Game1.uniqueIDForThisGame / 2uL));

            sb.Append("movieScreenAmbience/-2000 -2000/");
            string playerCharacterEventName = "farmer" + Utility.getFarmerNumberFromFarmer(Game1.player);
            string playerCharacterGuestName = "";

            foreach (List <Character> list in playerAndGuestAudienceGroups)
            {
                if (list.Contains(Game1.player))
                {
                    for (int i9 = 0; i9 < list.Count; i9++)
                    {
                        if (!(list[i9] is Farmer))
                        {
                            playerCharacterGuestName = list[i9].name;
                        }
                    }
                }
            }
            _farmers = new List <Farmer>();
            foreach (List <Character> playerAndGuestAudienceGroup in playerAndGuestAudienceGroups)
            {
                foreach (Character character3 in playerAndGuestAudienceGroup)
                {
                    if (character3 is Farmer && !_farmers.Contains(character3))
                    {
                        _farmers.Add(character3 as Farmer);
                    }
                }
            }
            List <Character> allAudience = playerAndGuestAudienceGroups.SelectMany((List <Character> x) => x).ToList();

            allAudience.AddRange(npcOnlyAudienceGroups.SelectMany((List <Character> x) => x).ToList());
            bool first = true;

            foreach (Character c2 in allAudience)
            {
                if (c2 != null)
                {
                    if (!first)
                    {
                        sb.Append(" ");
                    }
                    if (c2 is Farmer)
                    {
                        Farmer f = c2 as Farmer;
                        sb.Append("farmer" + Utility.getFarmerNumberFromFarmer(f));
                    }
                    else if ((string)c2.name == "Krobus")
                    {
                        sb.Append("Krobus_Trenchcoat");
                    }
                    else
                    {
                        sb.Append(c2.name);
                    }
                    sb.Append(" -1000 -1000 0");
                    first = false;
                }
            }
            sb.Append("/changeToTemporaryMap MovieTheaterScreen false/specificTemporarySprite movieTheater_setup/ambientLight 0 0 0/");
            string[] backRow = new string[8];
            playerAndGuestAudienceGroups = playerAndGuestAudienceGroups.OrderBy((List <Character> x) => theaterRandom.Next()).ToList();
            int startingSeat = theaterRandom.Next(8 - playerAndGuestAudienceGroups.SelectMany((List <Character> x) => x).Count() + 1);
            int whichGroup   = 0;

            for (int i8 = 0; i8 < 8; i8++)
            {
                int seat8 = (i8 + startingSeat) % 8;
                if (playerAndGuestAudienceGroups[whichGroup].Count == 2 && (seat8 == 3 || seat8 == 7))
                {
                    i8++;
                    seat8++;
                    seat8 %= 8;
                }
                for (int j3 = 0; j3 < playerAndGuestAudienceGroups[whichGroup].Count && seat8 + j3 < backRow.Length; j3++)
                {
                    backRow[seat8 + j3] = ((playerAndGuestAudienceGroups[whichGroup][j3] is Farmer) ? ("farmer" + Utility.getFarmerNumberFromFarmer(playerAndGuestAudienceGroups[whichGroup][j3] as Farmer)) : ((string)playerAndGuestAudienceGroups[whichGroup][j3].name));
                    if (j3 > 0)
                    {
                        i8++;
                    }
                }
                whichGroup++;
                if (whichGroup >= playerAndGuestAudienceGroups.Count)
                {
                    break;
                }
            }
            string[] midRow = new string[6];
            for (int j2 = 0; j2 < npcOnlyAudienceGroups.Count; j2++)
            {
                int seat = theaterRandom.Next(3 - npcOnlyAudienceGroups[j2].Count + 1) + j2 * 3;
                for (int i = 0; i < npcOnlyAudienceGroups[j2].Count; i++)
                {
                    midRow[seat + i] = npcOnlyAudienceGroups[j2][i].name;
                }
            }
            int soFar4 = 0;
            int sittingTogetherCount2 = 0;

            for (int i7 = 0; i7 < backRow.Length; i7++)
            {
                if (backRow[i7] == null || !(backRow[i7] != "") || !(backRow[i7] != playerCharacterEventName) || !(backRow[i7] != playerCharacterGuestName))
                {
                    continue;
                }
                soFar4++;
                if (soFar4 < 2)
                {
                    continue;
                }
                sittingTogetherCount2++;
                Point seat2 = getBackRowSeatTileFromIndex(i7);
                sb.Append("warp ").Append(backRow[i7]).Append(" ")
                .Append(seat2.X)
                .Append(" ")
                .Append(seat2.Y)
                .Append("/positionOffset ")
                .Append(backRow[i7])
                .Append(" 0 -10/");
                if (sittingTogetherCount2 == 2)
                {
                    sittingTogetherCount2 = 0;
                    if (theaterRandom.NextDouble() < 0.5 && backRow[i7] != playerCharacterGuestName && backRow[i7 - 1] != playerCharacterGuestName)
                    {
                        sb.Append("faceDirection " + backRow[i7] + " 3 true/");
                        sb.Append("faceDirection " + backRow[i7 - 1] + " 1 true/");
                    }
                }
            }
            soFar4 = 0;
            sittingTogetherCount2 = 0;
            for (int i6 = 0; i6 < midRow.Length; i6++)
            {
                if (midRow[i6] == null || !(midRow[i6] != ""))
                {
                    continue;
                }
                soFar4++;
                if (soFar4 < 2)
                {
                    continue;
                }
                sittingTogetherCount2++;
                Point seat3 = getMidRowSeatTileFromIndex(i6);
                sb.Append("warp ").Append(midRow[i6]).Append(" ")
                .Append(seat3.X)
                .Append(" ")
                .Append(seat3.Y)
                .Append("/positionOffset ")
                .Append(midRow[i6])
                .Append(" 0 -10/");
                if (sittingTogetherCount2 == 2)
                {
                    sittingTogetherCount2 = 0;
                    if (i6 != 3 && theaterRandom.NextDouble() < 0.5)
                    {
                        sb.Append("faceDirection " + midRow[i6] + " 3 true/");
                        sb.Append("faceDirection " + midRow[i6 - 1] + " 1 true/");
                    }
                }
            }
            Point warpPoint = new Point(1, 15);

            soFar4 = 0;
            for (int i5 = 0; i5 < backRow.Length; i5++)
            {
                if (backRow[i5] != null && backRow[i5] != "" && backRow[i5] != playerCharacterEventName && backRow[i5] != playerCharacterGuestName)
                {
                    Point seat6 = getBackRowSeatTileFromIndex(i5);
                    if (soFar4 == 1)
                    {
                        sb.Append("warp ").Append(backRow[i5]).Append(" ")
                        .Append(seat6.X - 1)
                        .Append(" 10")
                        .Append("/advancedMove ")
                        .Append(backRow[i5])
                        .Append(" false 1 " + 200 + " 1 0 4 1000/")
                        .Append("positionOffset ")
                        .Append(backRow[i5])
                        .Append(" 0 -10/");
                    }
                    else
                    {
                        sb.Append("warp ").Append(backRow[i5]).Append(" 1 12")
                        .Append("/advancedMove ")
                        .Append(backRow[i5])
                        .Append(" false 1 200 ")
                        .Append("0 -2 ")
                        .Append(seat6.X - 1)
                        .Append(" 0 4 1000/")
                        .Append("positionOffset ")
                        .Append(backRow[i5])
                        .Append(" 0 -10/");
                    }
                    soFar4++;
                }
                if (soFar4 >= 2)
                {
                    break;
                }
            }
            soFar4 = 0;
            for (int i4 = 0; i4 < midRow.Length; i4++)
            {
                if (midRow[i4] != null && midRow[i4] != "")
                {
                    Point seat5 = getMidRowSeatTileFromIndex(i4);
                    if (soFar4 == 1)
                    {
                        sb.Append("warp ").Append(midRow[i4]).Append(" ")
                        .Append(seat5.X - 1)
                        .Append(" 8")
                        .Append("/advancedMove ")
                        .Append(midRow[i4])
                        .Append(" false 1 " + 400 + " 1 0 4 1000/");
                    }
                    else
                    {
                        sb.Append("warp ").Append(midRow[i4]).Append(" 2 9")
                        .Append("/advancedMove ")
                        .Append(midRow[i4])
                        .Append(" false 1 300 ")
                        .Append("0 -1 ")
                        .Append(seat5.X - 2)
                        .Append(" 0 4 1000/");
                    }
                    soFar4++;
                }
                if (soFar4 >= 2)
                {
                    break;
                }
            }
            sb.Append("viewport 6 8 true/pause 500/");
            for (int i3 = 0; i3 < backRow.Length; i3++)
            {
                if (backRow[i3] != null && backRow[i3] != "")
                {
                    Point seat4 = getBackRowSeatTileFromIndex(i3);
                    if (backRow[i3] == playerCharacterEventName || backRow[i3] == playerCharacterGuestName)
                    {
                        sb.Append("warp ").Append(backRow[i3]).Append(" ")
                        .Append(warpPoint.X)
                        .Append(" ")
                        .Append(warpPoint.Y)
                        .Append("/advancedMove ")
                        .Append(backRow[i3])
                        .Append(" false 0 -5 ")
                        .Append(seat4.X - warpPoint.X)
                        .Append(" 0 4 1000/")
                        .Append("pause ")
                        .Append(1000)
                        .Append("/");
                    }
                }
            }
            sb.Append("pause 3000/proceedPosition ").Append(playerCharacterGuestName).Append("/pause 1000");
            if (playerCharacterGuestName.Equals(""))
            {
                sb.Append("/proceedPosition farmer");
            }
            sb.Append("/waitForAllStationary/pause 100");
            foreach (Character c in allAudience)
            {
                if (getEventName(c) != playerCharacterEventName && getEventName(c) != playerCharacterGuestName)
                {
                    if (c is Farmer)
                    {
                        sb.Append("/faceDirection ").Append(getEventName(c)).Append(" 0 true/positionOffset ")
                        .Append(getEventName(c))
                        .Append(" 0 42 true");
                    }
                    else
                    {
                        sb.Append("/faceDirection ").Append(getEventName(c)).Append(" 0 true/positionOffset ")
                        .Append(getEventName(c))
                        .Append(" 0 12 true");
                    }
                    if (theaterRandom.NextDouble() < 0.2)
                    {
                        sb.Append("/pause 100");
                    }
                }
            }
            sb.Append("/positionOffset ").Append(playerCharacterEventName).Append(" 0 32/positionOffset ")
            .Append(playerCharacterGuestName)
            .Append(" 0 8/ambientLight 210 210 120 true/pause 500/viewport move 0 -1 4000/pause 5000");
            List <Character> responding_characters2 = new List <Character>();

            foreach (List <Character> playerAndGuestAudienceGroup2 in playerAndGuestAudienceGroups)
            {
                foreach (Character character2 in playerAndGuestAudienceGroup2)
                {
                    if (!(character2 is Farmer) && !responding_characters2.Contains(character2))
                    {
                        responding_characters2.Add(character2);
                    }
                }
            }
            for (int i2 = 0; i2 < responding_characters2.Count; i2++)
            {
                int       index     = theaterRandom.Next(responding_characters2.Count);
                Character character = responding_characters2[i2];
                responding_characters2[i2]    = responding_characters2[index];
                responding_characters2[index] = character;
            }
            int current_response_index2 = 0;

            foreach (MovieScene scene2 in movieData.Scenes)
            {
                if (scene2.ResponsePoint != null)
                {
                    bool found_reaction = false;
                    for (int n = 0; n < responding_characters2.Count; n++)
                    {
                        MovieCharacterReaction reaction2 = MovieTheater.GetReactionsForCharacter(responding_characters2[n] as NPC);
                        if (reaction2 != null)
                        {
                            foreach (MovieReaction movie_reaction2 in reaction2.Reactions)
                            {
                                if (movie_reaction2.ShouldApplyToMovie(movieData, MovieTheater.GetPatronNames(), MovieTheater.GetResponseForMovie(responding_characters2[n] as NPC)) && movie_reaction2.SpecialResponses != null && movie_reaction2.SpecialResponses.DuringMovie != null && (movie_reaction2.SpecialResponses.DuringMovie.ResponsePoint == scene2.ResponsePoint || movie_reaction2.Whitelist.Count > 0))
                                {
                                    if (!_whiteListDependencyLookup.ContainsKey(responding_characters2[n]))
                                    {
                                        _responseOrder[current_response_index2] = responding_characters2[n];
                                        if (movie_reaction2.Whitelist != null)
                                        {
                                            for (int m = 0; m < movie_reaction2.Whitelist.Count; m++)
                                            {
                                                Character white_list_character2 = Game1.getCharacterFromName(movie_reaction2.Whitelist[m]);
                                                if (white_list_character2 != null)
                                                {
                                                    _whiteListDependencyLookup[white_list_character2] = responding_characters2[n];
                                                    foreach (int key2 in _responseOrder.Keys)
                                                    {
                                                        if (_responseOrder[key2] == white_list_character2)
                                                        {
                                                            _responseOrder.Remove(key2);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    responding_characters2.RemoveAt(n);
                                    n--;
                                    found_reaction = true;
                                    break;
                                }
                            }
                            if (found_reaction)
                            {
                                break;
                            }
                        }
                    }
                    if (!found_reaction)
                    {
                        for (int l = 0; l < responding_characters2.Count; l++)
                        {
                            MovieCharacterReaction reaction = MovieTheater.GetReactionsForCharacter(responding_characters2[l] as NPC);
                            if (reaction != null)
                            {
                                foreach (MovieReaction movie_reaction in reaction.Reactions)
                                {
                                    if (movie_reaction.ShouldApplyToMovie(movieData, MovieTheater.GetPatronNames(), MovieTheater.GetResponseForMovie(responding_characters2[l] as NPC)) && movie_reaction.SpecialResponses != null && movie_reaction.SpecialResponses.DuringMovie != null && movie_reaction.SpecialResponses.DuringMovie.ResponsePoint == current_response_index2.ToString())
                                    {
                                        if (!_whiteListDependencyLookup.ContainsKey(responding_characters2[l]))
                                        {
                                            _responseOrder[current_response_index2] = responding_characters2[l];
                                            if (movie_reaction.Whitelist != null)
                                            {
                                                for (int k = 0; k < movie_reaction.Whitelist.Count; k++)
                                                {
                                                    Character white_list_character = Game1.getCharacterFromName(movie_reaction.Whitelist[k]);
                                                    if (white_list_character != null)
                                                    {
                                                        _whiteListDependencyLookup[white_list_character] = responding_characters2[l];
                                                        foreach (int key in _responseOrder.Keys)
                                                        {
                                                            if (_responseOrder[key] == white_list_character)
                                                            {
                                                                _responseOrder.Remove(key);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        responding_characters2.RemoveAt(l);
                                        l--;
                                        found_reaction = true;
                                        break;
                                    }
                                }
                                if (found_reaction)
                                {
                                    break;
                                }
                            }
                        }
                    }
                    current_response_index2++;
                }
            }
            current_response_index2 = 0;
            for (int j = 0; j < responding_characters2.Count; j++)
            {
                if (!_whiteListDependencyLookup.ContainsKey(responding_characters2[j]))
                {
                    for (; _responseOrder.ContainsKey(current_response_index2); current_response_index2++)
                    {
                    }
                    _responseOrder[current_response_index2] = responding_characters2[j];
                    current_response_index2++;
                }
            }
            responding_characters2 = null;
            foreach (MovieScene scene in movieData.Scenes)
            {
                _ParseScene(sb, scene);
            }
            while (currentResponse < _responseOrder.Count)
            {
                _ParseResponse(sb);
            }
            sb.Append("/stopMusic");
            sb.Append("/fade/viewport -1000 -1000");
            sb.Append("/pause 500/message \"" + Game1.content.LoadString("Strings\\Locations:Theater_MovieEnd") + "\"/pause 500");
            sb.Append("/requestMovieEnd");
            Console.WriteLine(sb.ToString());
            return(new Event(sb.ToString()));
        }
 public void SetUp()
 {
     _movieTheater = ObjectMother.movieTheaterDefault;
 }
예제 #30
0
        public static bool NPC_tryToReceiveActiveObject_Prefix(NPC __instance, ref Farmer who, Dictionary <string, string> ___dialogue, ref List <int> __state)
        {
            try
            {
                if (ModEntry.GetSpouses(who, true).ContainsKey(__instance.Name) && Game1.NPCGiftTastes.ContainsKey(__instance.Name))
                {
                    Monitor.Log($"Gift to spouse {__instance.Name}");
                    __state = new List <int> {
                        who.friendshipData[__instance.Name].GiftsToday,
                        who.friendshipData[__instance.Name].GiftsThisWeek,
                        0,
                        0
                    };
                    if (Config.MaxGiftsPerSpousePerDay < 0 || who.friendshipData[__instance.Name].GiftsToday < Config.MaxGiftsPerSpousePerDay)
                    {
                        who.friendshipData[__instance.Name].GiftsToday = 0;
                    }
                    else
                    {
                        who.friendshipData[__instance.Name].GiftsToday = 1;
                        __state[2] = 1; // flag to say we set it to 1
                    }
                    if (Config.MaxGiftsPerSpousePerWeek < 0 || who.friendshipData[__instance.Name].GiftsThisWeek < Config.MaxGiftsPerSpousePerWeek)
                    {
                        who.friendshipData[__instance.Name].GiftsThisWeek = 0;
                    }
                    else
                    {
                        who.friendshipData[__instance.Name].GiftsThisWeek = 2;
                        __state[3] = 1; // flag to say we set it to 2
                    }
                }
                string safe_name = __instance.Name.ToLower().Replace(' ', '_');
                if (who.ActiveObject.HasContextTag("propose_roommate_" + safe_name))
                {
                    Monitor.Log($"Roommate proposal item {who.ActiveObject.Name} to {__instance.Name}");

                    if (who.getFriendshipHeartLevelForNPC(__instance.Name) >= 10 && who.HouseUpgradeLevel >= 1)
                    {
                        Monitor.Log($"proposal success!");
                        AccessTools.Method(typeof(NPC), "engagementResponse").Invoke(__instance, new object[] { who, true });
                        return(false);
                    }
                    Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\Characters:MovieInvite_NoTheater", __instance.displayName)));
                    return(false);
                }
                else if (who.ActiveObject.ParentSheetIndex == 808 && __instance.Name.Equals("Krobus"))
                {
                    if (who.getFriendshipHeartLevelForNPC(__instance.Name) >= 10 && who.HouseUpgradeLevel >= 1)
                    {
                        AccessTools.Method(typeof(NPC), "engagementResponse").Invoke(__instance, new object[] { who, true });
                        return(false);
                    }
                }
                else if (who.ActiveObject.ParentSheetIndex == 458)
                {
                    Monitor.Log($"Try give bouquet to {__instance.Name}");

                    if (ModEntry.GetSpouses(who, true).ContainsKey(__instance.Name))
                    {
                        who.spouse = __instance.Name;
                        ModEntry.ResetSpouses(who);
                        Game1.currentLocation.playSound("dwop", NetAudio.SoundContext.NPC);
                        if (ModEntry.customSpouseRoomsAPI == null)
                        {
                            FarmHouse fh = Utility.getHomeOfFarmer(who);
                            fh.showSpouseRoom();
                            Helper.Reflection.GetMethod(fh, "resetLocalState").Invoke();
                        }
                        return(false);
                    }

                    if (!__instance.datable.Value)
                    {
                        if (ModEntry.myRand.NextDouble() < 0.5)
                        {
                            Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\StringsFromCSFiles:NPC.cs.3955", __instance.displayName));
                            return(false);
                        }
                        __instance.CurrentDialogue.Push(new Dialogue((ModEntry.myRand.NextDouble() < 0.5) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:NPC.cs.3956") : Game1.LoadStringByGender(__instance.Gender, "Strings\\StringsFromCSFiles:NPC.cs.3957"), __instance));
                        Game1.drawDialogue(__instance);
                        return(false);
                    }
                    else
                    {
                        if (who.friendshipData.ContainsKey(__instance.Name) && who.friendshipData[__instance.Name].IsDating())
                        {
                            Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\UI:AlreadyDatingBouquet", __instance.displayName));
                            return(false);
                        }
                        if (who.friendshipData.ContainsKey(__instance.Name) && who.friendshipData[__instance.Name].IsDivorced())
                        {
                            __instance.CurrentDialogue.Push(new Dialogue(Game1.content.LoadString("Strings\\Characters:Divorced_bouquet"), __instance));
                            Game1.drawDialogue(__instance);
                            return(false);
                        }
                        if (who.friendshipData.ContainsKey(__instance.Name) && who.friendshipData[__instance.Name].Points < Config.MinPointsToDate / 2f)
                        {
                            __instance.CurrentDialogue.Push(new Dialogue((ModEntry.myRand.NextDouble() < 0.5) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:NPC.cs.3958") : Game1.LoadStringByGender(__instance.Gender, "Strings\\StringsFromCSFiles:NPC.cs.3959"), __instance));
                            Game1.drawDialogue(__instance);
                            return(false);
                        }
                        if (who.friendshipData.ContainsKey(__instance.Name) && who.friendshipData[__instance.Name].Points < Config.MinPointsToDate)
                        {
                            __instance.CurrentDialogue.Push(new Dialogue((ModEntry.myRand.NextDouble() < 0.5) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:NPC.cs.3960") : Game1.content.LoadString("Strings\\StringsFromCSFiles:NPC.cs.3961"), __instance));
                            Game1.drawDialogue(__instance);
                            return(false);
                        }
                        Friendship friendship = who.friendshipData[__instance.Name];
                        if (!friendship.IsDating())
                        {
                            friendship.Status = FriendshipStatus.Dating;
                            Multiplayer mp = ModEntry.SHelper.Reflection.GetField <Multiplayer>(typeof(Game1), "multiplayer").GetValue();
                            mp.globalChatInfoMessage("Dating", new string[]
                            {
                                who.Name,
                                __instance.displayName
                            });
                        }
                        __instance.CurrentDialogue.Push(new Dialogue((ModEntry.myRand.NextDouble() < 0.5) ? Game1.LoadStringByGender(__instance.Gender, "Strings\\StringsFromCSFiles:NPC.cs.3962") : Game1.LoadStringByGender(__instance.Gender, "Strings\\StringsFromCSFiles:NPC.cs.3963"), __instance));
                        who.changeFriendship(25, __instance);
                        who.reduceActiveItemByOne();
                        who.completelyStopAnimatingOrDoingAction();
                        __instance.doEmote(20, true);
                        Game1.drawDialogue(__instance);
                        return(false);
                    }
                }
                else if (who.ActiveObject.ParentSheetIndex == 460)
                {
                    Monitor.Log($"Try give pendant to {__instance.Name}");
                    if (who.isEngaged())
                    {
                        Monitor.Log($"Tried to give pendant while engaged");

                        __instance.CurrentDialogue.Push(new Dialogue((ModEntry.myRand.NextDouble() < 0.5) ? Game1.LoadStringByGender(__instance.Gender, "Strings\\StringsFromCSFiles:NPC.cs.3965") : Game1.LoadStringByGender(__instance.Gender, "Strings\\StringsFromCSFiles:NPC.cs.3966"), __instance));
                        Game1.drawDialogue(__instance);
                        return(false);
                    }
                    if (!__instance.datable.Value || __instance.isMarriedOrEngaged() || (who.friendshipData.ContainsKey(__instance.Name) && who.friendshipData[__instance.Name].Points < Config.MinPointsToMarry * 0.6f))
                    {
                        Monitor.Log($"Tried to give pendant to someone not datable");

                        if (ModEntry.myRand.NextDouble() < 0.5)
                        {
                            Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\StringsFromCSFiles:NPC.cs.3969", __instance.displayName));
                            return(false);
                        }
                        __instance.CurrentDialogue.Push(new Dialogue((__instance.Gender == 1) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:NPC.cs.3970") : Game1.content.LoadString("Strings\\StringsFromCSFiles:NPC.cs.3971"), __instance));
                        Game1.drawDialogue(__instance);
                        return(false);
                    }
                    else if (__instance.datable.Value && who.friendshipData.ContainsKey(__instance.Name) && who.friendshipData[__instance.Name].Points < Config.MinPointsToMarry)
                    {
                        Monitor.Log($"Tried to give pendant to someone not marriable");

                        if (!who.friendshipData[__instance.Name].ProposalRejected)
                        {
                            __instance.CurrentDialogue.Push(new Dialogue((ModEntry.myRand.NextDouble() < 0.5) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:NPC.cs.3972") : Game1.content.LoadString("Strings\\StringsFromCSFiles:NPC.cs.3973"), __instance));
                            Game1.drawDialogue(__instance);
                            who.changeFriendship(-20, __instance);
                            who.friendshipData[__instance.Name].ProposalRejected = true;
                            return(false);
                        }
                        __instance.CurrentDialogue.Push(new Dialogue((ModEntry.myRand.NextDouble() < 0.5) ? Game1.LoadStringByGender(__instance.Gender, "Strings\\StringsFromCSFiles:NPC.cs.3974") : Game1.LoadStringByGender(__instance.Gender, "Strings\\StringsFromCSFiles:NPC.cs.3975"), __instance));
                        Game1.drawDialogue(__instance);
                        who.changeFriendship(-50, __instance);
                        return(false);
                    }
                    else
                    {
                        Monitor.Log($"Tried to give pendant to someone marriable");
                        if (!__instance.datable.Value || who.HouseUpgradeLevel >= 1)
                        {
                            typeof(NPC).GetMethod("engagementResponse", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { who, false });
                            return(false);
                        }
                        Monitor.Log($"Can't marry");
                        if (ModEntry.myRand.NextDouble() < 0.5)
                        {
                            Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\StringsFromCSFiles:NPC.cs.3969", __instance.displayName));
                            return(false);
                        }
                        __instance.CurrentDialogue.Push(new Dialogue(Game1.content.LoadString("Strings\\StringsFromCSFiles:NPC.cs.3972"), __instance));
                        Game1.drawDialogue(__instance);
                        return(false);
                    }
                }
                else if (who.ActiveObject.ParentSheetIndex == 809 && !who.ActiveObject.bigCraftable.Value)
                {
                    Monitor.Log($"Tried to give movie ticket to {__instance.Name}");
                    if (ModEntry.GetSpouses(who, true).ContainsKey(__instance.Name) && Utility.doesMasterPlayerHaveMailReceivedButNotMailForTomorrow("ccMovieTheater") && !__instance.Name.Equals("Krobus") && who.lastSeenMovieWeek.Value < Game1.Date.TotalWeeks && !Utility.isFestivalDay(Game1.dayOfMonth, Game1.currentSeason) && Game1.timeOfDay <= 2100 && __instance.lastSeenMovieWeek.Value < Game1.Date.TotalWeeks && MovieTheater.GetResponseForMovie(__instance) != "reject")
                    {
                        Monitor.Log($"Tried to give movie ticket to spouse");
                        foreach (MovieInvitation invitation in who.team.movieInvitations)
                        {
                            if (invitation.farmer == who)
                            {
                                return(true);
                            }
                        }
                        foreach (MovieInvitation invitation2 in who.team.movieInvitations)
                        {
                            if (invitation2.invitedNPC == __instance)
                            {
                                return(true);
                            }
                        }

                        Monitor.Log($"Giving movie ticket to spouse");

                        if (LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.en)
                        {
                            __instance.CurrentDialogue.Push(new Dialogue(__instance.GetDispositionModifiedString("Strings\\Characters:MovieInvite_Spouse_" + __instance.Name, new object[0]), __instance));
                        }
                        else if (LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.en && ___dialogue != null && ___dialogue.ContainsKey("MovieInvitation"))
                        {
                            __instance.CurrentDialogue.Push(new Dialogue(___dialogue["MovieInvitation"], __instance));
                        }
                        else
                        {
                            __instance.CurrentDialogue.Push(new Dialogue(__instance.GetDispositionModifiedString("Strings\\Characters:MovieInvite_Invited", new object[0]), __instance));
                        }
                        Game1.drawDialogue(__instance);
                        who.reduceActiveItemByOne();
                        who.completelyStopAnimatingOrDoingAction();
                        who.currentLocation.localSound("give_gift");
                        MovieTheater.Invite(who, __instance);
                        if (who == Game1.player)
                        {
                            ModEntry.mp.globalChatInfoMessage("MovieInviteAccept", new string[]
                            {
                                Game1.player.displayName,
                                __instance.displayName
                            });
                            return(false);
                        }
                    }
                    return(true);
                }
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed in {nameof(NPC_tryToReceiveActiveObject_Prefix)}:\n{ex}", LogLevel.Error);
            }
            return(true);
        }