Advertisement
ChosenSquirrel

Base setup

Apr 9th, 2024
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.91 KB | Gaming | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Sims3.Gameplay;
  5. using Sims3.Gameplay.Actors;
  6. using Sims3.Gameplay.Autonomy;
  7. using Sims3.Gameplay.EventSystem;
  8. using Sims3.Gameplay.Interactions;
  9. using Sims3.Gameplay.Pools;
  10. using Sims3.Gameplay.Utilities;
  11. using Sims3.Gameplay.CAS;
  12. using Sims3.SimIFace;
  13. using Sims3.UI;
  14. using Sims3.Gameplay.Interfaces;
  15. using Sims3.Gameplay.Abstracts;
  16. using Sims3.Gameplay.ActorSystems;
  17. using Sims3.Gameplay.ChildAndTeenUpdates;
  18. using Sims3.Gameplay.Core;
  19. using Sims3.Gameplay.Objects;
  20. using Sims3.Gameplay.Objects.CookingObjects;
  21. using Sims3.Gameplay.Socializing;
  22. using Sims3.SimIFace.Enums;
  23.  
  24. namespace CS_Religion
  25. {
  26.     /// <summary>
  27.     /// Description of MyClass.
  28.     /// </summary>
  29.     public class ChistianInteractions
  30.     {
  31.         public const ulong CHRISTIAN_TRAIT = 15820275475115006459uL;
  32.  
  33.         private const int CH_CK = 286210339;
  34.         private const int CH_TRAIT_TIP = 9730;
  35.         public const TraitNames CH_TRAIT_GUID = (TraitNames)15820275475115006459uL;
  36.         public const CommodityKind CH_COMMODITYKIND = (CommodityKind)286210339;
  37.         [Tunable]
  38.         protected static bool kInstantiator = false;
  39.         private static EventListener sSimInstantiatedListener = null;
  40.         private static EventListener sSimAgedUpListener = null;
  41.  
  42.         static ChistianInteractions()
  43.         {
  44.             World.OnWorldLoadFinishedEventHandler += new EventHandler(OnWorldLoadFinishedHandler);
  45.         }
  46.         public static void OnWorldLoadFinishedHandler(object sender, System.EventArgs e)
  47.         {
  48.             try
  49.             {
  50.                 foreach (Sim sim in Sims3.Gameplay.Queries.GetObjects<Sim>())
  51.                 {
  52.                     if (sim != null)
  53.                     {
  54.                         AddInteractions(sim);
  55.                     }
  56.  
  57.                 }
  58.             }
  59.             catch (Exception exception)
  60.             {
  61.                 Exception(exception);
  62.             }
  63.             sSimInstantiatedListener = EventTracker.AddListener(EventTypeId.kSimInstantiated, new ProcessEventDelegate(OnSimInstantiated));
  64.             sSimAgedUpListener = EventTracker.AddListener(EventTypeId.kSimAgeTransition, new ProcessEventDelegate(OnSimInstantiated));
  65.         }
  66.  
  67.         protected static ListenerAction OnSimInstantiated(Event e)
  68.         {
  69.             try
  70.             {
  71.                 Sim sim = e.TargetObject as Sim;
  72.                 if (sim != null)
  73.                 {
  74.                     AddInteractions(sim);
  75.                 }
  76.             }
  77.             catch (Exception exception)
  78.             {
  79.                 Exception(exception);
  80.             }
  81.             return ListenerAction.Keep;
  82.         }
  83.  
  84.         public static void AddInteractions(Sim sim)
  85.         {
  86.             if (sim.SimDescription.TeenOrAbove)
  87.             {
  88.                 foreach (InteractionObjectPair pair in sim.Interactions)
  89.                 {
  90.                     if (pair.InteractionDefinition.GetType() == Pray.Singleton.GetType())
  91.                     {
  92.                         return;
  93.                     }
  94.                 }
  95.                 sim.AddInteraction(Pray.Singleton);
  96.             }
  97.         }
  98.         public static bool Exception(Exception exception)
  99.         {
  100.             try
  101.             {
  102.                 return ((IScriptErrorWindow)AppDomain.CurrentDomain.GetData("ScriptErrorWindow")).DisplayScriptError(null, exception);
  103.             }
  104.             catch
  105.             {
  106.                 WriteLog(exception);
  107.                 return true;
  108.             }
  109.         }
  110.         public static bool WriteLog(Exception exception)
  111.         {
  112.             try
  113.             {
  114.                 new ScriptError(null, exception, 0).WriteMiniScriptError();
  115.                 return true;
  116.             }
  117.             catch
  118.             {
  119.                 return false;
  120.             }
  121.         }
  122.  
  123.         private sealed class Pray : Interaction<Sim, Sim>
  124.         {
  125.             public static readonly InteractionDefinition Singleton = new Definition();
  126.             protected override bool Run()
  127.             {
  128.                 StandardEntry();
  129.                 EnterStateMachine("PlayerPray", "Enter", "x");
  130.                 EnterState("x", "Enter");
  131.                 AnimateSim("Exit");
  132.                 StandardExit();
  133.                 return true;
  134.             }
  135.             [DoesntRequireTuning]
  136.             private sealed class Definition : InteractionDefinition<Sim, Sim, Pray>, IOverridesVisualType, IHasCustomThumbnailIcon
  137.             {
  138.                 protected override string GetInteractionName(Sim a, Sim target, InteractionObjectPair interaction)
  139.                 {
  140.                     return "Pray";
  141.                 }
  142.                 public override string[] GetPath(bool bPath)
  143.  
  144.                 {
  145.  
  146.                     return new string[1] { "Christian..." };
  147.  
  148.                 }
  149.                 public InteractionVisualTypes GetVisualType
  150.                 {
  151.                     get
  152.                     {
  153.                         return InteractionVisualTypes.CustomThumbnail;
  154.                     }
  155.                 }
  156.                 public ThumbnailKey GetCustomThumbnailIcon(Sim actor, IGameObject target)
  157.                 {
  158.                     return new ThumbnailKey(ResourceKey.CreatePNGKey("CS_Christian_pie", ResourceUtils.ProductVersionToGroupId(ProductVersion.BaseGame)), ThumbnailSize.Large);
  159.  
  160.                 }
  161.                 protected override bool Test(Sim a, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
  162.                 {
  163.                     if (a.IsSleeping || a.Posture is SwimmingInPool)
  164.                     {
  165.                         return false;
  166.  
  167.                     }
  168.                     if (a == target)
  169.                     {
  170.                         return true;
  171.                     }
  172.                     return false;
  173.                 }
  174.  
  175.             }
  176.         }
  177.  
  178.     }
  179.  
  180. }
Tags: modding Sims 3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement