Exemple #1
0
            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);
            }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
            }
        }
Exemple #4
0
        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));
        }