/// <summary> /// (Cross-Game compatible) Return the existing BloonToSimulation for this specific Bloon. If it doesn't exist one will be created and stored /// </summary> public static BloonToSimulation GetBloonToSim(this Bloon bloon) { // This method doesn't need to be this long but it doesn't hurt to have extra checks var bloonSim = SessionData.bloonTracker.GetBloonToSim(bloon.GetId()); if (bloonSim is null && bloon.bloonModel is null) // if bloon.bloonModel is null then the bloon hasn't been initialized yet so continuing is pointless { return(null); } var currentPos = bloon.Position?.ToUnity(); if (currentPos is null) { currentPos = new UnityEngine.Vector3(); } if (bloonSim is null) { return(bloon.CreateBloonToSim()); } bloonSim.position = currentPos.Value; // Updating position isn't necessary but it helps with accuracy return(bloonSim); }
internal static bool Prefix(Bloon __instance, Model modelToUse) { SessionData.bloonTracker.TrackBloon(__instance); // Creating new BloonToSimulation will automatically start Tracking BloonSim via the Constructor __instance.CreateBloonToSim(); return(true); }
internal static void Postfix(Bloon __instance) { SessionData.bloonTracker.TrackBloon(__instance); __instance.CreateBloonToSim(); // Creating new BloonToSimulation will automatically start Tracking BloonSim via the Constructor MelonMain.DoPatchMethods(mod => { mod.OnBloonCreated(__instance); }); }