Esempio n. 1
0
            public static bool Prefix(HatManager __instance)
            {
                try {
                    if (!modded)
                    {
                        HatMod.Logger.LogMessage("Adding filesystem hats");
                        modded = true;
                        var hatsFromFilesystem = CreateFilesystemHats();
                        foreach (var hat in hatsFromFilesystem)
                        {
                            __instance.AllHats.Add(hat);
                        }

                        //
                        __instance.AllHats.Sort((Il2CppSystem.Comparison <HatBehaviour>)((h1, h2) => h2.ProductId.CompareTo(h1.ProductId)));
                    }
                    return(true);
                }
                catch (Exception e) {
                    HatMod.Logger.LogError("During Prefix, an exception occured");
                    HatMod.Logger.LogError("------------------------------------------------");
                    HatMod.Logger.LogError(e);
                    HatMod.Logger.LogError("------------------------------------------------");
                    throw e;
                }
            }
Esempio n. 2
0
 static bool Prefix(HatManager __instance)
 {
     try
     {
         if (!modded)
         {
             System.Console.WriteLine("Adding hats");
             modded = true;
             var id = 0;
             foreach (var hatData in _hatDatas)
             {
                 var hat = CreateHat(hatData, id++);
                 __instance.AllHats.Add(hat);
                 if (hatData.highUp)
                 {
                     TallIds.Add((uint)(__instance.AllHats.Count - 1));
                 }
                 IdToData.Add((uint)__instance.AllHats.Count - 1, hatData);
             }
         }
         return(true);
     }
     catch (Exception e)
     {
         System.Console.WriteLine("During Prefix, an exception occured");
         System.Console.WriteLine("------------------------------------------------");
         System.Console.WriteLine(e);
         System.Console.WriteLine("------------------------------------------------");
         throw;
     }
 }
Esempio n. 3
0
            static bool Prefix(HatManager __instance)
            {
                try {
                    if (!LOADED)
                    {
                        loadHatShader();

                        Assembly assembly = Assembly.GetExecutingAssembly();
                        string   hatres   = $"{assembly.GetName().Name}.Resources.CustomHats";
                        string[] hats     = (from r in assembly.GetManifestResourceNames()
                                             where r.StartsWith(hatres) && r.EndsWith(".png")
                                             select r).ToArray <string>();

                        List <CustomHat> customhats = createCustomHatDetails(hats);
                        foreach (CustomHat ch in customhats)
                        {
                            __instance.AllHats.Add(CreateHatBehaviour(ch));
                        }

                        LOADED = true;
                    }
                    return(true);
                } catch (Exception e) {
                    System.Console.WriteLine("Unable to add Custom Hats\n" + e);
                    return(false);
                }
            }
Esempio n. 4
0
 static bool Prefix(HatManager __instance)
 {
     try
     {
         if (!modded)
         {
             System.Console.WriteLine("Adding hats");
             modded = true;
             var hatsFromFilesystem = CreateAllHats();
             foreach (var hat in hatsFromFilesystem)
             {
                 __instance.AllHats.Add(hat);
             }
         }
         return(true);
     }
     catch (Exception e)
     {
         System.Console.WriteLine("During Prefix, an exception occured");
         System.Console.WriteLine("------------------------------------------------");
         System.Console.WriteLine(e);
         System.Console.WriteLine("------------------------------------------------");
         throw;
     }
 }
Esempio n. 5
0
    void OnLevelFinishedLoading(Scene scene, LoadSceneMode mode)
    {
        Debug.Log("Train Level Loaded");

        //Give the players their hats
        HatManager.OutfitBothplayers();
    }
