protected static InteractionTuning Inject(Type oldType, Type oldTarget, Type newType, Type newTarget, bool clone) { InteractionTuning tuning = null; try { tuning = AutonomyTuning.GetTuning(newType.FullName, newTarget.FullName); if (tuning == null) { tuning = AutonomyTuning.GetTuning(oldType, oldType.FullName, oldTarget); if (tuning == null) { return(null); } Common.InjectionLogger.Append(newType.FullName + " " + newTarget.FullName); if (clone) { tuning = CloneTuning(tuning); } AutonomyTuning.AddTuning(newType.FullName, newTarget.FullName, tuning); } InteractionObjectPair.sTuningCache.Remove(new Pair <Type, Type>(newType, newTarget)); } catch (Exception e) { Common.Exception("OldType: " + oldType.ToString() + Common.NewLine + "Target: " + oldTarget.ToString() + Common.NewLine + "NewType: " + newType.ToString() + Common.NewLine + "NewTarget: " + newTarget.ToString(), e); } return(tuning); }
protected static InteractionTuning Inject(Type oldType, Type oldTarget, Type newType, Type newTarget, bool clone) { InteractionTuning tuning = null; try { tuning = AutonomyTuning.GetTuning(newType.FullName, newTarget.FullName); if (tuning == null) { tuning = AutonomyTuning.GetTuning(oldType, oldType.FullName, oldTarget); if (tuning == null) { return(null); } if (clone) { tuning = CloneTuning(tuning); } AutonomyTuning.AddTuning(newType.FullName, newTarget.FullName, tuning); } InteractionObjectPair.sTuningCache.Remove(new Pair <Type, Type>(newType, newTarget)); } catch {} return(tuning); }
public static void InjectTuning <Target, OldType, NewType>() where Target : GameObject where OldType : InteractionDefinition where NewType : InteractionDefinition { InteractionTuning interactionTuning = AutonomyTuning.GetTuning(typeof(OldType), typeof(OldType).FullName, typeof(Target)); if (interactionTuning != null) { AutonomyTuning.AddTuning(typeof(NewType).FullName, typeof(Target).FullName, interactionTuning); } }
public static void OnWorldLoadFinishedHandler(object sender, System.EventArgs e) { // Add custom fishing interaction that uses custom fishing skill if (Terrain.Singleton != null) { Terrain.Singleton.RemoveInteractionByType(Terrain.CatFishHere.Singleton); Terrain.Singleton.AddInteraction(EWCatFishHere.Singleton); Terrain.Singleton.AddInteraction(EWCatInspectWater.Singleton); Terrain.Singleton.AddInteraction(EWCatPlayInWater.Singleton); Terrain.Singleton.AddInteraction(EWCatFishAWhile.Singleton); } try { // If there's no existing tuning for EWCatEatFish, copy over the Hunger output from PetEatPrey InteractionTuning eatTuning = AutonomyTuning.GetTuning(EWCatEatFish.Singleton.GetType().FullName, "Sims3.Gameplay.Interfaces.ICatPrey"); if (eatTuning == null) { InteractionTuning oldTuning = AutonomyTuning.GetTuning(PetEatPrey.Singleton.GetType().FullName, "Sims3.Gameplay.Interfaces.ICatPrey"); AutonomyTuning.AddTuning(EWCatEatFish.Singleton.GetType().FullName, "Sims3.Gameplay.Interfaces.ICatPrey", oldTuning); } } catch (Exception ex) { StyledNotification.Show(new StyledNotification.Format("ERROR loading EWCatEatFish tuning: " + ex.Message, StyledNotification.NotificationStyle.kDebugAlert)); } MinorPet[] objects = Queries.GetObjects <MinorPet>(); foreach (MinorPet val in objects) { if (val.CatHuntingComponent != null) { val.AddInventoryInteraction(EWCatDropHere.Singleton); } } Fish[] fish = Queries.GetObjects <Fish>(); foreach (Fish f in fish) { if (f.CatHuntingComponent != null) { // Separate out eating fish from land prey. f.AddInventoryInteraction(EWCatDropHere.Singleton); f.RemoveInteractionByType(PetEatPrey.Singleton); f.AddInteraction(EWCatEatFish.Singleton); } } EventTracker.AddListener(EventTypeId.kInventoryObjectAdded, new ProcessEventDelegate(OnObjectChanged)); EventTracker.AddListener(EventTypeId.kObjectStateChanged, new ProcessEventDelegate(OnObjectChanged)); }
private static void OnPreLoad() { if (!PreLoaded) { PreLoaded = true; InjectTuning <Fridge, Fridge_Have.Definition, OverridedFridge_Have.Definition>(); InjectTuning <Fridge, Fridge_Prepare.PrepareDefinition, OverridedFridge_Prepare.PrepareDefinition>(); InjectTuning <Stove, Stove_Have.Definition, OverridedStove_Have.Definition>(); InjectTuning <Microwave, Microwave_Have.Definition, OverridedMicrowave_Have.Definition>(); InjectTuning <Grill, Grill_Have.Definition, OverridedGrill_Have.Definition>(); InjectTuning <FoodProcessor, FoodProcessor.FoodProcessor_Have.Definition, OverridedFoodProcessor_Have.Definition>(); if (GameUtils.IsInstalled(ProductVersion.EP5)) { InteractionTuning tuning = AutonomyTuning.GetTuning(typeof(MakeGourmetFoodForPet.Definition), "Sims3.Gameplay.Objects.Appliances.MakeGourmetFoodForPet+Definition", typeof(Fridge)); if (tuning != null) { tuning.LoadFieldDisallowAutonomous(true); } } if (Recipe.NameToRecipeHash.ContainsKey("WOBakeBreadCountry")) { ApplianceTypes.Add(typeof(WoodFireOven)); InjectTuning <WoodFireOven, WoodFireOven.WOBake.Definition, OverridedWOBakeDefinition>(); } if (Recipe.NameToRecipeHash.ContainsKey("TGCookTeppanyakiSalmon")) { ApplianceTypes.Add(typeof(TeppanyakiGrill)); InjectTuning <TeppanyakiGrill, TeppanyakiGrill.TGCook.Definition, OverridedTGCookDefinition>(); } char[] separator = new char[] { ':' }; foreach (string current in SnackRequirements) { string[] array = current.Split(separator, 2); string key = array [0].Trim(); Recipe recipe; if (Recipe.NameToRecipeHash.TryGetValue(key, out recipe) && recipe.Ingredient1 == null) { recipe.mNonPersistableData.mIngredient1 = recipe.InitIngredient(array[1].Trim()); } } } }
static JapLowDinnerTable() { CommodityChange item = new CommodityChange((CommodityKind)286210343, 100f, true, 100f, OutputUpdateType.ImmediateDelta, false, false, UpdateAboveAndBelowZeroType.Either); try { InteractionTuning tuning = AutonomyTuning.GetTuning(typeof(JapLowDinnerTable.Eat.Definition).FullName, typeof(JapLowDinnerTable).FullName); tuning.mTradeoff.mOutputs.Add(item); tuning = AutonomyTuning.GetTuning(typeof(JapLowDinnerTable.ServeMeal.Definition).FullName, typeof(ServingContainerGroup).FullName); tuning.mTradeoff.mOutputs.Add(item); } catch (Exception ex) { JapLowDinnerTable.DebugMsg("InteractionTuning(s) not updated\n\n" + ex.StackTrace.Substring(0, JapLowDinnerTable.UMIN(750, ex.StackTrace.Length))); } JapLowDinnerTable.mSurfaceAddOn = new SurfaceAddOn(); JapLowDinnerTable.mSurfaceAddOn.AddSurface("ContainmentSlot_0", 1f, SurfaceType.Eating, SurfaceHeight.CoffeeTable, CarrySystemPutDownRule.Default, null); World.OnWorldLoadFinishedEventHandler += JapLowDinnerTable.OnWorldLoadFinished; }
public static InteractionTuning GetTuning(Type interactionType, string tuningFile, Type targetType, Common.StringBuilder msg) { msg += Common.NewLine + "GetTuning"; string str; Label_0000: str = targetType.FullName; msg += Common.NewLine + "FullName: " + str; InteractionTuning tuning = GetTuning(tuningFile, str, msg); if (tuning != null) { msg += Common.NewLine + "A"; return(tuning); } if (targetType != typeof(GameObject)) { targetType = targetType.BaseType; if (targetType != null) { goto Label_0000; } } if ((interactionType != null) && Reflection.IsTypeAssignableFrom(typeof(InteractionDefinition), interactionType)) { msg += Common.NewLine + "InteractionType: " + interactionType; while (interactionType.BaseType != typeof(object)) { if (interactionType.BaseType == null) { break; } msg += Common.NewLine + "BaseType: " + interactionType.BaseType; if (interactionType.BaseType.IsGenericType) { Type baseType = interactionType.BaseType; Type[] genericArguments = baseType.GetGenericArguments(); while ((genericArguments.Length != 0x3) && (baseType.BaseType != null)) { genericArguments = baseType.BaseType.GetGenericArguments(); } if ((genericArguments.Length == 0x3) && genericArguments[0x1].IsInterface) { msg += Common.NewLine + "TuningFule: " + tuningFile; msg += Common.NewLine + "FullName: " + genericArguments[0x1].FullName; InteractionTuning tuning2 = AutonomyTuning.GetTuning(tuningFile, genericArguments[0x1].FullName); if (tuning2 != null) { msg += Common.NewLine + "B"; return(tuning2); } } } interactionType = interactionType.BaseType; } } msg += Common.NewLine + "C"; return(null); }
public static InteractionTuning GetTuning(Type oldType, Type target) { return(AutonomyTuning.GetTuning(oldType.FullName, target.FullName)); }