static bool Prefix(CustomActorUI __instance) { if (!enabled || !isCustomizing) return true; Module<AudioModule>.Self.PlayEffect2D(68, false, true, false); if (__instance.GreenBar(__instance.nameInput.text)) { UIUtils.ShowTipsMode2(TextMgr.GetStr(100501, -1), Color.white, 1.5f, null, false); } else if (Module<GameMgr>.Self.CheckTooManyCharacters()) { UIUtils.ShowTipsMode2(TextMgr.GetStr(100901, -1), Color.white, 1.5f, null, false); } else { __instance.gameObject.SetActive(false); CalendarUIStdState.ShowBirthdaySelect(new Action(ReturnToGame), delegate { __instance.gameObject.SetActive(true); }); } return false; }
public static bool Prefix(WholeMapViewer __instance, ref MapIconData iconData, ref MapIconInfo icon) { if (!enabled) { return(true); } if (iconData.CurIcon is PresetIcon && (iconData.CurIcon as PresetIcon).IsIcon(MapIcon.TRANSFERPOINT)) { iconData.iconObject.GetComponent <Image>().raycastTarget = false; UnityEngine.Object.Destroy(iconData.iconObject.GetComponent <MapIconInteractTransfer>()); UnityEngine.Object.Destroy(iconData.iconObject.GetComponent <Selectable>()); } iconData.SetCurIcon(icon, __instance.GetHashCode()); PresetIcon presetIcon = icon as PresetIcon; if (icon is PresetIcon && presetIcon.IsIcon(MapIcon.TRANSFERPOINT)) { (iconData.iconObject as MapIconPoolSprite).SetRaycastTarget(true); if (iconData.iconObject.gameObject.GetComponent <MapIconInteractTransfer>() == null) { iconData.iconObject.gameObject.AddComponent <MapIconInteractTransfer>(); iconData.iconObject.gameObject.AddComponent <Selectable>(); } iconData.iconObject.gameObject.GetComponent <MapIconInteractTransfer>().SetImap(iconData.imap); int tranId = Singleton <TransferTransIdDataBase> .Self.GetTranId((iconData.imap as SceneItemTransfer_IMap).SItem.ID); string name = (tranId <= 0) ? string.Empty : TextMgr.GetStr(tranId, -1); Dbgl($"name: {name} pos: {iconData.imap.GetPos()}"); } return(false); }
public static void Postfix(List <ItemBaseConfData> ___itemBaseList) { // Load sprites offsets. var offsets = File.ReadAllLines($"{Central.Instance.HomePath}/offsets.txt"); Central.Instance.ItemOffsets = new Dictionary <string, int[]>(offsets.Length); foreach (var off in offsets) { var offSplit = off.Split('='); Central.Instance.ItemOffsets.Add(offSplit[0], offSplit[1].Split(',').Select(s => int.Parse(s)).ToArray()); } // Load items. Central.Instance.ItemDB = new List <DbItem>(); var validItems = ___itemBaseList.Where(i => Central.Instance.ItemOffsets.ContainsKey(i.IconPath.Replace("Sprites/Package/", ""))) .GroupBy(i => i.NameID); foreach (var kv in validItems) { if (kv.Count() == 1) { var ib = kv.First(); var name = TextMgr.GetStr(ib.NameID).ToLower(); if (name.Trim() == "") { continue; } Central.Instance.ItemDB.Add(new DbItem { ID = ib.ID, Name = TextMgr.GetStr(ib.NameID).ToLower(), NameID = ib.NameID, IconName = ib.IconPath.Replace("Sprites/Package/", "") }); continue; } var first = kv.ElementAt(0); var firstName = TextMgr.GetStr(first.NameID).ToLower(); if (firstName.Trim() == "") { continue; } Central.Instance.ItemDB.Add(new DbItem(kv.Skip(1).Select(i => new int[] { i.UseLevel, i.ID })) { ID = first.ID, Name = firstName, NameID = first.NameID, IconName = first.IconPath.Replace("Sprites/Package/", "") }); } }
private static void OnLoadGame() { if (!enabled) { return; } Dbgl(TextMgr.GetStr(1, -1)); }
static void Prefix(PlayerItemBarCtr __instance) { if (!enabled) { return; } if (KeyDown(settings.ItemBarSwitchKey)) { for (int index = 0; index < 8; index++) { ItemObject itemObject = Module <Player> .Self.bag.itemBar.itemBarItems[index]; ItemObject itemObj = Module <Player> .Self.bag.GetItems(0).GetItemObj(index); Module <Player> .Self.bag.BagExchangeItemBar(index, index, 0); } MethodInfo dynMethod = __instance.GetType().GetMethod("Unequip", BindingFlags.NonPublic | BindingFlags.Instance); dynMethod.Invoke(__instance, new object[] { }); } else if (KeyDown(settings.OpenStorageKey) && UIStateMgr.Instance.currentState.type == UIStateMgr.StateType.Play) { StorageViewer sv = new StorageViewer(); FieldRef <StorageViewer, StorageUnit> suRef = FieldRefAccess <StorageViewer, StorageUnit>("storageUnit"); suRef(sv) = StorageUnit.GetStorageByGlobalIndex(lastStorageIndex); MethodInfo dynMethod = sv.GetType().GetMethod("InteractStorage", BindingFlags.NonPublic | BindingFlags.Instance); dynMethod.Invoke(sv, new object[] { }); } else if (KeyDown(settings.OpenFactoryKey) && UIStateMgr.Instance.currentState.type == UIStateMgr.StateType.Play) { FarmFactory[] factorys = Module <FarmFactoryMgr> .Self.GetAllFactorys(); if (factorys.Length == 0) { return; } FarmFactory factory = factorys[0]; Action <List <IdCount> > action = delegate(List <IdCount> ls) { factory.SetMatList(ls); }; UIStateMgr.Instance.ChangeStateByType(UIStateMgr.StateType.PackageExchangeState, true, new object[] { factory.MatList, TextMgr.GetStr(103440, -1), true, action, 103521, 300 }); } }
private static void Postfix(List <ItemBaseConfData> ___itemBaseList) { GiveItem.Logger.Log("Loading items DB"); ItemDataMgrPatches.ItemDB = new Dictionary <int, string>(); foreach (var item in ___itemBaseList) { ItemDataMgrPatches.ItemDB.Add(item.ID, TextMgr.GetStr(item.NameID)); } GiveItem.Logger.Log($"Loaded {ItemDataMgrPatches.ItemDB.Count} items!"); }
static void Postfix(PackageExchangeUICtr __instance, TextMeshProUGUI ___title) { if (!enabled) { return; } Regex pattern = new Regex(@" \([0-9]{1,3}%\)"); if (pattern.IsMatch(___title.text)) { int gols = getGols(__instance.GetStoreage()); ___title.text = string.Format(" <color=#FFE17E>{0}</color>", TextMgr.GetStr(101347, -1) + (gols > 0 ? " " + TextMgr.GetStr(101388, -1) + gols:"") + " (" + (Math.Round(Module <StoreManagerV40> .Self.CurPriceIndex * 100)) + "%)"); } }
private static bool Prefix(AbilityItem __instance, ref string __result, AbilityData ___refData) { if (!enabled) { return(true); } string str = TextMgr.GetStr(___refData.descTextId, -1); List <object> list = new List <object>(); for (int i = 0; i < __instance.relatedModifierId.Count; i++) { list.AddRange(Module <FeatureModule> .Self.GetNextValueAry(__instance.relatedModifierId[i])); } __result = string.Format(str, list.ToArray()); return(false); }
private static void Prefix(UIStateMgr.StateType type, ref object[] objs) { if (!enabled || type != UIStateMgr.StateType.PackageExchangeState) { return; } try { if ((string)objs[1] == TextMgr.GetStr(103440, -1) && (int)objs[objs.Length - 1] == 300) { objs[objs.Length - 1] = settings.FactoryStorageSize; } Dbgl($"Setting factory storage size to {settings.FactoryStorageSize}"); } catch { } }
public static bool Prefix(PackageUIBase __instance) { if (!enabled) { return(true); } int id = ((ItemObject)typeof(PackageUIBase).GetProperty("curSelectItem", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance, new object[0])).ItemDataId; if (MissionRequire.IsMissionRequired(id)) { UIUtils.ShowTipsMode2(TextMgr.GetStr(103554, -1), Color.white, 1.5f, null, false); } else { __instance.DeleteItem(); } return(false); }
public static bool Prefix(MapIconInteractTransfer __instance, IMap ___curImap, ref string __result) { if (!enabled) { return(true); } int busStopTransferTime = Module <SceneItemManager> .Self.GetBusStopTransferTime(___curImap); int num = busStopTransferTime / 60; int num2 = busStopTransferTime - num * 60; int tranId = Singleton <TransferTransIdDataBase> .Self.GetTranId((___curImap as SceneItemTransfer_IMap).SItem.ID); string name = (tranId <= 0) ? string.Empty : TextMgr.GetStr(tranId, -1); __result = string.Format($"<b>{name}</b>\r\n" + TextMgr.GetStr(91200043, -1), num.ToString(), num2.ToString(), Module <SceneItemManager> .Self.GetBusStopTransferMoney(___curImap)); return(false); }
private static void AddMissionInfoToList(ref List <string> outInfo, Mission mi) { outInfo.Add($"\r\n\tMission Id: {mi.MissionId}"); outInfo.Add($"\t\tMission NO: {mi.MissionNO}"); outInfo.Add($"\t\tIsMain: {mi.IsMain}"); outInfo.Add($"\t\tMission Name: {TextMgr.GetStr(mi.MissionShowName, -1)}"); outInfo.Add($"\t\tGroup Type: {mi.groupType}"); outInfo.Add($"\t\tGroup Id: {mi.groupId}"); outInfo.Add($"\t\tDescription: \r\n\t\t\t{mi.MissionDescribe.Replace("\r\n","\r\n\t\t\t")}"); outInfo.Add($"\t\treceive Npc: {NpcRepository.Self.GetNpcName(mi.MissionReceiveNPC)}"); outInfo.Add($"\t\tpreTalk: {mi.PreTalk}"); outInfo.Add($"\t\tPossible rewards:"); foreach (MissionRewards mr in mi.m_missionRewardsList) { outInfo.Add($"\r\n\t\t\tMoney: {mr.Money}"); outInfo.Add($"\t\t\tExp: {mr.Exp}"); outInfo.Add($"\t\t\tItems:"); foreach (IdCount idc in mr.ItemList) { outInfo.Add($"\t\t\t\t{Module<ItemDataMgr>.Self.GetItemName(idc.id)} {idc.count}"); } outInfo.Add($"\t\t\tFavor:"); foreach (IdCount idc in mr.FavorList) { outInfo.Add($"\t\t\t\t{Module<NpcRepository>.Self.GetNpcName(idc.id)} {idc.count}"); } outInfo.Add($"\t\t\tRep: {mr.Reputation}"); } PsScript script = Module <Story> .Self.ScriptMgr.MScriptList.Find(s => s.Id == mi.MissionId); if (script != null) { outInfo.Add("\t\tVariables:"); if (script.VarDict != null) { foreach (KeyValuePair <string, Variable> kvp in script.VarDict) { outInfo.Add("\t\t\t" + kvp.Key + " " + kvp.Value); } } } }
private static void OpenShippingBin() { if (!enabled) { return; } Action <List <IdCount> > action = delegate(List <IdCount> ls) { SellItems(ls); }; UIStateMgr.Instance.ChangeStateByType(UIStateMgr.StateType.PackageExchangeState, true, new object[] { new List <IdCount>(), TextMgr.GetStr(101347, -1) + " (" + (Math.Round(Module <StoreManagerV40> .Self.CurPriceIndex * 100)) + "%)", false, action, 103521, 300 }); }
static void Prefix(List <AnimalData> ___datas) { if (!enabled) { return; } if (___datas == null) { SqliteDataReader sqliteDataReader = LocalDb.cur.ReadFullTable("AnimalFarm_Animal"); if (sqliteDataReader == null) { return; } ___datas = DbReader.Read <AnimalData>(sqliteDataReader, 20); } for (int i = 0; i < ___datas.Count; i++) { typeof(AnimalData).GetProperty("TotalPoint").SetValue(___datas[i], (int)Math.Round(___datas[i].StandardPoint * settings.MaxAnimalGrowthPercent / 100f), null); string name = TextMgr.GetStr(___datas[i].NameId, -1); Dbgl($"{name} max points set to {___datas[i].TotalPoint}"); } }
static void ShowHunger(FishBowlUnitViewer __instance, FishBowlUnit ___fishBowlUnit) { FieldRef <UnitViewer, PlayerTargetMultiAction> CurPlayerTargetRef = FieldRefAccess <UnitViewer, PlayerTargetMultiAction>("playerTarget"); PlayerTargetMultiAction CurPlayerTarget = CurPlayerTargetRef(__instance); if (CurPlayerTarget == null) { return; } Dbgl("Showing Hunger"); int count = ___fishBowlUnit.FishCount; int hungry = count; for (int i = 0; i < count; i++) { if (___fishBowlUnit.GetFish(i).isFull) { hungry--; } } ItemObject curUseItem = Module <Player> .Self.bag.itemBar.GetCurUseItem(); if (curUseItem != null && FishData.HasId(curUseItem.ItemDataId)) { CurPlayerTarget.SetAction(ActionType.ActionAttack, TextMgr.GetStr(300315, -1), ActionTriggerMode.Normal); } else if (curUseItem != null && FishFeedItem.HasId(curUseItem.ItemDataId)) { CurPlayerTarget.SetAction(ActionType.ActionAttack, TextMgr.GetStr(300317, -1) + " (Hungry: " + hungry + "/" + ___fishBowlUnit.FishCount + ")", ActionTriggerMode.Normal); } else { CurPlayerTarget.RemoveAction(ActionType.ActionAttack, ActionTriggerMode.Normal); } }
private static List <string> GetMissionInfo(string dumpMissionInfoTempVal, List <string> outInfo = null) { if (outInfo == null) { outInfo = new List <string>(); } MissionBaseInfo mbi = MissionManager.allMissionBaseInfo[int.Parse(dumpMissionInfoTempVal)]; outInfo.Add($"Mission NO: {mbi.MissionNO}"); outInfo.Add($"IsMain: {mbi.IsMain}"); outInfo.Add($"Mission Name: {TextMgr.GetStr(mbi.MissionNameId, -1)}"); outInfo.Add($"Properties: {mbi.Properties}"); outInfo.Add($"Group Type: {mbi.GroupType}"); outInfo.Add($"Group Id: {mbi.GroupId}"); List <string> outDesc = new List <string>(); foreach (int i in mbi.description) { outDesc.Add(TextMgr.GetStr(i, -1)); } outInfo.Add($"description:\r\n\t{string.Join("\r\n\t", outDesc.ToArray())}"); outInfo.Add($"receive Npc: {NpcRepository.Self.GetNpcName(mbi.receiveNpc)}"); outInfo.Add($"preTalk: {mbi.preTalk}"); outInfo.Add($"reward:\r\n\t{string.Join("\r\n\t", mbi.reward.ToArray())}"); PsScript script = Module <Story> .Self.ScriptMgr.MScriptList.Find(s => s.Id == int.Parse(dumpMissionInfoTempVal)); if (script != null) { outInfo.Add("Variables:"); foreach (KeyValuePair <string, Variable> kvp in script.VarDict) { outInfo.Add("\t" + kvp.Key + " " + kvp.Value); } } return(outInfo); }
static void Postfix(PlantingBoxInfoUI __instance, bool isInit, ref TextMeshProUGUI ___progText, bool ___isEnable, bool ___riped, bool ___isBadSeason, GameTimeSpan ___timeToRipe) { if (!enabled) { return; } if (!isInit) { if (!__instance.enabled) { return; } if (!___isEnable) { return; } } GameTimeSpan gts = new GameTimeSpan((long)Math.Round(___timeToRipe.Ticks / settings.plantGrowMult)); if (!___riped && !___isBadSeason && gts.TotalDays <= 99.0) { if (gts.TotalDays < 1) { ___progText.text = string.Format(TextMgr.GetStr(100373, -1), gts.Hours, gts.Minutes); } else if (gts.TotalDays < 2) { ___progText.text = string.Format($"{TextMgr.GetStr(100972, -1)} {TextMgr.GetStr(100373, -1)}", (int)gts.TotalDays, gts.Hours, gts.Minutes).Replace("(s)", "").Replace("(e)", ""); } else { ___progText.text = string.Format($"{TextMgr.GetStr(100972, -1)} {TextMgr.GetStr(100373, -1)}", (int)gts.TotalDays, gts.Hours, gts.Minutes).Replace("(s)", "s").Replace("(e)", "e"); } } }
static void ShowHunger(FishBowlUnitViewer __instance, FishBowlUnit ___fishBowlUnit) { PlayerTargetMultiAction CurPlayerTarget = (PlayerTargetMultiAction)typeof(UnitViewer).GetProperty("CurPlayerTarget", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance, null); if (CurPlayerTarget == null) { return; } Dbgl("Showing Hunger"); FishBowl fishBowl = AccessTools.FieldRefAccess <FishBowlUnit, FishBowl>(___fishBowlUnit, "fishBowl"); float max = AccessTools.FieldRefAccess <FishBowl, FishBowl.FishBowlData>(fishBowl, "data").volumn; float maxmax = AccessTools.FieldRefAccess <FishBowl, FishBowl.FishBowlData>(fishBowl, "data").maxVolumn; int count = ___fishBowlUnit.FishCount; int hungry = 0; float chp = 0; float mhp = 0; float lhp = 0; Dictionary <int, List <FishInFishBowl> > fcounts = new Dictionary <int, List <FishInFishBowl> >(); for (int i = 0; i < count; i++) { FishInFishBowl fish = ___fishBowlUnit.GetFish(i); if (fcounts.ContainsKey(fish.FishId)) { fcounts[fish.FishId].Add(fish); } else { fcounts.Add(fish.FishId, new List <FishInFishBowl>() { fish }); } chp += fish.CurHp; mhp += fish.MaxHp; if (fish.CurHp > 0 && (lhp <= 0 || fish.CurHp / fish.MaxHp < lhp)) { lhp = fish.CurHp / fish.MaxHp; } if (fish.IsHunger) { hungry++; } } List <string> fishs = new List <string>(); foreach (KeyValuePair <int, List <FishInFishBowl> > kvp in fcounts) { int next = int.MaxValue; List <FishInFishBowl> list = kvp.Value; for (int i = list.Count - 1; i >= 0; i--) { if (!list[i].IsDead && (!list[i].IsHunger || list[i].CanReproduce)) { for (int j = 0; j < i; j++) { if (!list[j].IsDead && list[j].FishId == list[i].FishId && (!list[i].IsHunger || list[i].CanReproduce)) { FishData data1 = AccessTools.FieldRefAccess <FishInFishBowl, FishData>(list[i], "data"); int reproduce1 = AccessTools.FieldRefAccess <FishInFishBowl, int>(list[i], "reproduceDayCount"); int thisNext1 = data1.DayToReproduce - reproduce1; FishData data2 = AccessTools.FieldRefAccess <FishInFishBowl, FishData>(list[j], "data"); int reproduce2 = AccessTools.FieldRefAccess <FishInFishBowl, int>(list[j], "reproduceDayCount"); int thisNext2 = data2.DayToReproduce - reproduce2; int thisNext = Math.Max(thisNext1, thisNext2); if (thisNext < next) { next = thisNext; } } } } } string nextRepro = next < int.MaxValue ? string.Format(strings[0], next) : ""; fishs.Add($"{kvp.Value.Count} {Module<ItemDataMgr>.Self.GetItemName(kvp.Key)}{nextRepro}"); } if (___fishBowlUnit.HasDeadFish()) { CurPlayerTarget.SetAction(ActionType.ActionInteract, TextMgr.GetStr(300318, -1), ActionTriggerMode.Normal); } else if (___fishBowlUnit.FishCount > 0) { string full = ""; if (count >= maxmax) { full = strings[1]; } else if (count >= max) { full = strings[2]; } CurPlayerTarget.SetAction(ActionType.ActionInteract, $"{TextMgr.GetStr(300316, -1)} ({count}/{maxmax}{full})", ActionTriggerMode.Normal); CurPlayerTarget.SetAction(ActionType.ActionMoveBack, $"{string.Join("\r\n",fishs.ToArray())}", ActionTriggerMode.Normal); CurPlayerTarget.SetAction(ActionType.ActionFavor, string.Format(strings[3], hungry, Math.Round(chp / mhp * 100), Math.Round(lhp * 100)), ActionTriggerMode.Normal); } else { CurPlayerTarget.RemoveAction(ActionType.ActionInteract, ActionTriggerMode.Normal); CurPlayerTarget.RemoveAction(ActionType.ActionMoveBack, ActionTriggerMode.Normal); CurPlayerTarget.RemoveAction(ActionType.ActionFavor, ActionTriggerMode.Normal); } return; }
private static void OnSceneLoaded(ScenarioModule.Arg arg) { Module <ScenarioModule> .Self.EndLoadEventor -= OnSceneLoaded; if (!isLoading) { return; } Module <Player> .Self.GamePos = VectorFromString(lastLoadedSave.position); Dbgl("input solution: " + Module <InputSolutionModule> .Self.CurSolutionType + ""); Module <InputSolutionModule> .Self.Pop(); Module <InputSolutionModule> .Self.Push(SolutionType.Gaming); //Module<SleepModule>.Self.GetType().GetMethod("PlayerWakeUpAfterArchive", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(Module<SleepModule>.Self, new object[] { }); //Module<SleepModule>.Self.GetType().GetMethod("ShowSleepMask", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(Module<SleepModule>.Self, new object[] { false }); //MessageManager.Instance.Dispatch("WakeUpScreen", null, DispatchType.IMME, 2f); //Module<SleepModule>.Self.WakeUpScreenMaskFinishedEvent?.Invoke(); Singleton <SleepTipMgr> .Self.SleepState(false); Dbgl("Checking DLC"); // stuff that needs to be recreated after save GameDLCRewardsModule.Self.GetType().GetMethod("CheckAndOpenAllDlc", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(Module <GameDLCRewardsModule> .Self, new object[] { }); Dbgl("Checking Engagement"); if (Module <EGMgr> .Self.IsEngagement()) { Dbgl("Engagement is active"); EGDate date = AccessTools.FieldRefAccess <EGMgr, EGDate>(Module <EGMgr> .Self, "mDate"); GameDateTime dateBegin = AccessTools.FieldRefAccess <EGDate, GameDateTime>(date, "mBeginTimer"); if (Module <TimeManager> .Self.DateTime > dateBegin) { date.GetType().GetMethod("InitProjectMap", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(date, new object[] { }); Actor mActor = AccessTools.FieldRefAccess <EGDate, Actor>(date, "mActor"); AccessTools.FieldRefAccess <EGDate, Actor>(date, "mActor").SetBehaviorValue("EGActor", Module <Player> .Self.actor); AccessTools.FieldRefAccess <EGDate, Actor>(date, "mActor").SetBehaviorValue("EGDate", EGData.GetDatePlace(AccessTools.FieldRefAccess <EGDate, int>(date, "mDateID"))); AccessTools.FieldRefAccess <EGDate, SharedInt>(date, "mForceValue") = mActor.GetBehaviorVariable <SharedInt>("EGForce"); AccessTools.FieldRefAccess <EGDate, SharedInt>(date, "mMoodValue") = mActor.GetBehaviorVariable <SharedInt>("EGMood"); AccessTools.FieldRefAccess <EGDate, SharedIntList>(date, "mEventCount") = mActor.GetBehaviorVariable <SharedIntList>("EGEventIDs"); AccessTools.FieldRefAccess <EGDate, List <EGRoot> >(date, "mRoots") = mActor.behavior.FindTasks <EGRoot>(); date.Start(); Dbgl("Engagement starts with " + mActor.ActorName); } else if (Module <TimeManager> .Self.DateTime > dateBegin - EGConst.Spawn_Hour_1) { Dbgl("Less than one hour before engagement starts!"); date.GetType().GetMethod("InitProjectMap", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(date, new object[] { }); Actor mActor = AccessTools.FieldRefAccess <EGDate, Actor>(date, "mActor"); AccessTools.FieldRefAccess <EGDate, Actor>(date, "mActor").SetBehaviorValue("EGActor", Module <Player> .Self.actor); AccessTools.FieldRefAccess <EGDate, Actor>(date, "mActor").SetBehaviorValue("EGDate", EGData.GetDatePlace(AccessTools.FieldRefAccess <EGDate, int>(date, "mDateID"))); AccessTools.FieldRefAccess <EGDate, SharedInt>(date, "mForceValue") = mActor.GetBehaviorVariable <SharedInt>("EGForce"); AccessTools.FieldRefAccess <EGDate, SharedInt>(date, "mMoodValue") = mActor.GetBehaviorVariable <SharedInt>("EGMood"); AccessTools.FieldRefAccess <EGDate, SharedIntList>(date, "mEventCount") = mActor.GetBehaviorVariable <SharedIntList>("EGEventIDs"); AccessTools.FieldRefAccess <EGDate, List <EGRoot> >(date, "mRoots") = mActor.behavior.FindTasks <EGRoot>(); Singleton <TipsMgr> .Instance.SendSystemTip(string.Format(TextMgr.GetStr(100507, -1), TextMgr.GetStr(AccessTools.FieldRefAccess <EGDate, int>(date, "mTipTypeID"), -1)), SystemTipType.warning); } else if (Module <TimeManager> .Self.DateTime > dateBegin - EGConst.Spawn_Hour_2) { Dbgl("Less than two hours hour before engagement starts!"); date.GetType().GetMethod("InitProjectMap", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(date, new object[] { }); Actor mActor = AccessTools.FieldRefAccess <EGDate, Actor>(date, "mActor"); AccessTools.FieldRefAccess <EGDate, Actor>(date, "mActor").SetBehaviorValue("EGActor", Module <Player> .Self.actor); AccessTools.FieldRefAccess <EGDate, Actor>(date, "mActor").SetBehaviorValue("EGDate", EGData.GetDatePlace(AccessTools.FieldRefAccess <EGDate, int>(date, "mDateID"))); AccessTools.FieldRefAccess <EGDate, SharedInt>(date, "mForceValue") = mActor.GetBehaviorVariable <SharedInt>("EGForce"); AccessTools.FieldRefAccess <EGDate, SharedInt>(date, "mMoodValue") = mActor.GetBehaviorVariable <SharedInt>("EGMood"); AccessTools.FieldRefAccess <EGDate, SharedIntList>(date, "mEventCount") = mActor.GetBehaviorVariable <SharedIntList>("EGEventIDs"); AccessTools.FieldRefAccess <EGDate, List <EGRoot> >(date, "mRoots") = mActor.behavior.FindTasks <EGRoot>(); Singleton <TipsMgr> .Instance.SendSystemTip(string.Format(TextMgr.GetStr(100506, -1), TextMgr.GetStr(AccessTools.FieldRefAccess <EGDate, int>(date, "mTipTypeID"), -1)), SystemTipType.warning); } } if (arg.IsMain) { Dbgl("Checking Ridables"); Module <FarmModule> .Self.ForeachUnit(delegate(Unit unit, bool isFloor) { if (unit != null && unit is RidableTamingUnit) { RidableTamingUnit ru = unit as RidableTamingUnit; GameObject unitGameObjectByUnit = Module <FarmModule> .Self.GetUnitGameObjectByUnit(unit); if (unitGameObjectByUnit == null) { return; } RidableTamingUnitViewer uv = (RidableTamingUnitViewer)unitGameObjectByUnit.GetComponentInChildren <UnitViewer>(); AccessTools.FieldRefAccess <RidableTamingUnitViewer, List <IRidable> >(uv, "ridableList").Clear(); typeof(RidableTamingUnitViewer).GetMethod("CreateShit", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(uv, new object[] { }); typeof(RidableTamingUnitViewer).GetMethod("CreateAllWorkableRidable", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(uv as RidableTamingUnitViewer, new object[] { }); typeof(RidableTamingUnitViewer).GetMethod("UpdateAllRidableInfo", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(uv as RidableTamingUnitViewer, new object[] { }); } }); typeof(RidableModuleManager).GetMethod("InitIdGenerator", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(Module <RidableModuleManager> .Self, new object[] { }); Dictionary <int, RidableTransactionSaveData> rideDic = AccessTools.FieldRefAccess <RidableModuleManager, Dictionary <int, RidableTransactionSaveData> >(Module <RidableModuleManager> .Self, "ridableTransactionDataDic"); int[] rideKeys = new int[rideDic.Count]; rideDic.Keys.CopyTo(rideKeys, 0); foreach (int key in rideKeys) { if (rideDic[key].RidableSource == RidableSource.NPC) { AccessTools.FieldRefAccess <RidableModuleManager, Dictionary <int, RidableTransactionSaveData> >(Module <RidableModuleManager> .Self, "ridableTransactionDataDic").Remove(key); } } Scene sceneByName = SceneManager.GetSceneByName(arg.scenarioName); if (sceneByName.IsValid() && sceneByName.isLoaded) { GameObject[] gos = sceneByName.GetRootGameObjects(); foreach (GameObject go in gos) { Component co = go.GetComponentInChildren(typeof(NpcsRidableManager)); if (co != null) { Dbgl("Got NpcsRidableManager"); (co as NpcsRidableManager).DestoryAllRidable(); AccessTools.FieldRefAccess <RidableFences, Dictionary <IRidable, RidableFence> >((co as NpcsRidableManager), "ridableDic").Clear(); typeof(NpcsRidableManager).GetMethod("AfterPlayerWakeUpEvent", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(co as NpcsRidableManager, new object[] { }); } } } } Dbgl("Checking wishes"); AccessTools.FieldRefAccess <DynamicWishManager, List <int> >(Module <DynamicWishManager> .Self, "hasTalkToday").AddRange(from it in AccessTools.FieldRefAccess <DynamicWishManager, List <DoubleInt> >(Module <DynamicWishManager> .Self, "curWishData") select it.id0); //Module<RidableModuleManager>.Self.InitNpcRidableBehaviourValue(); // stuff that needs to be carried over but isnt, use meta file Dbgl("Loading Meta"); string filePath = Path.Combine(GetSavesPath(), $"{lastLoadedSave.fileName}.xml"); try { System.Xml.Serialization.XmlSerializer reader = new System.Xml.Serialization.XmlSerializer(typeof(SaveMeta)); StreamReader file = new StreamReader($"{filePath}"); SaveMeta save = (SaveMeta)reader.Deserialize(file); file.Close(); Dbgl("Loading Player Meta"); if (save.playerRot != null) { string[] rotStrings = save.playerRot.Replace("(", "").Replace(")", "").Replace(" ", "").Split(','); Quaternion rot = new Quaternion(float.Parse(rotStrings[0]), float.Parse(rotStrings[1]), float.Parse(rotStrings[2]), float.Parse(rotStrings[3])); Player.Self.GameRot = rot; } Dbgl("Loading NPC Meta"); foreach (NPCMeta npc in save.NPClist) { Actor actor = Module <ActorMgr> .Self.Get(npc.id); if (actor != null) { Module <ActorMgr> .Self.MoveToScenario(actor, npc.scene, VectorFromString(npc.pos)); } } Dbgl("Loading Ridable Meta"); if (save.RideableList != null) { foreach (RideableMeta r in save.RideableList) { IRidable rideable = Module <RidableModuleManager> .Self.GetRidable(r.id); if (rideable == null) { Dbgl("null rideable " + r.id); rideable = Module <RidableModuleManager> .Self.GetRidable(r.id); continue; } Dbgl("got rideable " + r.id); Actor actor = rideable.GetActor(); if (actor != null) { Dbgl("got rideable actor for " + rideable.GetNickName()); actor.gamePos = VectorFromString(r.pos); actor.RefreshPos(); } switch (r.state) { case "None": rideable.SetRidableState(RidableState.None); break; case "Idle": rideable.SetRidableState(RidableState.Idle); break; case "Ride": if (rideable.BelongToPlayer) { int otherNPCID = Module <EGMgr> .Self.GetEngagementStartNpcID(); if (RideUtils.TestRideWithNpcID > 0) { otherNPCID = RideUtils.TestRideWithNpcID; RideUtils.TestRideWithNpcID = -1; } Module <Player> .Self.RideRidable(rideable, otherNPCID); } else if (rideable.GetBelongRider() is ActorRiderAdapter) { Actor belongActor = (rideable.GetBelongRider() as ActorRiderAdapter).actor; RideController rideController = belongActor.RideController; rideController.RideOn(rideable); } break; case "Follow": rideable.SetRidableState(RidableState.Follow); break; case "Stay": rideable.SetRidableState(RidableState.Stay); break; } } } Dbgl("Loading Fishbowl Meta"); if (save.FishBowlConsumeHour != -1) { typeof(FishBowl).GetField("consumeHour", BindingFlags.NonPublic | BindingFlags.Static).SetValue(Module <FishBowl> .Self, save.FishBowlConsumeHour); } Dbgl("Loading Store Meta"); AccessTools.FieldRefAccess <StoreManagerV40, float>(Module <StoreManagerV40> .Self, "curPriceIndex") = save.CurPriceIndex; if (save.StoreList != null) { foreach (StoreMeta sMeta in save.StoreList) { Module <StoreManagerV40> .Self.GetStore(sMeta.id).recycleCount = sMeta.recycleCount; Module <StoreManagerV40> .Self.GetStore(sMeta.id).ownMoney = sMeta.money; } } Dbgl("Loading Weather Meta"); if (save.WeatherState != -1) { AccessTools.FieldRefAccess <WeatherModule, WeatherCtr>(Module <WeatherModule> .Self, "weatherCtr").SetWeather((WeatherState)save.WeatherState); } } catch (Exception ex) { Dbgl("Problem with meta file: " + ex); } isLoading = false; resetLastSave(); }
private static void OnGUI(UnityModManager.ModEntry modEntry) { for (int i = 0; i < sortedIdToNames.Count; i++) { string id = sortedIdToNames.Keys.ToArray()[i]; bool enable = (bool)typeof(Settings).GetField($"EnableCustomModelFor{id}").GetValue(settings); string modelId = (string)typeof(Settings).GetField($"CustomModelFor{id}").GetValue(settings); if (modelId == null || !idToModels.ContainsKey(modelId)) { modelId = defaultModelIdForId[id]; } typeof(Settings).GetField($"EnableCustomModelFor{id}").SetValue(settings, GUILayout.Toggle(enable, string.Format(" Enable custom model for {0} ({1}){2}", Module <NpcRepository> .Self.GetNpcName(int.Parse(id)), id, (enable? string.Format(": <b>{0}</b> (<i>{1}</i>)", TextMgr.GetStr(int.Parse(sortedIdToNames[modelId]), -1), idToModels[modelId]) : "")), new GUILayoutOption[0])); if (enable) { typeof(Settings).GetField($"CustomModelFor{id}").SetValue(settings, idToModels.Keys.ToArray()[(int)GUILayout.HorizontalSlider(idToModels.Keys.ToArray().IndexOf(modelId), 0f, idToModels.Keys.Count - 1, new GUILayoutOption[0])]); } } }
static void Postfix(MissionUICtr __instance, GridPage ___missionTitleGrid) { void RestartMission(int index) { MissionType curShowType = curShowTypeByRef(__instance); List <MissionHistoryRecord> historyRecord = Module <MissionManager> .Self.HistoryRecord; List <Mission> missionProgress = Module <MissionManager> .Self.GetMissionRunning(); List <MissionHistoryRecord> missionNormalDone = new List <MissionHistoryRecord>(); for (int i = 0; i < historyRecord.Count; i++) { if (!historyRecord[i].IsOrderMission) { missionNormalDone.Add(historyRecord[i]); } } MissionBaseInfo m = null; if (curShowType == MissionUICtr.MissionType.progress && index < missionProgress.Count && index >= 0) { Dbgl("clicked progress mission"); m = MissionManager.GetmissionBaseInfo(missionProgress[index].InstanceID); } else if (curShowType == MissionUICtr.MissionType.normalDone && index < missionNormalDone.Count && index >= 0) { m = MissionManager.GetmissionBaseInfo(missionNormalDone[index].InstanceId); Dbgl("clicked done mission " + missionNormalDone[index].InstanceId + " " + missionNormalDone[index].MissionNo); List <Mission> doneMissions = missions_EndTypeByRef(MissionManager.GetInstance); Dbgl("done missions before: " + doneMissions.Count); doneMissions.RemoveAll((Mission it) => it.InstanceID == m.InstanceID); MissionManager.GetInstance.HistoryRecord.RemoveAll((MissionHistoryRecord hr) => hr.InstanceId == m.InstanceID); missionNormalDone.Remove(missionNormalDone[index]); Dbgl("done missions after: " + doneMissions.Count); MissionManager.GetInstance.GetType().GetField("m_missions_End", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(MissionManager.Self, doneMissions); Dbgl("real done missions after: " + missions_EndTypeByRef(MissionManager.Self).Count); } if (m != null) { Dbgl("clicked mission not null id:" + m.InstanceID + " number:" + m.MissionNO + " name: " + TextMgr.GetStr(m.MissionNameId, -1)); return; //MethodInfo dynMethod = MissionManager.GetInstance.GetType().GetMethod("InitSaveData", BindingFlags.NonPublic | BindingFlags.Instance); //dynMethod.Invoke(MissionManager.GetInstance, new object[] { }); MissionManager.GetInstance.UpgradeRecord(); MissionManager.GetInstance.RefreshAllNpcMissionIcon(); MissionManager.GetInstance.DispatcherMissionTargetRefresh(); MissionManager.GetInstance.FreshTrace(); Mission mi = new Mission(); mi.InitFromBaseInfo(m); MissionManager.GetInstance.DeliverMission(mi); } } ___missionTitleGrid.OnMiddleClick += RestartMission; }
public static bool Prefix(WholeMapViewer __instance, Image image, MapHoverDetail details, bool isDrag, ref Vector2 nearestAim, List <IMap> ___imapShowInfo, List <MapIconData> ___listIconPrefabs) { if (!enabled) { return(true); } nearestAim = Vector2.zero; float num = 100f; bool flag = false; ___imapShowInfo.Clear(); if (!isDrag) { Rect rect = WholeMapViewer.RectTransformToWorldSpace(image.rectTransform); for (int i = 0; i < ___listIconPrefabs.Count; i++) { if (!(___listIconPrefabs[i].iconObject == null)) { if (___listIconPrefabs[i].iconObject.gameObject.activeSelf) { MapIconPoolObj iconObject = ___listIconPrefabs[i].iconObject; Rect other = WholeMapViewer.RectTransformToWorldSpace(iconObject.ColRect); if (Singleton <InputDeviceDetector> .Instance.CurDevice != InputDevice.MouseKeyboard) { Vector3 v = input.GetActiveIcon().rectTransform.InverseTransformPoint(___listIconPrefabs[i].iconObject.transform.position); float num2 = Vector2.Distance(Vector2.zero, v); if (num > num2) { num = num2; nearestAim = v; } } if (rect.Overlaps(other)) { ___imapShowInfo.Add(___listIconPrefabs[i].imap); MapIconInteractTransfer component = ___listIconPrefabs[i].iconObject.GetComponent <MapIconInteractTransfer>(); if (component != null && curTransfer == null && Input.GetMouseButton(0)) { flag = true; curTransfer = component; Dbgl(rect.ToString()); IMap imap = AccessTools.FieldRefAccess <MapIconInteractTransfer, IMap>(component, "curImap"); int tranId = Singleton <TransferTransIdDataBase> .Self.GetTranId((imap as SceneItemTransfer_IMap).SItem.ID); string name = (tranId <= 0) ? string.Empty : TextMgr.GetStr(tranId, -1); //Dbgl($"name: {name} pos: {imap.GetPos()}"); break; } } } } } } if (!flag) { return(true); } details.Fresh(___imapShowInfo); return(false); }
public override string GetContent() { string text = "<b>" + TextMgr.GetStr(103556, -1) + "</b>\r\n\r\n" + TextMgr.GetStr(contentId, -1) + "\r\n\r\n" + money; return(text); }
private static bool Prefix(ref AnimalFarmUnit __instance) { if (!enabled) { return(false); } if (__instance.Animals.Count >= __instance.HouseData.AnimalMax) { Dbgl($"farm already full, cancelling"); return(false); } int tipsId; Dictionary <int, List <AnimalinFarm> > aifs = new Dictionary <int, List <AnimalinFarm> >(); foreach (AnimalinFarm aif in __instance.Animals) { if (aif.Age >= aif.Data.StandardPoint) { if (aifs.ContainsKey(aif.Data.Id)) { aifs[aif.Data.Id].Add(aif); } else { aifs.Add(aif.Data.Id, new List <AnimalinFarm>() { aif }); } } } Dictionary <int, int> newAnimals = new Dictionary <int, int>(); foreach (KeyValuePair <int, List <AnimalinFarm> > kvp in aifs) { newAnimals.Add(kvp.Key, 0); } while (aifs.Keys.Count > 0) { if (__instance.Animals.Count >= __instance.HouseData.AnimalMax) { Dbgl($"farm filled up, breaking"); break; } int idx = aifs.Keys.ToArray()[UnityEngine.Random.Range(0, aifs.Count - 1)]; if (aifs[idx].Count < 2) { aifs.Remove(idx); } else { List <AnimalinFarm> aifl = aifs[idx]; List <AnimalinFarm> matureAnimals = aifl.FindAll((AnimalinFarm a) => a.Age >= a.Data.StandardPoint); if (matureAnimals.Count < 2) { aifs.Remove(idx); } else { int a = UnityEngine.Random.Range(0, matureAnimals.Count - 1); AnimalinFarm aa = matureAnimals[a]; matureAnimals.RemoveAt(a); int b = UnityEngine.Random.Range(0, matureAnimals.Count - 1); AnimalinFarm ab = matureAnimals[a]; matureAnimals.RemoveAt(b); float chancea = settings.BasePregnancyChance + (100 - settings.BasePregnancyChance) * ((aa.Age - aa.Data.StandardPoint) / aa.Data.StandardPoint); float chanceb = settings.BasePregnancyChance + (100 - settings.BasePregnancyChance) * ((ab.Age - ab.Data.StandardPoint) / ab.Data.StandardPoint); float chance = (chancea + chanceb) / 2f; Dbgl($"type: {idx} age: {aa.Age} {ab.Age} preg chance: {chance}"); if (UnityEngine.Random.Range(0, 100) <= chance) { Dbgl($"birthing"); __instance.AddAnimal(idx, out tipsId); typeof(AnimalinFarm).GetField("age", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(aa, aa.Data.StandardPoint); typeof(AnimalinFarm).GetField("age", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(ab, ab.Data.StandardPoint); newAnimals[idx]++; } aifs[idx].Remove(aa); aifs[idx].Remove(ab); } } } foreach (KeyValuePair <int, int> kvp in newAnimals) { if (kvp.Value > 0) { string name = TextMgr.GetStr(AnimalData.GetDataByDataId(kvp.Key).NameId, -1); Dbgl($"sending tips ui"); Singleton <TipsMgr> .Instance.SendSystemTip($"{(kvp.Value > 1 ? kvp.Value + " " + name + "s" : "A " + name)} gave birth!"); } } return(false); }