Пример #1
0
        /// <summary>
        /// This method replaced the original CheckPlantGrowthStage
        /// This method is public to avoid Protected memory access to the arguments (needs to be same access level as original)
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="facade"></param>
        public void CheckPlantGrowthStage(Entity entity, EntityUniverseFacade facade)
        {
            PlayerEntityLogic playerEntityLogic = entity.PlayerEntityLogic;
            Tile tile = default(Tile);
            PlantConfiguration config   = default(PlantConfiguration);
            Vector3I           cursor   = default(Vector3I);
            Vector3I           adjacent = default(Vector3I);
            Vector3I           core     = default(Vector3I);

            if (playerEntityLogic != null && playerEntityLogic.LookingAtTile(out cursor, out adjacent) && ((ItemFacade)facade).FindReadCompoundTileCore(cursor, TileAccessFlags.None, out core, out tile) && GameContext.PlantDatabase.TryGetByTile(tile, out config))
            {
                Season season            = SeasonHelper.FromInt(facade.DayNightCycle().GetSeason());
                bool   livesInThisSeason = config.LivesInSeason(season);

                Totem        totem;
                List <Totem> totems;
                bool         plantedInGreenhouse = (PlantLogic.GetValidTotemsOfType(PlantLogic.GreenhouseTotemCode, out totems) && PlantLogic.IsInTotemsRegion(totems, cursor, out totem));

                Notification notif;
                if (config.IsWitheredTile(tile))
                {
                    notif = ((!livesInThisSeason && !plantedInGreenhouse) ? GameContext.NotificationDatabase.CreateNotificationFromCode("staxel.notifications.checkPlantGrowth.witheredSeason", entity.Step, NotificationParams.CreateFromTranslation(season.GetCode()), false) : GameContext.NotificationDatabase.CreateNotificationFromCode("staxel.notifications.checkPlantGrowth.withered", entity.Step, NotificationParams.EmptyParams, false));
                }
                else if (config.IsWiltedTile(tile))
                {
                    notif = GameContext.NotificationDatabase.CreateNotificationFromCode("staxel.notifications.checkPlantGrowth.wilted", entity.Step, NotificationParams.EmptyParams, false);
                }
                else if (!livesInThisSeason && !plantedInGreenhouse)
                {
                    notif = GameContext.NotificationDatabase.CreateNotificationFromCode("staxel.notifications.checkPlantGrowth.season", entity.Step, NotificationParams.CreateFromTranslation(season.GetCode()), false);
                }
                else
                {
                    float  percentage  = config.GetGrowthPercentage(tile, config);
                    string description = (!(percentage < 0.1f)) ? ((!(percentage < 1f)) ? "hintText.checkPlantGrowth.fruited" : "hintText.checkPlantGrowth.growing") : "hintText.checkPlantGrowth.seed";
                    notif = GameContext.NotificationDatabase.CreateNotificationFromCode("staxel.notifications.checkPlantGrowth", entity.Step, NotificationParams.CreateFromTranslation(description), false);
                }
                playerEntityLogic.ShowNotification(notif);
            }
            entity.Logic.ActionFacade.NoNextAction();
        }