Exemple #1
0
            static bool Prefix(TVBenchUnitViewer __instance, CabinetUnit ___cabineUnit)
            {
                if (!enabled || __instance.GetComponentInParent <PhotoFrameCtr>() == null)
                {
                    return(true);
                }
                Dbgl($"Fresh Actions");
                return(false);

                PlayerTargetMultiAction CurPlayerTarget = (PlayerTargetMultiAction)typeof(UnitViewer).GetProperty("CurPlayerTarget", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance, null);

                CurPlayerTarget.SetAction(ActionType.ActionInteract, 103809, ActionTriggerMode.Normal);
                CurPlayerTarget.RemoveAction(ActionType.ActionInteract, ActionTriggerMode.Hold);

                return(false);


                ItemObject item = ___cabineUnit.GetItem(0);

                CurPlayerTarget.RemoveAction(ActionType.ActionRoll, ActionTriggerMode.Normal);
                if (item != null)
                {
                }
                CurPlayerTarget.SetAction(ActionType.ActionRoll, "Switch", ActionTriggerMode.Normal);
            }
Exemple #2
0
 static void Postfix(AutomataMachiePlace __instance, int ___plugType)
 {
     if (___plugType == 4)
     {
         PlayerTargetMultiAction CurPlayerTarget = (PlayerTargetMultiAction)typeof(UnitViewer).GetProperty("CurPlayerTarget", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance, null);
         CurPlayerTarget.SetAction(ActionType.ActionRoll, 101174, ActionTriggerMode.Normal);
     }
 }
Exemple #3
0
            static void Postfix(PlayerTargetMultiAction ___playerTarget)
            {
                if (!enabled)
                {
                    return;
                }

                ___playerTarget.SetAction(ActionType.ActionRoll, 101208, ActionTriggerMode.Normal);
            }
Exemple #4
0
        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);
            }
        }
Exemple #5
0
        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;
        }
Exemple #6
0
            static void Postfix(PhotoFrameCtr __instance)
            {
                if (!enabled)
                {
                    return;
                }
                Dbgl($"starting photoframectr");

                MeshRenderer[] bbms = __instance.gameObject.GetComponentsInChildren <MeshRenderer>();

                MeshRenderer screenMr = null;

                foreach (MeshRenderer m in bbms)
                {
                    //Dbgl($"mesh: {m.name}");
                    if (m.name == "Item_Billboard_2")
                    {
                        screenMr = m;
                        break;
                    }
                }

                if (screenMr == null)
                {
                    return;
                }

                GameObject tvt = Singleton <ResMgr> .Instance.LoadSyncByType <GameObject>(AssetType.Home, "HomeItem_TVTable");

                TVBenchUnitViewer tvtv = tvt.GetComponentInChildren <TVBenchUnitViewer>(true);

                /*
                 * CabinetUnit unit = new CabinetUnit(3031001);
                 * unit.PutCabinet(4030001, 1, out ItemObject item);
                 * typeof(TVBenchUnitViewer).GetMethod("SetUnitInternal", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(tvtv, new object[] { unit });
                 * Dbgl($"Set Unit");
                 */

                GameObject tvtr = UnityEngine.Object.Instantiate(tvt, __instance.gameObject.transform);
                //Dbgl($"Instantiated");


                ItemObject item = ItemObject.CreateItem(4030001);

                //Dbgl($"got item {item.ItemBase.Name}");

                GameUtils.ClearChildren(typeof(TVBenchUnitViewer).GetField("placeHolder", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(tvtv) as GameObject, false);
                GameObject tvObject = GameUtils.AddChild(typeof(TVBenchUnitViewer).GetField("placeHolder", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(tvtv) as GameObject, item.ItemBase.DropModelPath, false, AssetType.ItemSystem);
                TVCtr      tvc      = tvObject.GetComponentInChildren <TVCtr>(true);

                //Dbgl($"tvc is null? {tvc == null}");

                typeof(TVBenchUnitViewer).GetField("tVCtr", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(tvtv, tvc);

                MeshRenderer[] tvtms = tvtr.GetComponentsInChildren <MeshRenderer>();

                for (int i = 0; i < tvtms.Length; i++)
                {
                    MeshRenderer m = tvtms[i];
                    m.gameObject.SetActive(false);
                }

                MeshRenderer[] tvms = tvObject.GetComponentsInChildren <MeshRenderer>();

                for (int i = 0; i < tvms.Length; i++)
                {
                    MeshRenderer m = tvms[i];
                    m.gameObject.SetActive(false);
                }

                GameObject screen = typeof(TVCtr).GetField("screen", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(tvc) as GameObject;

                screen.GetComponentInChildren <MeshFilter>().mesh = screenMr.GetComponentInChildren <MeshFilter>().mesh;

                //screen.transform.localScale = new Vector3(32f, 18f, 1f);

                PlayerTargetMultiAction CurPlayerTarget = (PlayerTargetMultiAction)typeof(UnitViewer).GetProperty("CurPlayerTarget", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance, null);

                CurPlayerTarget.SetAction(ActionType.ActionRoll, 103809, ActionTriggerMode.Normal);
            }