Esempio n. 6
0
    // Use this for initialization
    void Start()
    {
        secondsLeft        = GameManager.instance.activeLevel.levelTime;
        desiredIngredients = GameManager.instance.activeLevel.desiredIngredients;
        UIController.Instance.UpdateMissionWithDesiredIngredients();
        GameManager.instance.shouldPlayCustomerReactionInHub = false;

        HatManager.OutfitBothplayers();

        //reset level save data
        GameManager.instance.globalSaveData.currentLevelSaveData = new LevelSaveData();
        if (SaveManager.GetLevelData(GameManager.instance.activeLevel) != null)
        {
            SaveManager.UpdateCurrentLevelDataWithPrevious();
        }

        if (debugMode)
        {
            CutsceneManager.instance.ExitIntroCutscene();
            CutsceneManager.instance.HideLevelText();
        }

        if (GameManager.instance.activeLevel.coalMachineEnabled)
        {
            coalMachine.SetActive(true);
        }
    }
Esempio n. 7
0
 void Start()
 {
     if (m_instance)
     {
         Destroy(this.gameObject);
     }
     else
     {
         m_instance = this;
     }
 }
Esempio n. 8
0
        public static bool Prefix(HatManager __instance, ref Il2CppReferenceArray <HatBehaviour> __result)
        {
            var array = (
                from h in __instance.AllHats.ToArray()
                where !HatManager.IsMapStuff(h.ProdId) || SaveManager.GetPurchase(h.ProductId)
                select h
                into o
                orderby o.Order descending, o.name
                select o).ToArray();

            __result = array;
            return(false);
        }
Esempio n. 9
0
 public override void OnAwake()
 {
     Instance = this;
     foreach (var hat in Hats)
     {
         hat.material = new Material(Material.StandardMaterial);
         hat.material.SetColor("color", Color.White);
         hat.material.SetTexture2D("DiffuseTexture", hat.texture);
         if (hat.specular != null)
         {
             hat.material.SetTexture2D("SpecularTexture", hat.specular);
         }
     }
 }
Esempio n. 10
0
            static void Prefix(HatManager __instance)
            {
                if (RUNNING)
                {
                    return;
                }
                RUNNING = true; // prevent simultaneous execution

                try {
                    if (!LOADED)
                    {
                        Assembly assembly = Assembly.GetExecutingAssembly();
                        string   hatres   = $"{assembly.GetName().Name}.Resources.CustomHats";
                        string[] hats     = (from r in assembly.GetManifestResourceNames()
                                             where r.StartsWith(hatres) && r.EndsWith(".png")
                                             select r).ToArray <string>();

                        List <CustomHat> customhats = createCustomHatDetails(hats);
                        foreach (CustomHat ch in customhats)
                        {
                            __instance.allHats.Add(CreateHatData(ch));
                        }
                    }
                    while (CustomHatLoader.hatDetails.Count > 0)
                    {
                        __instance.allHats.Add(CreateHatData(CustomHatLoader.hatDetails[0]));
                        Logger.info(String.Format("Add CustomHat Author:{0,-20}Name:{1}", CustomHatLoader.hatDetails[0].author, CustomHatLoader.hatDetails[0].name), "CustomHats");
                        CustomHatLoader.hatDetails.RemoveAt(0);
                    }
                } catch (System.Exception e) {
                    if (!LOADED)
                    {
                        Logger.error("Unable to add Custom Hats\n" + e, "CustomHats");
                    }
                }
                LOADED = true;
            }
Esempio n. 11
0
 private void TaskOnClick()
 {
     HatManager.UpdateCurrentHat(hat);
     HatManager.UpdateGlobalDataWithNewHat(hat);
 }
