private void _loadDoor(Asset asset) { GameObject go = AssetPackUtilities.LoadAsset <GameObject>(_bundle, asset.Guid); if (go == null) { throw new Exception("Can't find Object:" + asset.Guid); } WallBuilder <Door> doorBuilder = Parkitility.CreateWall <Door>(go) .Id(asset.Guid) .BuildLayerMask(LayerMasks.TERRAIN) .Price(asset.Price, false) .DisplayName(asset.Name) .CustomColor(AssetPackUtilities.ConvertColors(asset.CustomColors, asset.ColorCount)) .BlockRain(asset.BlocksRain) .HeightChangeDelta(asset.HeightDelta) .SnapGridToCenter(true) .OnGrid(true) .GridSubdivisions(1f) .Category(asset.Category, asset.SubCategory) .SeeThrough(asset.SeeThrough); if (asset.IsResizable) { doorBuilder.Resizable(asset.MinSize, asset.MaxSize); } doorBuilder.Build(_assetManagerLoader); }
private void _loadPath(Asset asset) { PathStyleBuilder builder = new PathStyleBuilder(); switch (asset.PathMaterialType) { case Asset.PathMaterial.Sheet: { Texture2D sheet = AssetPackUtilities.LoadAsset <Texture2D>(_bundle, asset.Guid + ".path_sheet"); Texture2D mask = AssetPackUtilities.LoadAsset <Texture2D>(_bundle, asset.Guid + ".path_mask"); Texture2D normal = AssetPackUtilities.LoadAsset <Texture2D>(_bundle, asset.Guid + ".path_normal"); CustomColorsMaskedNormalBuilder materialBuilder = ShaderUtility.PathMaterial(); if (sheet != null) { materialBuilder.MainTex(sheet); } materialBuilder.MainTex(sheet == null ? ShaderUtility.EmptyTexture : sheet); materialBuilder.MaskTex(mask == null ? ShaderUtility.EmptyTexture : mask); materialBuilder.NormalTex(normal == null ? ShaderUtility.EmptyTexture : normal); builder.Material(materialBuilder.build()) .Id(asset.Guid) .Name(asset.Name) .CustomColor(AssetPackUtilities.ConvertColors(asset.CustomColors, asset.ColorCount)) .Register(asset.PathType, _assetManagerLoader, PathStyleBuilder.GetPathStyle(PathStyleBuilder.NormalPathIds.Gravel, PathStyleBuilder.PathType.Normal)); } break; case Asset.PathMaterial.Tiled: { Texture2D sheet = AssetPackUtilities.LoadAsset <Texture2D>(_bundle, asset.Guid + ".path_sheet"); Texture2D mask = AssetPackUtilities.LoadAsset <Texture2D>(_bundle, asset.Guid + ".path_mask"); Texture2D normal = AssetPackUtilities.LoadAsset <Texture2D>(_bundle, asset.Guid + ".path_normal"); CustomColorMaskedCutoutBuilder materialBuilder = ShaderUtility.PathMaterialTiled(); if (sheet != null) { materialBuilder.MainTex(sheet); } materialBuilder.MaskTex(mask == null ? ShaderUtility.EmptyTexture : mask); materialBuilder.MainTex(sheet == null ? ShaderUtility.EmptyTexture : sheet); materialBuilder.NormalTex(normal == null ? ShaderUtility.EmptyTexture : normal); builder.Material(materialBuilder.build()) .Id(asset.Guid) .CustomColor(AssetPackUtilities.ConvertColors(asset.CustomColors, asset.ColorCount)) .Name(asset.Name) .Register(asset.PathType, _assetManagerLoader, PathStyleBuilder.GetPathStyle(PathStyleBuilder.NormalPathIds.Concrete, PathStyleBuilder.PathType.Normal)); } break; } }
public void OnEnabled() { _bundle = AssetBundle.LoadFromFile(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(this.Path), "assetPack")); if (_bundle == null) { throw new Exception("Failed to load AssetBundle!"); } var pack = AssetPackUtilities.LoadAsset(File.ReadAllText(Path)); IsLoaded = true; foreach (var asset in pack.Assets) { if (!asset.LoadAsset) { continue; } try { Debug.Log("Loading Item " + asset.Name + " by type " + asset.TargetType); switch (asset.TargetType) { case AssetType.Shop: _loadShop(asset); break; case AssetType.Door: _loadDoor(asset); break; case AssetType.Path: _loadPath(asset); break; } } catch (Exception ex) { Debug.LogError(ex); } } _bundle.Unload(false); }
public override void onEnabled() { if (GameController.Instance != null && GameController.Instance.isCampaignScenario) { return; } _assetBundle = AssetBundle.LoadFromFile(System.IO.Path.Combine(Parkitility.CurrentModDirectory(), "assetpack")); if (_assetBundle == null) { throw new Exception("Failed to load AssetBundle!"); } var entertainers = AssetManager.Instance.getPrefab <Entertainer>(Prefabs.Entertainer); EmployeeCostume raptorCostume = entertainers.costumes.First(k => k.name == "EntertainerCostumeRaptor"); var bodyPartsContainer = raptorCostume.bodyPartsMale; _entertainerMaterial = bodyPartsContainer.getTorso(0).GetComponentInChildren <Renderer>().sharedMaterial; SpriteRenderer pandaSprite = AssetPackUtilities .LoadAsset <GameObject>(_assetBundle, "c08cc832b55af5f638a6f8c64f6258fb") .GetComponent <SpriteRenderer>(); Parkitility.CostumeBuilder() .Id("EntertainerPanda-cc65c162") .DisplayName("Panda") .GuestThoughtAboutCostume("What a cute Panda!") .CostumeSprite("panda", Object.Instantiate(pandaSprite.sprite), 50, 50) .BodyPartMale( Parkitility.CreateBodyPart() .AddTorso(_remap(bodyPartsContainer.getTorso(0), AssetPackUtilities.LoadAsset <GameObject>(_assetBundle, "38c9bccac03f19b6caa53a4c4f656334"))) .AddHairstyle(_remapHead(AssetPackUtilities.LoadAsset <GameObject>(_assetBundle, "595f9e3b779740751893aa986ff5ad87"))) .Build(_assetManagerLoader)) .MeshAnimations(raptorCostume.meshAnimations) .AnimatorController(raptorCostume.animatorController) .Register(_assetManagerLoader, entertainers); SpriteRenderer tigerSprite = AssetPackUtilities .LoadAsset <GameObject>(_assetBundle, "8d3a87427a6819f9e9c457c3feef4a56") .GetComponent <SpriteRenderer>(); Parkitility.CostumeBuilder() .Id("EntertainerTiger-cc65c162") .DisplayName("Tiger") .GuestThoughtAboutCostume("What a fluffy Tiger!") .CostumeSprite("tiger", Object.Instantiate(tigerSprite.sprite), 50, 50) .BodyPartMale( Parkitility.CreateBodyPart() .AddTorso(_remap(bodyPartsContainer.getTorso(0), AssetPackUtilities.LoadAsset <GameObject>(_assetBundle, "21d83d7233511714f875e57875992cee"))) .AddHairstyle(_remapHead(AssetPackUtilities.LoadAsset <GameObject>(_assetBundle, "20bc030acb52b1cb09ada2ed8131cef0"))) .Build(_assetManagerLoader)) .MeshAnimations(raptorCostume.meshAnimations) .AnimatorController(raptorCostume.animatorController) .Register(_assetManagerLoader, entertainers); SpriteRenderer kiwiSprite = AssetPackUtilities .LoadAsset <GameObject>(_assetBundle, "75709b8ccf2c15f3d8ab256f59007800") .GetComponent <SpriteRenderer>(); Parkitility.CostumeBuilder() .Id("EntertainerKiwi-cc65c162") .DisplayName("Kiwi") .GuestThoughtAboutCostume("What a strange Bird!") .CostumeSprite("kiwi", Object.Instantiate(kiwiSprite.sprite), 50, 50) .BodyPartMale( Parkitility.CreateBodyPart() .AddTorso(_remap(bodyPartsContainer.getTorso(0), AssetPackUtilities.LoadAsset <GameObject>(_assetBundle, "929ba34d2f0bbd52c99ae3d6097ef25c"))) .AddHairstyle(_remapHead(AssetPackUtilities.LoadAsset <GameObject>(_assetBundle, "d6c340003b853f1b29c1012dd6d2baae"))) .Build(_assetManagerLoader)) .MeshAnimations(raptorCostume.meshAnimations) .AnimatorController(raptorCostume.animatorController) .Register(_assetManagerLoader, entertainers); SpriteRenderer sodaCanSprite = AssetPackUtilities .LoadAsset <GameObject>(_assetBundle, "aa9f7adbf9716911691e4fef5506081f") .GetComponent <SpriteRenderer>(); Parkitility.CostumeBuilder() .Id("EntertainerSoda-cc65c162") .DisplayName("Soda Can") .CustomColor(new Color(0.92156862f, 0.250980f, 0.1843f)) .GuestThoughtAboutCostume("Hmmm, Soda!") .CostumeSprite("soda", Object.Instantiate(sodaCanSprite.sprite), 50, 50) .BodyPartMale( Parkitility.CreateBodyPart() .AddTorso(_remap(bodyPartsContainer.getTorso(0), AssetPackUtilities.LoadAsset <GameObject>(_assetBundle, "0bb60bc4c6af4b0ee9717f2e2ae012ae"))) .Build(_assetManagerLoader)) .MeshAnimations(raptorCostume.meshAnimations) .AnimatorController(raptorCostume.animatorController) .Register(_assetManagerLoader, entertainers); _assetBundle.Unload(false); }
private void _loadShop(Asset asset) { GameObject go = AssetPackUtilities.LoadAsset <GameObject>(_bundle, asset.Guid); if (go == null) { throw new Exception("Can't find Object:" + asset.Guid); } var builder = Parkitility.CreateProductShop <ProductShop>(go) .DisplayName(asset.Name) .Id(asset.Guid) .Price(asset.Price) .WalkableFlag(Asset.ConvertWalkable(asset.Walkable)); foreach (var box in AssetPackUtilities.ConvertBoundingBox(asset.BoundingBoxes.ToArray())) { builder.AddBoundingBox(box); } foreach (var product in asset.Products) { GameObject productGo = AssetPackUtilities.LoadAsset <GameObject>(_bundle, product.Guid); if (productGo == null) { Debug.Log("Can't find product game object for:" + product.Name); continue; } switch (product.ProductType) { case ProductType.ON_GOING: var ongoingProductBuilder = Parkitility .CreateOnGoingProduct <OngoingEffectProduct>(productGo) .Id(product.Guid) .DisplayName(product.Name) .Duration(product.Duration) .DestroyWhenDepleted(product.DestroyWhenDepleted) .RemoveFromInventoryWhenDepleted(product.RemoveWhenDepleted) .TwoHanded(product.IsTwoHanded) .InterestingToLookAt(product.IsInterestingToLookAt) .DefaultPrice(product.Price) .HandSide(ProductShopUtility.ConvertToSide(product.HandSide)); foreach (var shopIngredient in product.Ingredients) { _bindIngredients(ongoingProductBuilder.AddIngredient(_assetManagerLoader), product, shopIngredient); } builder.AddProduct(_assetManagerLoader, ongoingProductBuilder); break; case ProductType.BALLOON: Debug.Log(product.Name); var balloonBuilder = Parkitility .CreateBalloonProduct <Balloon>(productGo) .Id(product.Guid) .DisplayName(product.Name) .DestroyWhenDepleted(false) .Duration(180) .DefaultPrice(product.Price) .DefaultMass(product.DefaultMass) .DefaultDrag(product.DefaultDrag) .DefaultAngularDrag(product.DefaultAngularDrag) .RemoveFromInventoryWhenDepleted(true); if (product.HasCustomColors) { balloonBuilder.CustomColor( AssetPackUtilities.ConvertColors(product.CustomColors, product.ColorCount)); } foreach (var shopIngredient in product.Ingredients) { _bindIngredients(balloonBuilder.AddIngredient(_assetManagerLoader), product, shopIngredient); } builder.AddProduct(_assetManagerLoader, balloonBuilder); break; case ProductType.WEARABLE: var wearableProductBuilder = Parkitility .CreateWearableProduct <WearableProduct>(productGo) .Id(product.Guid) .DisplayName(product.Name) .TwoHanded(product.IsTwoHanded) .InterestingToLookAt(product.IsInterestingToLookAt) .DefaultPrice(product.Price) .HandSide(ProductShopUtility.ConvertToSide(product.HandSide)) .TemperaturePreference( ProductShopUtility.ConvertTemperaturePreference( product.TemperaturePreference)) .SeasonalPreference( ProductShopUtility.ConvertSeasonalPreference( product.SeasonalPreference)) .BodyLocation(ProductShopUtility.ConvertBodyLocation(product.BodyLocation)) .HideHair(product.HideHair) .HideOnRide(product.HideOnRide); if (product.HasCustomColors) { wearableProductBuilder.CustomColor( AssetPackUtilities.ConvertColors(product.CustomColors, product.ColorCount)); } foreach (var shopIngredient in product.Ingredients) { _bindIngredients(wearableProductBuilder.AddIngredient(_assetManagerLoader), product, shopIngredient); } builder.AddProduct(_assetManagerLoader, wearableProductBuilder); break; case ProductType.CONSUMABLE: var consumableBuilder = Parkitility .CreateConsumableProduct <ConsumableProduct>(productGo) .Id(product.Guid) .DisplayName(product.Name) .TwoHanded(product.IsTwoHanded) .InterestingToLookAt(product.IsInterestingToLookAt) .TemperaturePreference( ProductShopUtility.ConvertTemperaturePreference( product.TemperaturePreference)) .ConsumeAnimation( ProductShopUtility.ConvertConsumeAnimation(product.ConsumeAnimation)) .DefaultPrice(product.Price) .HandSide(ProductShopUtility.ConvertToSide(product.HandSide)); GameObject trashGo = AssetPackUtilities.LoadAsset <GameObject>(_bundle, product.TrashGuid); if (trashGo != null) { consumableBuilder.Trash <Trash>(trashGo, _assetManagerLoader) .Id(product.TrashGuid) .Disgust(product.DisgustFactor) .Volume(product.Volume) .CanWiggle(product.CanWiggle); } foreach (var shopIngredient in product.Ingredients) { _bindIngredients(consumableBuilder.AddIngredient(_assetManagerLoader), product, shopIngredient); } builder.AddProduct(_assetManagerLoader, consumableBuilder); break; } } builder.Build(_assetManagerLoader); }