Пример #1
0
 public CustomBobberBarFactory(
     IModHelper helper,
     IMonitor monitor,
     IFishingApi fishingApi,
     FishConfig fishConfig,
     TreasureConfig treasureConfig
     )
 {
     this.helper         = helper ?? throw new ArgumentNullException(nameof(helper));
     this.monitor        = monitor ?? throw new ArgumentNullException(nameof(monitor));
     this.fishingApi     = fishingApi ?? throw new ArgumentNullException(nameof(fishingApi));
     this.fishConfig     = fishConfig ?? throw new ArgumentNullException(nameof(fishConfig));
     this.treasureConfig =
         treasureConfig ?? throw new ArgumentNullException(nameof(treasureConfig));
 }
Пример #2
0
    public static FishConfig GetFishConfig(int fishType)
    {
        if (_fishConfigDic.ContainsKey(fishType))
        {
            return(_fishConfigDic[fishType]);
        }

        string     path   = DataAccessor.GetFishPathByType(fishType);
        FishConfig config = DataAccessor.LoadObjectFromJsonFile <FishConfig>(path);

        if (config != null)
        {
            _fishConfigDic[fishType] = config;
        }

        return(config);
    }
Пример #3
0
        internal FishingApi(
            IModHelper helper,
            IMonitor monitor,
            IManifest manifest,
            FishConfig fishConfig,
            TreasureConfig treasureConfig,
            Func <IEnumerable <IFishingContentSource> > contentSourcesFactory,
            EntryManagerFactory <FishEntry, FishAvailabilityInfo> fishEntryManagerFactory,
            EntryManagerFactory <TrashEntry, AvailabilityInfo> trashEntryManagerFactory,
            EntryManagerFactory <TreasureEntry, AvailabilityInfo> treasureEntryManagerFactory,
            FishingEffectManagerFactory fishingEffectManagerFactory,
            Lazy <IOptional <IEmpApi> > empApi
            )
        {
            this.helper         = helper ?? throw new ArgumentNullException(nameof(helper));
            this.monitor        = monitor ?? throw new ArgumentNullException(nameof(monitor));
            this.manifest       = manifest ?? throw new ArgumentNullException(nameof(manifest));
            this.fishConfig     = fishConfig ?? throw new ArgumentNullException(nameof(fishConfig));
            this.treasureConfig =
                treasureConfig ?? throw new ArgumentNullException(nameof(treasureConfig));
            this.contentSourcesFactory = contentSourcesFactory
                                         ?? throw new ArgumentNullException(nameof(contentSourcesFactory));
            this.fishEntryManagerFactory = fishEntryManagerFactory
                                           ?? throw new ArgumentNullException(nameof(fishEntryManagerFactory));
            this.trashEntryManagerFactory = trashEntryManagerFactory
                                            ?? throw new ArgumentNullException(nameof(trashEntryManagerFactory));
            this.treasureEntryManagerFactory = treasureEntryManagerFactory
                                               ?? throw new ArgumentNullException(nameof(treasureEntryManagerFactory));
            this.fishingEffectManagerFactory = fishingEffectManagerFactory
                                               ?? throw new ArgumentNullException(nameof(fishingEffectManagerFactory));
            this.empApi = empApi ?? throw new ArgumentNullException(nameof(empApi));

            this.fishTraits            = new();
            this.fishManagers          = new();
            this.trashManagers         = new();
            this.treasureManagers      = new();
            this.fishingEffectManagers = new();
            this.stateKey = $"{manifest.UniqueID}/fishing-state";

            this.CreatedDefaultFishingInfo += this.ApplyMapOverrides;
            this.CreatedDefaultFishingInfo += this.ApplyEmpOverrides;
            this.CreatedDefaultFishingInfo += FishingApi.ApplyMagicBait;
            this.PreparedFishChances       += FishingApi.ApplyCuriosityLure;

            this.reloadRequested = true;
        }