Esempio n. 12
0
            public static void Prefix(HatManager __instance)
            {
                var CHLog = new ManualLogSource("HatPack");

                BepInEx.Logging.Logger.Sources.Add(CHLog);
                if (!_customHatsLoaded)
                {
                    var allHats = DestroyableSingleton <HatManager> .Instance.allHats;
                    CHLog.LogInfo("Adding hats from hatpack");
                    foreach (var data in authorDatas)
                    {
                        HatID++;
                        try
                        {
                            if (data.FloorHatName != null && data.ClimbHatName != null && data.LeftImageName != null)
                            {
                                CHLog.LogInfo("Adding " + data.HatName + " and associated floor/climb hats/left image");
                                if (data.NoBounce)
                                {
                                    if (data.altShader == true)
                                    {
                                        CHLog.LogInfo("Adding " + data.HatName + " with Alt shaders and bounce");
                                        __instance.allHats.Add(CreateHat(GetSprite(data.HatName), data.AuthorName, GetSprite(data.ClimbHatName), GetSprite(data.FloorHatName), leftimage: null, back: null, true, true));
                                    }
                                    else
                                    {
                                        CHLog.LogInfo("Adding " + data.HatName + " with bounce enabled");
                                        allHats.Add(CreateHat(GetSprite(data.HatName), data.AuthorName, climb: GetSprite(data.ClimbHatName), floor: GetSprite(data.FloorHatName), leftimage: GetSprite(data.LeftImageName), back: null, true, false));
                                    }
                                }
                                else
                                {
                                    CHLog.LogInfo("Adding " + data.HatName + " with bounce disabled");
                                    allHats.Add(CreateHat(GetSprite(data.HatName), data.AuthorName, climb: GetSprite(data.ClimbHatName), floor: GetSprite(data.FloorHatName), leftimage: GetSprite(data.LeftImageName)));
                                }
                            }
                            else if (data.HatName != null && data.LeftImageName != null && data.ClimbHatName == null && data.FloorHatName == null)
                            {
                                if (data.NoBounce)
                                {
                                    CHLog.LogInfo("Adding " + data.HatName + " with bounce enabled and left image");
                                    allHats.Add(CreateHat(GetSprite(data.HatName), data.AuthorName, climb: null, floor: null, GetSprite(data.LeftImageName), back: null, true));
                                }
                                else
                                {
                                    //Add hat without bounce and leftimage
                                    CHLog.LogInfo("Adding " + data.HatName + " without bounce and left image");
                                    allHats.Add(CreateHat(GetSprite(data.HatName), data.AuthorName, climb: null, floor: null, GetSprite(data.LeftImageName)));
                                }
                            }
                            else if (data.HatName != null && data.BackImageName != null && data.LeftImageName == null && data.ClimbHatName == null && data.FloorHatName == null)
                            {
                                if (data.NoBounce)
                                {
                                    CHLog.LogInfo("Adding " + data.HatName + " with bounce enabled and back image");
                                    allHats.Add(CreateHat(GetSprite(data.HatName), data.AuthorName, climb: null, floor: null, leftimage: null, back: GetSprite(data.BackImageName), true));
                                }
                                else
                                {
                                    //Add hat without bounce and back image
                                    CHLog.LogInfo("Adding " + data.HatName + " without bounce and back image");
                                    allHats.Add(CreateHat(GetSprite(data.HatName), data.AuthorName, climb: null, floor: null, leftimage: null, GetSprite(data.BackImageName)));
                                }
                            }
                            else
                            {
                                if (data.altShader == true)
                                {
                                    CHLog.LogInfo("Adding " + data.HatName + " with Alt shaders");
                                    allHats.Add(CreateHat(GetSprite(data.HatName), data.AuthorName, climb: null, floor: null, leftimage: null, back: null, data.NoBounce, data.altShader));
                                }
                                else
                                {
                                    CHLog.LogInfo("Adding " + data.HatName);
                                    allHats.Add(CreateHat(GetSprite(data.HatName), data.AuthorName));
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            CHLog.LogInfo("An exception occured " + ex.InnerException.Message);
                        }
                        IdToData.Add(HatManager.Instance.allHats.Count - 1, data);

                        _customHatsLoaded = true;
                    }



                    _customHatsLoaded = true;
                }
            }
Esempio n. 13
0
 static void Postfix(HatManager __instance)
 {
     RUNNING = false;
 }
Esempio n. 14
0
 public override void OnDestroy()
 {
     Instance = null;
 }