Esempio n. 1
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. 2
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;
                }
            }