public static void BuildPrefab() { if (prefab != null || CompanionBuilder.companionDictionary.ContainsKey(guid)) { return; } //Create the prefab with a starting sprite and hitbox offset/size prefab = CompanionBuilder.BuildPrefab("Big Slime", guid, "ItemAPI/Resources/BigSlime/Idle/son_idle_001", new IntVector2(1, 0), new IntVector2(9, 9)); //Add a companion component to the prefab (could be a custom class) var companion = prefab.AddComponent <CompanionController>(); companion.aiActor.MovementSpeed = 5f; //Add all of the needed animations (most of the animations need to have specific names to be recognized, like idle_right or attack_left) prefab.AddAnimation("idle_right", "ItemAPI/Resources/BigSlime/Idle", fps: 5, AnimationType.Idle, DirectionType.TwoWayHorizontal); prefab.AddAnimation("idle_left", "ItemAPI/Resources/BigSlime/Idle", fps: 5, AnimationType.Idle, DirectionType.TwoWayHorizontal); prefab.AddAnimation("run_right", "ItemAPI/Resources/BigSlime/MoveRight", fps: 7, AnimationType.Move, DirectionType.TwoWayHorizontal); prefab.AddAnimation("run_left", "ItemAPI/Resources/BigSlime/MoveLeft", fps: 7, AnimationType.Move, DirectionType.TwoWayHorizontal); //Add the behavior here, this too can be a custom class that extends AttackBehaviorBase or something like that var bs = prefab.GetComponent <BehaviorSpeculator>(); bs.MovementBehaviors.Add(new CompanionFollowPlayerBehavior() { IdleAnimations = new string[] { "idle" } }); }
// Token: 0x060000C0 RID: 192 RVA: 0x0000891C File Offset: 0x00006B1C public static tk2dSpriteAnimationClip AddAnimation(this GameObject obj, string name, string spriteDirectory, int fps, CompanionBuilder.AnimationType type, DirectionalAnimation.DirectionType directionType = DirectionalAnimation.DirectionType.None, DirectionalAnimation.FlipType flipType = DirectionalAnimation.FlipType.None) { AIAnimator orAddComponent = obj.GetOrAddComponent <AIAnimator>(); DirectionalAnimation directionalAnimation = orAddComponent.GetDirectionalAnimation(name, directionType, type); bool flag = directionalAnimation == null; if (flag) { directionalAnimation = new DirectionalAnimation { AnimNames = new string[0], Flipped = new DirectionalAnimation.FlipType[0], Type = directionType, Prefix = string.Empty }; } directionalAnimation.AnimNames = directionalAnimation.AnimNames.Concat(new string[] { name }).ToArray <string>(); directionalAnimation.Flipped = directionalAnimation.Flipped.Concat(new DirectionalAnimation.FlipType[] { flipType }).ToArray <DirectionalAnimation.FlipType>(); orAddComponent.AssignDirectionalAnimation(name, directionalAnimation, type); return(CompanionBuilder.BuildAnimation(orAddComponent, name, spriteDirectory, fps)); }
// Token: 0x06000020 RID: 32 RVA: 0x00002DFF File Offset: 0x00000FFF public static void Init() { FakePrefabHooks.Init(); CompanionBuilder.Init(); Tools.Init(); ItemBuilder.LoadShopTables(); }
/// <summary> /// Initializes hooks and grabs necessary assets for building items /// </summary> public static void Init() { FakePrefabHooks.Init(); CompanionBuilder.Init(); EnemyBuilder.Init(); LoadShopTables(); }
public static void BuildPrefab() { if (blobPrefab != null || CompanionBuilder.companionDictionary.ContainsKey(guid)) { ETGModConsole.Log("Tried to make the same Blob prefab twice!"); return; } blobPrefab = CompanionBuilder.BuildPrefab("Baby Good Blob", guid, spritePaths[0], new IntVector2(1, 0), new IntVector2(9, 9)); var blob = blobPrefab.AddComponent <RandomGoopTrailBehaviour>(); var aiAnimator = blobPrefab.GetComponent <AIAnimator>(); aiAnimator.MoveAnimation = new DirectionalAnimation() { AnimNames = new string[] { "idle" }, Type = DirectionalAnimation.DirectionType.None }; aiAnimator.IdleAnimation = aiAnimator.MoveAnimation; if (blobCollection == null) { blobCollection = SpriteBuilder.ConstructCollection(blobPrefab, "Baby_Good_Blob_Collection"); GameObject.DontDestroyOnLoad(blobCollection); for (int i = 0; i < spritePaths.Length; i++) { SpriteBuilder.AddSpriteToCollection(spritePaths[i], blobCollection); } SpriteBuilder.AddAnimation(blob.spriteAnimator, blobCollection, new List <int>() { 0, 1, 2, 3, 4, 5 }, "idle", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 5; } var bs = blobPrefab.GetComponent <BehaviorSpeculator>(); bs.MovementBehaviors.Add(new CompanionFollowPlayerBehavior() { IdleAnimations = new string[] { "idle" } }); bs.MovementBehaviors.Add(new SeekTargetBehavior() { LineOfSight = false, StopWhenInRange = true, CustomRange = 1f }); blob.aiActor.MovementSpeed = 7; GameObject.DontDestroyOnLoad(blobPrefab); FakePrefab.MarkAsFakePrefab(blobPrefab); blobPrefab.SetActive(false); }