/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { IStateSimulation coreState = new FishBowl(); using (var game = new Game(coreState)) { game.Run(); } }
protected override void FinishEffect(Point3D p, Map map, Mobile from) { if (from.Skills.Fishing.Value < 10) { from.SendLocalizedMessage(1074487); // The creatures are too quick for you! } else { BaseFish fish = GiveFish(from); FishBowl bowl = Aquarium.GetEmptyBowl(from); if (bowl != null) { fish.StopTimer(); bowl.AddItem(fish); from.SendLocalizedMessage(1074489); // A live creature jumps into the fish bowl in your pack! Delete(); return; } else { if (from.PlaceInBackpack(fish)) { from.PlaySound(0x5A2); from.SendLocalizedMessage(1074490); // A live creature flops around in your pack before running out of air. fish.Kill(); Delete(); return; } else { fish.Delete(); from.SendLocalizedMessage(1074488); // You could not hold the creature. } } } InUse = false; Movable = true; if (!from.PlaceInBackpack(this)) { if (from.Map == null || from.Map == Map.Internal) { Delete(); } else { MoveToWorld(from.Location, from.Map); } } }
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; }