public static GameObject BuildPrefab(string name, string guid, string defaultSpritePath, IntVector2 hitboxOffset, IntVector2 hitBoxSize) { if (CompanionBuilder.companionDictionary.ContainsKey(guid)) { ETGModConsole.Log("CompanionBuilder: Tried to create two companion prefabs with the same GUID!"); return(null); } var prefab = GameObject.Instantiate(behaviorSpeculatorPrefab); prefab.name = name; //setup misc components var sprite = SpriteBuilder.SpriteFromResource(defaultSpritePath, prefab).GetComponent <tk2dSprite>(); sprite.SetUpSpeculativeRigidbody(hitboxOffset, hitBoxSize).CollideWithOthers = false; prefab.AddComponent <tk2dSpriteAnimator>(); prefab.AddComponent <AIAnimator>(); //setup health haver var healthHaver = prefab.AddComponent <HealthHaver>(); healthHaver.RegisterBodySprite(sprite); healthHaver.PreventAllDamage = true; healthHaver.SetHealthMaximum(15000); healthHaver.FullHeal(); //setup AI Actor var aiActor = prefab.AddComponent <AIActor>(); aiActor.State = AIActor.ActorState.Normal; aiActor.EnemyGuid = guid; //setup behavior speculator var bs = prefab.GetComponent <BehaviorSpeculator>(); bs.MovementBehaviors = new List <MovementBehaviorBase>(); bs.AttackBehaviors = new List <AttackBehaviorBase>(); bs.TargetBehaviors = new List <TargetBehaviorBase>(); bs.OverrideBehaviors = new List <OverrideBehaviorBase>(); bs.OtherBehaviors = new List <BehaviorBase>(); //Add to enemy database EnemyDatabaseEntry enemyDatabaseEntry = new EnemyDatabaseEntry() { myGuid = guid, placeableWidth = 2, placeableHeight = 2, isNormalEnemy = false }; EnemyDatabase.Instance.Entries.Add(enemyDatabaseEntry); CompanionBuilder.companionDictionary.Add(guid, prefab); //finalize GameObject.DontDestroyOnLoad(prefab); FakePrefab.MarkAsFakePrefab(prefab); prefab.SetActive(false); return(prefab); }
public static Object InstantiateOPR(Func <Object, Vector3, Quaternion, Object> orig, Object original, Vector3 position, Quaternion rotation) { return(FakePrefab.Instantiate(original, orig(original, position, rotation))); }
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 InstantiateOP(Func <Object, Transform, Object> orig, Object original, Transform parent) { return(FakePrefab.Instantiate(original, orig(original, parent))); }
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 GameObject BuildPrefab(string name, string guid, string defaultSpritePath, IntVector2 hitboxOffset, IntVector2 hitBoxSize, bool HasAiShooter) { if (EnemyBuilder.Dictionary.ContainsKey(guid)) { ETGModConsole.Log("EnemyBuilder: Yea something went wrong. Complain to Neighborino about it."); return(null); } var prefab = GameObject.Instantiate(behaviorSpeculatorPrefab); prefab.name = name; //setup misc components var sprite = SpriteBuilder.SpriteFromResource(defaultSpritePath, prefab).GetComponent <tk2dSprite>(); sprite.SetUpSpeculativeRigidbody(hitboxOffset, hitBoxSize).CollideWithOthers = true; prefab.AddComponent <tk2dSpriteAnimator>(); prefab.AddComponent <AIAnimator>(); //setup knockback var knockback = prefab.AddComponent <KnockbackDoer>(); knockback.weight = 1; //setup health haver var healthHaver = prefab.AddComponent <HealthHaver>(); healthHaver.RegisterBodySprite(sprite); healthHaver.PreventAllDamage = false; healthHaver.SetHealthMaximum(15000); healthHaver.FullHeal(); //setup AI Actor var aiActor = prefab.AddComponent <AIActor>(); aiActor.State = AIActor.ActorState.Normal; aiActor.EnemyGuid = guid; aiActor.CanTargetPlayers = true; aiActor.HasShadow = false; aiActor.specRigidbody.CollideWithOthers = true; aiActor.specRigidbody.CollideWithTileMap = true; aiActor.specRigidbody.PixelColliders.Clear(); aiActor.specRigidbody.PixelColliders.Add(new PixelCollider { ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual, CollisionLayer = CollisionLayer.EnemyCollider, IsTrigger = false, BagleUseFirstFrameOnly = false, SpecifyBagelFrame = string.Empty, BagelColliderNumber = 0, ManualOffsetX = 0, ManualOffsetY = 0, ManualWidth = 15, ManualHeight = 17, ManualDiameter = 0, ManualLeftX = 0, ManualLeftY = 0, ManualRightX = 0, ManualRightY = 0 }); aiActor.specRigidbody.PixelColliders.Add(new PixelCollider { ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual, CollisionLayer = CollisionLayer.EnemyHitBox, IsTrigger = false, BagleUseFirstFrameOnly = false, SpecifyBagelFrame = string.Empty, BagelColliderNumber = 0, ManualOffsetX = 0, ManualOffsetY = 0, ManualWidth = 15, ManualHeight = 17, ManualDiameter = 0, ManualLeftX = 0, ManualLeftY = 0, ManualRightX = 0, ManualRightY = 0, }); aiActor.CorpseObject = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").CorpseObject; aiActor.PreventBlackPhantom = false; //setup behavior speculator var bs = prefab.GetComponent <BehaviorSpeculator>(); bs.MovementBehaviors = new List <MovementBehaviorBase>(); bs.AttackBehaviors = new List <AttackBehaviorBase>(); bs.TargetBehaviors = new List <TargetBehaviorBase>(); bs.OverrideBehaviors = new List <OverrideBehaviorBase>(); bs.OtherBehaviors = new List <BehaviorBase>(); prefab.AddComponent <AIBulletBank>(); if (HasAiShooter) { var actor = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5"); behaviorSpeculatorPrefab = GameObject.Instantiate(actor.gameObject); foreach (Transform child in behaviorSpeculatorPrefab.transform) { if (child != behaviorSpeculatorPrefab.transform) { GameObject.DestroyImmediate(child); } } foreach (var comp in behaviorSpeculatorPrefab.GetComponents <Component>()) { if (comp.GetType() != typeof(BehaviorSpeculator)) { GameObject.DestroyImmediate(comp); } } GameObject.DontDestroyOnLoad(behaviorSpeculatorPrefab); FakePrefab.MarkAsFakePrefab(behaviorSpeculatorPrefab); behaviorSpeculatorPrefab.SetActive(false); } //Add to enemy database EnemyDatabaseEntry enemyDatabaseEntry = new EnemyDatabaseEntry() { myGuid = guid, placeableWidth = 2, placeableHeight = 2, isNormalEnemy = true }; EnemyDatabase.Instance.Entries.Add(enemyDatabaseEntry); EnemyBuilder.Dictionary.Add(guid, prefab); //finalize GameObject.DontDestroyOnLoad(prefab); FakePrefab.MarkAsFakePrefab(prefab); prefab.SetActive(false); return(prefab); }
public static GameObject BuildPrefab(string name, string guid, string defaultSpritePath, IntVector2 hitboxOffset, IntVector2 hitBoxSize, bool HasAiShooter, bool UsesAttackGroup = false) { if (BossBuilder.Dictionary.ContainsKey(guid)) { ETGModConsole.Log("BossBuilder: Yea something went wrong. Complain to Neighborino about it."); return(null); } var prefab = GameObject.Instantiate(behaviorSpeculatorPrefab); prefab.name = name; //setup misc components var sprite = SpriteBuilder.SpriteFromResource(defaultSpritePath, prefab).GetComponent <tk2dSprite>(); sprite.SetUpSpeculativeRigidbody(hitboxOffset, hitBoxSize).CollideWithOthers = true; prefab.AddComponent <tk2dSpriteAnimator>(); prefab.AddComponent <AIAnimator>(); PickupObject item = PickupObjectDatabase.GetById(291); //setup knockback var knockback = prefab.AddComponent <KnockbackDoer>(); knockback.weight = 1; //setup health haver var healthHaver = prefab.AddComponent <HealthHaver>(); healthHaver.RegisterBodySprite(sprite); healthHaver.PreventAllDamage = false; healthHaver.SetHealthMaximum(15000); healthHaver.FullHeal(); //setup AI Actor var aiActor = prefab.AddComponent <AIActor>(); aiActor.State = AIActor.ActorState.Normal; aiActor.EnemyGuid = guid; aiActor.HasShadow = false; //setup behavior speculator var bs = prefab.GetComponent <BehaviorSpeculator>(); bs.MovementBehaviors = new List <MovementBehaviorBase>(); bs.TargetBehaviors = new List <TargetBehaviorBase>(); bs.OverrideBehaviors = new List <OverrideBehaviorBase>(); bs.OtherBehaviors = new List <BehaviorBase>(); bs.AttackBehaviorGroup.AttackBehaviors = new List <AttackBehaviorGroup.AttackGroupItem>(); if (HasAiShooter) { var actor = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5"); behaviorSpeculatorPrefab = GameObject.Instantiate(actor.gameObject); foreach (Transform child in behaviorSpeculatorPrefab.transform) { if (child != behaviorSpeculatorPrefab.transform) { GameObject.DestroyImmediate(child); } } foreach (var comp in behaviorSpeculatorPrefab.GetComponents <Component>()) { if (comp.GetType() != typeof(BehaviorSpeculator)) { GameObject.DestroyImmediate(comp); } } GameObject.DontDestroyOnLoad(behaviorSpeculatorPrefab); FakePrefab.MarkAsFakePrefab(behaviorSpeculatorPrefab); behaviorSpeculatorPrefab.SetActive(false); } else { AIBulletBank aibulletBank = prefab.AddComponent <AIBulletBank>(); } //Add to enemy database EnemyDatabaseEntry enemyDatabaseEntry = new EnemyDatabaseEntry { myGuid = guid, placeableWidth = 2, placeableHeight = 2, isNormalEnemy = true, path = guid, isInBossTab = true, encounterGuid = guid, }; EnemyDatabase.Instance.Entries.Add(enemyDatabaseEntry); BossBuilder.Dictionary.Add(guid, prefab); //finalize GameObject.DontDestroyOnLoad(prefab); FakePrefab.MarkAsFakePrefab(prefab); prefab.SetActive(false); return(prefab); }
public static UnityEngine.Object InstantiateO(Func <UnityEngine.Object, UnityEngine.Object> orig, UnityEngine.Object original) { return(FakePrefab.Instantiate(original, orig(original))); }
public static UnityEngine.Object InstantiateOP(Func <UnityEngine.Object, Transform, UnityEngine.Object> orig, UnityEngine.Object original, Transform parent) { return(FakePrefab.Instantiate(original, orig(original, parent))); }