public GenericModConfigMenuSetup( IModHelper helper, IManifest manifest, IOptional <IGenericModConfigMenuApi> configApiFactory, HudConfig hudConfig, ConfigManager <HudConfig> hudConfigManager, FishConfig fishConfig, ConfigManager <FishConfig> fishConfigManager, TreasureConfig treasureConfig, ConfigManager <TreasureConfig> treasureConfigManager ) { this.helper = helper ?? throw new ArgumentNullException(nameof(helper)); this.manifest = manifest ?? throw new ArgumentNullException(nameof(manifest)); this.configApi = configApiFactory ?? throw new ArgumentNullException(nameof(configApiFactory)); this.hudConfig = hudConfig ?? throw new ArgumentNullException(nameof(hudConfig)); this.hudConfigManager = hudConfigManager ?? throw new ArgumentNullException(nameof(hudConfigManager)); this.fishConfig = fishConfig ?? throw new ArgumentNullException(nameof(fishConfig)); this.fishConfigManager = fishConfigManager ?? throw new ArgumentNullException(nameof(fishConfigManager)); this.treasureConfig = treasureConfig ?? throw new ArgumentNullException(nameof(treasureConfig)); this.treasureConfigManager = treasureConfigManager ?? throw new ArgumentNullException(nameof(treasureConfigManager)); }
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)); }
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; }
/// <summary> /// 记录玩家数据 /// </summary> /// <param name="userId"></param> /// <param name="totalSeconds"></param> /// <returns></returns> public static async Task RecordGamerInfo(long userId, int totalSeconds) { DBProxyComponent proxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); ConfigComponent configComponent = Game.Scene.GetComponent <ConfigComponent>(); List <GamerInfoDB> gamerInfos = await proxyComponent.QueryJson <GamerInfoDB>($"{{UId:{userId}}}"); GamerInfoDB gamerInfo; if (gamerInfos.Count == 0) { gamerInfo = ComponentFactory.CreateWithId <GamerInfoDB>(IdGenerater.GenerateId()); } else { gamerInfo = gamerInfos[0]; } gamerInfo.UId = userId; gamerInfo.DailyOnlineTime += totalSeconds; gamerInfo.TotalOnlineTime += totalSeconds; TreasureConfig treasureConfig = configComponent.Get(typeof(TreasureConfig), ++gamerInfo.DailyTreasureCount) as TreasureConfig; // Log.Debug(gamerInfo.DailyTreasureCount + ""); // Log.Debug(JsonHelper.ToJson(treasureConfig)); if (gamerInfo.DailyOnlineTime > treasureConfig?.TotalTime) { gamerInfo.DailyOnlineTime = treasureConfig.TotalTime; } --gamerInfo.DailyTreasureCount; await proxyComponent.Save(gamerInfo); //记录玩家在线时长 await DBCommonUtil.UpdateChengjiu(userId, 107, totalSeconds); await DBCommonUtil.UpdateChengjiu(userId, 108, totalSeconds); await DBCommonUtil.UpdateChengjiu(userId, 109, totalSeconds); }
/// <summary> /// 获取在线时长 /// </summary> /// <param name="userId"></param> public static async Task <int> GetRestOnlineSeconds(long userId) { DBProxyComponent proxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); ConfigComponent configComponent = Game.Scene.GetComponent <ConfigComponent>(); List <GamerInfoDB> gamerInfos = await proxyComponent.QueryJson <GamerInfoDB>($"{{UId:{userId}}}"); if (gamerInfos.Count == 0) { TreasureConfig config = (TreasureConfig)configComponent.Get(typeof(TreasureConfig), 1); return(config.TotalTime); } else { for (int j = 1; j < gamerInfos.Count; j++) { await proxyComponent.Delete <GamerInfoDB>(gamerInfos[j].Id); } } TreasureConfig treasureConfig = configComponent.Get(typeof(TreasureConfig), ++gamerInfos[0].DailyTreasureCount) as TreasureConfig; //当天的宝箱已领取完 if (treasureConfig == null) { return(-1); } int i = treasureConfig.TotalTime - gamerInfos[0].DailyOnlineTime; // Log.Debug("TotalTime" + treasureConfig.TotalTime); // Log.Debug("gamerInfos[0].DailyOnlineTime" + gamerInfos[0].DailyOnlineTime); // Log.Debug("还剩" + i); return(i); }
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 {
protected override async Task Run(Gamer gamer, C2M_ActorGamerGetTreasure message, Action <M2C_ActorGamerGetTreasure> reply) { M2C_ActorGamerGetTreasure response = new M2C_ActorGamerGetTreasure(); try { DBProxyComponent proxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); ConfigComponent configComponent = Game.Scene.GetComponent <ConfigComponent>(); //记录数据 gamer.EndTime = DateTime.Now; TimeSpan span = gamer.EndTime - gamer.StartTime; int totalSeconds = (int)span.TotalSeconds; //await DBCommonUtil.RecordGamerTime(gamer.EndTime, false, gamer.UserID); await DBCommonUtil.RecordGamerInfo(gamer.UserID, totalSeconds); List <GamerInfoDB> gamerInfos = await proxyComponent.QueryJson <GamerInfoDB>($"{{UId:{gamer.UserID}}}"); if (gamerInfos.Count == 0) { response.Error = ErrorCode.ERR_Common; response.Message = "未到时间"; reply(response); return; } GamerInfoDB gamerInfo = gamerInfos[0]; gamerInfo.DailyTreasureCount++; TreasureConfig config = configComponent.Get(typeof(TreasureConfig), gamerInfo.DailyTreasureCount) as TreasureConfig; Log.Debug("config:" + JsonHelper.ToJson(config)); if (config == null) { response.Error = ErrorCode.ERR_Common; response.Message = "宝箱已领取完"; } else { if (gamerInfo.DailyOnlineTime >= config.TotalTime) { await DBCommonUtil.ChangeWealth(gamer.UserID, 1, config.Reward, "游戏内宝箱奖励"); await proxyComponent.Save(gamerInfo); //下一个奖励 TreasureConfig treasureConfig = (TreasureConfig)configComponent.Get(typeof(TreasureConfig), ++gamerInfo.DailyTreasureCount); //宝箱领完了 if (treasureConfig == null) { response.RestSeconds = -1; response.Reward = config.Reward; } else { response.RestSeconds = treasureConfig.TotalTime - gamerInfo.DailyOnlineTime; response.Reward = config.Reward; } } else { response.Error = ErrorCode.ERR_Common; response.Message = "未到时间"; } } reply(response); gamer.StartTime = DateTime.Now; //await DBCommonUtil.RecordGamerTime(gamer.EndTime, false, gamer.UserID); } catch (Exception e) { ReplyError(response, e, reply); } await Task.CompletedTask; }