private static HatBehaviour CreateHatBehaviour(CustomHat ch, bool fromDisk = false) { HatBehaviour hat = new HatBehaviour(); hat.MainImage = CreateHatSprite(ch.resource, fromDisk); if (ch.backresource != null) { hat.BackImage = CreateHatSprite(ch.backresource, fromDisk); } if (ch.climbresource != null) { hat.ClimbImage = CreateHatSprite(ch.climbresource, fromDisk); } hat.name = ch.name; hat.Order = 99; hat.ProductId = "hat_" + ch.name.Replace(' ', '_'); hat.InFront = !ch.behind; hat.NoBounce = !ch.bounce; hat.ChipOffset = new Vector2(0f, 0.35f); if (ch.adaptive && hatShader != null) { hat.AltShader = hatShader; } return(hat); }
private static List <CustomHat> createCustomHatDetails(string[] hats, bool fromDisk = false) { Dictionary <string, CustomHat> fronts = new Dictionary <string, CustomHat>(); Dictionary <string, string> backs = new Dictionary <string, string>(); Dictionary <string, string> climbs = new Dictionary <string, string>(); for (int i = 0; i < hats.Length; i++) { string s = fromDisk ? hats[i].Substring(hats[i].LastIndexOf("\\") + 1).Split('.')[0] : hats[i].Split('.')[3]; string[] p = s.Split('_'); HashSet <string> options = new HashSet <string>(); for (int j = 1; j < p.Length; j++) { options.Add(p[j]); } if (options.Contains("climb")) { climbs.Add(p[0], hats[i]); } if (options.Contains("back")) { backs.Add(p[0], hats[i]); } if (!options.Contains("back") && !options.Contains("climb")) { CustomHat custom = new CustomHat { resource = hats[i] }; custom.name = p[0].Replace('-', ' '); custom.bounce = options.Contains("bounce"); custom.adaptive = options.Contains("adaptive"); custom.behind = options.Contains("behind"); fronts.Add(p[0], custom); } } List <CustomHat> customhats = new List <CustomHat>(); foreach (string k in fronts.Keys) { CustomHat hat = fronts[k]; backs.TryGetValue(k, out hat.backresource); climbs.TryGetValue(k, out hat.climbresource); if (hat.backresource != null) { hat.behind = true; } customhats.Add(hat); } return(customhats); }
private static HatBehaviour CreateHatBehaviour(CustomHat ch, bool fromDisk = false, bool testOnly = false) { if (hatShader == null && DestroyableSingleton <HatManager> .InstanceExists) { foreach (HatBehaviour h in DestroyableSingleton <HatManager> .Instance.AllHats) { if (h.AltShader != null) { hatShader = h.AltShader; break; } } } HatBehaviour hat = new HatBehaviour(); hat.MainImage = CreateHatSprite(ch.resource, fromDisk); if (ch.backresource != null) { hat.BackImage = CreateHatSprite(ch.backresource, fromDisk); ch.behind = true; // Required to view backresource } if (ch.climbresource != null) { hat.ClimbImage = CreateHatSprite(ch.climbresource, fromDisk); } hat.name = ch.name; hat.Order = 99; hat.ProductId = "hat_" + ch.name.Replace(' ', '_'); hat.InFront = !ch.behind; hat.NoBounce = !ch.bounce; hat.ChipOffset = new Vector2(0f, 0.2f); if (ch.adaptive && hatShader != null) { hat.AltShader = hatShader; } if (!testOnly) { HatExtension extend = new HatExtension(); extend.author = ch.author != null ? ch.author : "Unknown"; extend.package = ch.package != null ? ch.package : "Misc."; extend.condition = ch.condition != null ? ch.condition : "none"; CustomHatRegistry.Add(hat.name, extend); } return(hat); }
private static HatData CreateHatData(CustomHat ch, bool fromDisk = false, bool testOnly = false) { if (hatShader == null && DestroyableSingleton <HatManager> .InstanceExists) { hatShader = new Material(Shader.Find("Unlit/PlayerShader")); } HatData hat = new HatData(); hat.hatViewData.viewData = new HatViewData(); hat.hatViewData.viewData.MainImage = CreateHatSprite(ch.resource, fromDisk); if (ch.backresource != null) { hat.hatViewData.viewData.BackImage = CreateHatSprite(ch.backresource, fromDisk); ch.behind = true; // Required to view backresource } if (ch.climbresource != null) { hat.hatViewData.viewData.ClimbImage = CreateHatSprite(ch.climbresource, fromDisk); } hat.name = ch.name + "\nby " + ch.author; hat.displayOrder = 99; hat.ProductId = "hat_" + ch.name.Replace(' ', '_'); hat.InFront = !ch.behind; hat.NoBounce = !ch.bounce; hat.ChipOffset = new Vector2(0f, 0.2f); hat.Free = true; hat.NotInStore = true; if (ch.adaptive && hatShader != null) { hat.hatViewData.viewData.AltShader = hatShader; } HatExtension extend = new HatExtension(); extend.author = ch.author != null ? ch.author : "Unknown"; extend.package = ch.package != null ? ch.package : "Misc."; extend.condition = ch.condition != null ? ch.condition : "none"; if (ch.flipresource != null) { extend.FlipImage = CreateHatSprite(ch.flipresource, fromDisk); } if (ch.backflipresource != null) { extend.BackFlipImage = CreateHatSprite(ch.backflipresource, fromDisk); } if (testOnly) { TestExt = extend; TestExt.condition = hat.name; } else { CustomHatRegistry.Add(hat.name, extend); } return(hat); }