Пример #4
0
        public CustomBobberBar(
            IModHelper helper,
            FishConfig fishConfig,
            TreasureConfig treasureConfig,
            FishingInfo fishingInfo,
            FishEntry fishEntry,
            FishTraits fishTraits,
            Item fishItem,
            float fishSizePercent,
            bool treasure,
            int bobber,
            bool fromFishPond
            )
            : base(0, fishSizePercent, treasure, bobber)
        {
            _ = helper ?? throw new ArgumentNullException(nameof(helper));
            this.fishConfig     = fishConfig ?? throw new ArgumentNullException(nameof(fishConfig));
            this.treasureConfig =
                treasureConfig ?? throw new ArgumentNullException(nameof(treasureConfig));
            this.fishingInfo = fishingInfo ?? throw new ArgumentNullException(nameof(fishingInfo));
            this.fishEntry   = fishEntry;
            this.fishTraits  = fishTraits ?? throw new ArgumentNullException(nameof(fishTraits));
            this.fishItem    = fishItem ?? throw new ArgumentNullException(nameof(fishItem));

            this.treasureField         = helper.Reflection.GetField <bool>(this, "treasure");
            this.treasureCaughtField   = helper.Reflection.GetField <bool>(this, "treasureCaught");
            this.treasurePositionField =
                helper.Reflection.GetField <float>(this, "treasurePosition");
            this.treasureAppearTimerField =
                helper.Reflection.GetField <float>(this, "treasureAppearTimer");
            this.treasureScaleField = helper.Reflection.GetField <float>(this, "treasureScale");

            this.distanceFromCatchingField =
                helper.Reflection.GetField <float>(this, "distanceFromCatching");
            this.treasureCatchLevelField =
                helper.Reflection.GetField <float>(this, "treasureCatchLevel");

            this.bobberBarPosField    = helper.Reflection.GetField <float>(this, "bobberBarPos");
            this.bobberInBarField     = helper.Reflection.GetField <bool>(this, "bobberInBar");
            this.difficultyField      = helper.Reflection.GetField <float>(this, "difficulty");
            this.fishQualityField     = helper.Reflection.GetField <int>(this, "fishQuality");
            this.perfectField         = helper.Reflection.GetField <bool>(this, "perfect");
            this.scaleField           = helper.Reflection.GetField <float>(this, "scale");
            this.flipBubbleField      = helper.Reflection.GetField <bool>(this, "flipBubble");
            this.bobberBarHeightField = helper.Reflection.GetField <int>(this, "bobberBarHeight");
            this.reelRotationField    = helper.Reflection.GetField <float>(this, "reelRotation");
            this.bobberPositionField  = helper.Reflection.GetField <float>(this, "bobberPosition");
            this.bossFishField        = helper.Reflection.GetField <bool>(this, "bossFish");
            this.motionTypeField      = helper.Reflection.GetField <int>(this, "motionType");
            this.fishSizeField        = helper.Reflection.GetField <int>(this, "fishSize");
            this.minFishSizeField     = helper.Reflection.GetField <int>(this, "minFishSize");
            this.maxFishSizeField     = helper.Reflection.GetField <int>(this, "maxFishSize");
            this.fromFishPondField    = helper.Reflection.GetField <bool>(this, "fromFishPond");

            this.barShakeField        = helper.Reflection.GetField <Vector2>(this, "barShake");
            this.fishShakeField       = helper.Reflection.GetField <Vector2>(this, "fishShake");
            this.treasureShakeField   = helper.Reflection.GetField <Vector2>(this, "treasureShake");
            this.everythingShakeField =
                helper.Reflection.GetField <Vector2>(this, "everythingShake");
            this.fadeOutField = helper.Reflection.GetField <bool>(this, "fadeOut");

            this.sparkleTextField = helper.Reflection.GetField <SparklingText?>(this, "sparkleText");

            // Track state
            this.lastDistanceFromCatching = 0f;
            this.lastTreasureCatchLevel   = 0f;
            this.state = new(true, treasure ? TreasureState.NotCaught : TreasureState.None);

            // Track player streak
            this.perfectField.SetValue(true);
            var fishSizeReductionTimerField =
                helper.Reflection.GetField <int>(this, "fishSizeReductionTimer");

            fishSizeReductionTimerField.SetValue(800);

            // Fish size
            var minFishSize = fishTraits.MinSize;
            var maxFishSize = fishTraits.MaxSize;
            var fishSize    = (int)(minFishSize + (maxFishSize - minFishSize) * fishSizePercent) + 1;

            this.minFishSizeField.SetValue(minFishSize);
            this.maxFishSizeField.SetValue(maxFishSize);
            this.fishSizeField.SetValue(fishSize);

            // Track other information (not all tracked by vanilla)
            this.fromFishPondField.SetValue(fromFishPond);
            this.bossFishField.SetValue(fishTraits.IsLegendary);

            // Adjust quality to be increased by streak
            var fishQuality = fishSizePercent switch
            {