forked from akanyan/mu3-mods
feat(UnlockGameEvents): mission event cycling
* Makes the game use the first available non-cleared mission. * Rather than the first available mission period. * No longer unlocks missions marked as expired by the server.
This commit is contained in:
@ -0,0 +1,40 @@
|
||||
using MU3.Data;
|
||||
using MU3.User;
|
||||
using MU3.Util;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MU3.Operation;
|
||||
|
||||
class patch_OperationManager: OperationManager {
|
||||
private Dictionary<int, MissionEventData> _missionEventDataMap;
|
||||
|
||||
public extern MissionEventData orig_getTargetMissionFromChapterID(int chapterId);
|
||||
public new MissionEventData getTargetMissionFromChapterID(int chapterId) {
|
||||
return overrideMission(orig_getTargetMissionFromChapterID(chapterId));
|
||||
}
|
||||
|
||||
public extern MissionEventData orig_getTargetMissionFromStoryID(int storyId);
|
||||
public new MissionEventData getTargetMissionFromStoryID(int storyId) {
|
||||
return overrideMission(orig_getTargetMissionFromStoryID(storyId));
|
||||
}
|
||||
|
||||
private MissionEventData overrideMission(MissionEventData orig) {
|
||||
if(orig != null) {
|
||||
foreach(KeyValuePair<int, MissionEventData> item in _missionEventDataMap) {
|
||||
MissionEventData value = item.Value;
|
||||
if(!value.isMissionEventActive || value.eventData == null) {
|
||||
continue;
|
||||
}
|
||||
var userMissions = Singleton<UserManager>.instance.userMission;
|
||||
if(userMissions != null && userMissions.TryGetValue(value.missionEventId, out UserMission um)) {
|
||||
var rv = value.eventData.getNextEventPointBonus(out EventRewardInfo rewardInfo, um.Point);
|
||||
if(!rv || rewardInfo.bonus_.RewardNameAndCounts[0].isLoop) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return orig;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user