public static Object InstantiateO(Func <Object, Object> orig, Object original) { return(FakePrefab.Instantiate(original, orig(original))); }
public static Object InstantiateOPI(Func <Object, Transform, bool, Object> orig, Object original, Transform parent, bool instantiateInWorldSpace) { return(FakePrefab.Instantiate(original, orig(original, parent, instantiateInWorldSpace))); }
public static Object InstantiateOP(Func <Object, Transform, Object> orig, Object original, Transform parent) { return(FakePrefab.Instantiate(original, orig(original, parent))); }
public static T InstantiateGeneric <T>(Object original) where T : Object { return((T)FakePrefab.Instantiate(original, Object.Instantiate(original))); }
public static Object InstantiateOPRP(Func <Object, Vector3, Quaternion, Transform, Object> orig, Object original, Vector3 position, Quaternion rotation, Transform parent) { return(FakePrefab.Instantiate(original, orig(original, position, rotation, parent))); }
public static Object InstantiateOPR(Func <Object, Vector3, Quaternion, Object> orig, Object original, Vector3 position, Quaternion rotation) { return(FakePrefab.Instantiate(original, orig(original, position, rotation))); }
///maybe add some value proofing here (name != null, collider != IntVector2.Zero) public GameObject Build() { try { //Get texture and create sprite Texture2D tex = ResourceExtractor.GetTextureFromResource(spritePath); var shrine = ItemAPI.SpriteBuilder.SpriteFromResource(spritePath, null, false); //Add (hopefully) unique ID to shrine for tracking string ID = $"{modID}:{name}".ToLower().Replace(" ", "_"); shrine.name = ID; //Position sprite var shrineSprite = shrine.GetComponent <tk2dSprite>(); shrineSprite.IsPerpendicular = true; shrineSprite.PlaceAtPositionByAnchor(offset, tk2dBaseSprite.Anchor.LowerCenter); //Add speech bubble origin var talkPoint = new GameObject("talkpoint").transform; talkPoint.position = shrine.transform.position + talkPointOffset; talkPoint.SetParent(shrine.transform); //Set up collider if (!usesCustomColliderOffsetAndSize) { IntVector2 spriteDimensions = new IntVector2(tex.width, tex.height); colliderOffset = new IntVector2(0, 0); colliderSize = new IntVector2(spriteDimensions.x, spriteDimensions.y / 2); } var body = ItemAPI.SpriteBuilder.SetUpSpeculativeRigidbody(shrineSprite, colliderOffset, colliderSize); //if (!string.IsNullOrEmpty(shadowSpritePath)) //{ // var shadow = ((GameObject)UnityEngine.Object.Instantiate(ResourceCache.Acquire("DefaultShadowSprite"))).GetComponent<tk2dSprite>(); // var shadowSprite = ItemAPI.SpriteBuilder.SpriteFromResource(shadowSpritePath, null, false).GetComponent<tk2dSprite>(); // Tools.Print($"Shadow material: {shadow.renderer.material.name}"); // Tools.Print($"\tShadow color: {shadow.color}"); // Tools.Print($"\tShadow material: {shadowSprite.renderer.material.name}"); // Tools.Print($"\tShadow color: {shadowSprite.color}"); // Tools.ExportTexture(shadow.renderer.material.mainTexture.GetReadable()); // //Tools.ExportTexture(shadowSprite.renderer.material.mainTexture.GetReadable()); // shrineSprite.AttachRenderer(shadow); // shadow.PlaceAtPositionByAnchor(shrineSprite.WorldBottomCenter, tk2dBaseSprite.Anchor.UpperCenter); // //shadow.color = new Color(1, 1, 1, .5f); // //shadow.HeightOffGround = -0.1f; // //shadow.renderer.material = defaultSprite.renderer.material; // DepthLookupManager.ProcessRenderer(shadow.GetComponent<Renderer>(), DepthLookupManager.GungeonSortingLayer.BACKGROUND); // //Tools.LogPropertiesAndFields(defaultSprite); //} var data = shrine.AddComponent <CustomShrineController>(); data.ID = ID; data.roomStyles = roomStyles; data.isBreachShrine = true; data.offset = offset; data.pixelColliders = body.specRigidbody.PixelColliders; data.factory = this; data.OnAccept = OnAccept; data.OnDecline = OnDecline; data.CanUse = CanUse; data.text = text; data.acceptText = acceptText; data.declineText = declineText; if (interactableComponent == null) { var simpInt = shrine.AddComponent <SimpleShrine>(); simpInt.isToggle = this.isToggle; simpInt.OnAccept = this.OnAccept; simpInt.OnDecline = this.OnDecline; simpInt.CanUse = CanUse; simpInt.text = this.text; simpInt.acceptText = this.acceptText; simpInt.declineText = this.declineText; simpInt.talkPoint = talkPoint; } else { shrine.AddComponent(interactableComponent); } shrine.name = ID; if (!isBreachShrine) { if (!room) { room = RoomFactory.CreateEmptyRoom(); } RegisterShrineRoom(shrine, room, ID, offset); } registeredShrines.Add(ID, shrine); FakePrefab.MarkAsFakePrefab(shrine); Tools.Print("Added shrine: " + ID); return(shrine); } catch (Exception e) { Tools.PrintException(e); return(null); } }
// Token: 0x0600005C RID: 92 RVA: 0x00005ABC File Offset: 0x00003CBC public GameObject Build() { GameObject result; try { Texture2D textureFromResource = ResourceExtractor.GetTextureFromResource(this.spritePath); GameObject gameObject = SpriteBuilder.SpriteFromResource(this.spritePath, null, false); string text = (this.modID + ":" + this.name).ToLower().Replace(" ", "_"); gameObject.name = text; tk2dSprite component = gameObject.GetComponent <tk2dSprite>(); component.IsPerpendicular = true; component.PlaceAtPositionByAnchor(this.offset, tk2dBaseSprite.Anchor.LowerCenter); Transform transform = new GameObject("talkpoint").transform; transform.position = gameObject.transform.position + this.talkPointOffset; transform.SetParent(gameObject.transform); bool flag = !this.usesCustomColliderOffsetAndSize; bool flag2 = flag; if (flag2) { IntVector2 intVector = new IntVector2(textureFromResource.width, textureFromResource.height); this.colliderOffset = new IntVector2(0, 0); this.colliderSize = new IntVector2(intVector.x, intVector.y / 2); } SpeculativeRigidbody speculativeRigidbody = component.SetUpSpeculativeRigidbody(this.colliderOffset, this.colliderSize); ShrineFactory.CustomShrineController customShrineController = gameObject.AddComponent <ShrineFactory.CustomShrineController>(); customShrineController.ID = text; customShrineController.roomStyles = this.roomStyles; customShrineController.isBreachShrine = true; customShrineController.offset = this.offset; customShrineController.pixelColliders = speculativeRigidbody.specRigidbody.PixelColliders; customShrineController.factory = this; customShrineController.OnAccept = this.OnAccept; customShrineController.OnDecline = this.OnDecline; customShrineController.CanUse = this.CanUse; customShrineController.text = this.text; customShrineController.acceptText = this.acceptText; customShrineController.declineText = this.declineText; bool flag3 = this.interactableComponent == null; bool flag4 = flag3; if (flag4) { SimpleShrine simpleShrine = gameObject.AddComponent <SimpleShrine>(); simpleShrine.isToggle = this.isToggle; simpleShrine.OnAccept = this.OnAccept; simpleShrine.OnDecline = this.OnDecline; simpleShrine.CanUse = this.CanUse; simpleShrine.text = this.text; simpleShrine.acceptText = this.acceptText; simpleShrine.declineText = this.declineText; simpleShrine.talkPoint = transform; } else { gameObject.AddComponent(this.interactableComponent); } gameObject.name = text; bool flag5 = !this.isBreachShrine; bool flag6 = flag5; if (flag6) { bool flag7 = !this.room; bool flag8 = flag7; if (flag8) { this.room = GungeonAPI.RoomFactory.CreateEmptyRoom(12, 12); } ShrineFactory.RegisterShrineRoom(gameObject, this.room, text, this.offset); } ShrineFactory.registeredShrines.Add(text, gameObject); FakePrefab.MarkAsFakePrefab(gameObject); Tools.Print <string>("Added shrine: " + text, "FFFFFF", false); result = gameObject; } catch (Exception e) { Tools.PrintException(e, "FF0000"); result = null; } return(result); }