public void HandleVFX(VFXPool vfx, bool value) { if (vfx != null && vfx.effects != null) { vfx.ToggleRenderers(value); } }
private static void DeconstructVFXPool(VFXPool pool) { int iterator = 0; if (pool.effects != null && pool.effects.Length > 0) { foreach (VFXComplex comp in pool.effects) { ETGModConsole.Log("<color=#ff0000ff> VFXPoolEffect: </color>" + iterator); if (comp.effects != null && comp.effects.Length > 0) { foreach (VFXObject obj in comp.effects) { ETGModConsole.Log("<color=#ff0000ff> VFXObject: </color>" + iterator); if (obj.effect != null) { ETGModConsole.Log("<color=#ff0000ff> Effect: </color>" + obj.effect.name); } else { ETGModConsole.Log("<color=#ff0000ff> Effect: </color>" + "NULL"); } } } else { ETGModConsole.Log("<color=#ff0000ff> VFXObject: </color>" + "NULL"); } } } else { ETGModConsole.Log("<color=#ff0000ff> VFXPoolEffects: </color>" + "NULL"); } }
public static void Init() { string itemName = "Imposter's Knife"; string resourceName = "ImposterItems/Resources/imposter_knife"; GameObject obj = new GameObject(itemName); var item = obj.AddComponent <ImpostersKnife>(); ItemBuilder.AddSpriteToObject(itemName, resourceName, obj); string shortDesc = "Wasn't me"; string longDesc = "On use, deliver a quick short range, high damage stab towards a direction of your choosing.\n\nSharp, quick, reliable, and most importantly never runs out of ammo. It's no wonder why the knife is such an effective " + "killing device, held back only for it's short range..maybe there's some kind of workaround to that..."; ItemBuilder.SetupItem(item, shortDesc, longDesc, "spapi"); ItemBuilder.SetCooldownType(item, ItemBuilder.CooldownType.Damage, 500); item.consumable = false; item.quality = ItemQuality.SPECIAL; var cm = Instantiate((GameObject)BraveResources.Load("Global Prefabs/_ChallengeManager", ".prefab")); item.DarknessEffectShader = (cm.GetComponent <ChallengeManager>().PossibleChallenges.Where(c => c.challenge is DarknessChallengeModifier).First().challenge as DarknessChallengeModifier).DarknessEffectShader; VFXPool stabVFX = new VFXPool { type = VFXPoolType.All }; VFXComplex complex = new VFXComplex(); VFXObject vfxObj = new VFXObject { alignment = VFXAlignment.Fixed, attached = true, orphaned = false, persistsOnDeath = false, destructible = true, usesZHeight = true, zHeight = -0.25f }; GameObject stabKnifeObj = SpriteBuilder.SpriteFromResource("ImposterItems/Resources/imposter_knife_stab", new GameObject("ImposterKnifeStab")); stabKnifeObj.SetActive(false); FakePrefab.MarkAsFakePrefab(stabKnifeObj); DontDestroyOnLoad(stabKnifeObj); tk2dSpriteAnimator animator = stabKnifeObj.AddComponent <tk2dSpriteAnimator>(); SpriteBuilder.AddAnimation(animator, stabKnifeObj.GetComponent <tk2dBaseSprite>().Collection, new List <int> { stabKnifeObj.GetComponent <tk2dBaseSprite>().spriteId }, "stab", tk2dSpriteAnimationClip.WrapMode.Once).fps = 1; animator.playAutomatically = true; animator.DefaultClipId = animator.GetClipIdByName("stab"); SpriteAnimatorKiller killer = stabKnifeObj.AddComponent <SpriteAnimatorKiller>(); killer.fadeTime = -1f; killer.delayDestructionTime = -1f; killer.animator = animator; ConstructOffsetsFromAnchor(stabKnifeObj.GetComponent <tk2dBaseSprite>().GetCurrentSpriteDef(), tk2dBaseSprite.Anchor.MiddleLeft); vfxObj.effect = stabKnifeObj; complex.effects = new VFXObject[] { vfxObj }; stabVFX.effects = new VFXComplex[] { complex }; item.stabVfx = stabVFX; Destroy(cm); ImpostersKnifeId = item.PickupObjectId; Game.Items.Rename("spapi:imposter's_knife", "spapi:imposters_knife"); }
private void Awake() { if (Instance != null && Instance != this) { Destroy(this.gameObject); } else { Instance = this; } }
public void Remove() { VFXPool.PlayVFX(VFXPool.VFXType.BoxStack, transform.position); stack.Remove(this); if (transform.parent != null) { transform.parent = null; } gameObject.SetActive(false); transform.localScale = Vector3.zero; }
public static void Init() { //Spirat Teleportation VFX #region SpiratTP GameObject teleportBullet = EnemyDatabase.GetOrLoadByGuid("7ec3e8146f634c559a7d58b19191cd43").bulletBank.GetBullet("self").BulletObject; Projectile proj = teleportBullet.GetComponent <Projectile>(); if (proj != null) { TeleportProjModifier tp = proj.GetComponent <TeleportProjModifier>(); if (tp != null) { SpiratTeleportVFXPool = tp.teleportVfx; SpiratTeleportVFX = tp.teleportVfx.effects[0].effects[0].effect; } } #endregion }
private void Awake() { if (Instance == null) { Instance = this; DontDestroyOnLoad(this); } else { Destroy(gameObject); return; } for (int i = 0; i < m_VFXPrefabsList.Count; i++) { m_VFXToPrefabDictionary.Add(m_VFXList[i], m_VFXPrefabsList[i]); } }
public static void Init() { //Last Bullet Standing VFX GameObject ChallengeManagerReference = LoadHelper.LoadAssetFromAnywhere <GameObject>("_ChallengeManager"); LastBulletStandingX = (ChallengeManagerReference.GetComponent <ChallengeManager>().PossibleChallenges[0].challenge as BestForLastChallengeModifier).KingVFX; //Spirat Teleportation VFX #region SpiratTP GameObject teleportBullet = EnemyDatabase.GetOrLoadByGuid("7ec3e8146f634c559a7d58b19191cd43").bulletBank.GetBullet("self").BulletObject; Projectile proj = teleportBullet.GetComponent <Projectile>(); if (proj != null) { TeleportProjModifier tp = proj.GetComponent <TeleportProjModifier>(); if (tp != null) { SpiratTeleportVFXPool = tp.teleportVfx; SpiratTeleportVFX = tp.teleportVfx.effects[0].effects[0].effect; } } #endregion }
public override void Start() { base.Start(); m_cachedKnockback = m_aiActor.CollisionKnockbackStrength; m_cachedDamage = m_aiActor.CollisionDamage; m_cachedVfx = m_aiActor.CollisionVFX; m_cachedNonActorWallVfx = m_aiActor.NonActorCollisionVFX; m_cachedPathableTiles = m_aiActor.PathableTiles; m_cachedDoDustUps = m_aiActor.DoDustUps; m_cachedDustUpInterval = m_aiActor.DustUpInterval; if (switchCollidersOnCharge) { for (int i = 0; i < m_aiActor.specRigidbody.PixelColliders.Count; i++) { PixelCollider pixelCollider = m_aiActor.specRigidbody.PixelColliders[i]; if (pixelCollider.CollisionLayer == CollisionLayer.EnemyCollider) { m_enemyCollider = pixelCollider; } if (pixelCollider.CollisionLayer == CollisionLayer.EnemyHitBox) { m_enemyHitbox = pixelCollider; } if (!pixelCollider.Enabled && pixelCollider.CollisionLayer == CollisionLayer.Projectile) { m_projectileCollider = pixelCollider; m_projectileCollider.CollisionLayerCollidableOverride |= CollisionMask.LayerToMask(CollisionLayer.Projectile); } } } if (!collidesWithDodgeRollingPlayers) { SpeculativeRigidbody specRigidbody = m_aiActor.specRigidbody; specRigidbody.OnPreRigidbodyCollision = (SpeculativeRigidbody.OnPreRigidbodyCollisionDelegate)Delegate.Combine(specRigidbody.OnPreRigidbodyCollision, new SpeculativeRigidbody.OnPreRigidbodyCollisionDelegate(OnPreRigidbodyCollision)); } }
public static void Add() { Gun gun = ETGMod.Databases.Items.NewGun("Royal Guard's Knife", "royal_guard's_knife"); Game.Items.Rename("outdated_gun_mods:royal_guard's_knife", "sts:royal_guard's_knife"); gun.gameObject.AddComponent <RoyalGuardsKnife>(); gun.SetShortDescription("Stab Stab Stab"); gun.SetLongDescription("A weak hunting knife used by The Royal Guard for cutting up game or sawing rope."); gun.SetupSprite(null, "royal_guard's_knife_idle_001", 8); gun.SetAnimationFPS(gun.shootAnimation, 12); gun.SetAnimationFPS(gun.reloadAnimation, 2); gun.AddProjectileModuleFrom("38_special", true, false); gun.DefaultModule.ammoType = GameUIAmmoType.AmmoType.SMALL_BULLET; gun.DefaultModule.ammoCost = 1; gun.DefaultModule.shootStyle = ProjectileModule.ShootStyle.SemiAutomatic; gun.DefaultModule.sequenceStyle = ProjectileModule.ProjectileSequenceStyle.Random; gun.reloadTime = 0f; gun.DefaultModule.angleVariance = 0f; gun.DefaultModule.cooldownTime = .2f; gun.DefaultModule.numberOfShotsInClip = 350; Gun gun2 = PickupObjectDatabase.GetById(151) as Gun; gun.muzzleFlashEffects.type = VFXPoolType.None; gun.SetBaseMaxAmmo(350); gun.barrelOffset.transform.localPosition = new Vector3(0.75f, 0f, 0f); gun.quality = PickupObject.ItemQuality.EXCLUDED; gun.encounterTrackable.EncounterGuid = "Fuckfuckfuckfuckpleaseworkpleasefuckingworkpleasepleasework."; gun.sprite.IsPerpendicular = true; gun.gunClass = GunClass.NONE; Projectile projectile = UnityEngine.Object.Instantiate <Projectile>(gun.DefaultModule.projectiles[0]); projectile.gameObject.SetActive(false); FakePrefab.MarkAsFakePrefab(projectile.gameObject); UnityEngine.Object.DontDestroyOnLoad(projectile); gun.DefaultModule.projectiles[0] = projectile; projectile.transform.parent = gun.barrelOffset; projectile.baseData.damage *= .5f; VFXPool fuckyouyoustupidfuckingvfxihateyousofuckingmuchyougoddamnmistakefuckyourubelaswellihateyousomuchformakingthevfxpoolcodesofuckingbadAAAAAAAAAAAAAAAAAAAAAAAAA = VFXLibrary.CreateMuzzleflash("royal_guard's_knife_slash", new List <string> { "royal_guard's_knife_slash_001", "royal_guard's_knife_slash_002", "royal_guard's_knife_slash_003", "royal_guard's_knife_slash_004", }, 10, new List <IntVector2> { new IntVector2(27, 27), new IntVector2(27, 27), new IntVector2(27, 27), new IntVector2(27, 27), }, new List <tk2dBaseSprite.Anchor> { tk2dBaseSprite.Anchor.MiddleLeft, tk2dBaseSprite.Anchor.MiddleLeft, tk2dBaseSprite.Anchor.MiddleLeft, tk2dBaseSprite.Anchor.MiddleLeft }, new List <Vector2> { Vector2.zero, Vector2.zero, Vector2.zero, Vector2.zero, }, false, false, false, false, 0, VFXAlignment.Fixed, true, new List <float> { 0, 0, 0, 0 }, new List <Color> { VFXLibrary.emptyColor, VFXLibrary.emptyColor, VFXLibrary.emptyColor, VFXLibrary.emptyColor, }); ProjectileSlashingBehaviour slashingBehaviour = projectile.gameObject.AddComponent <ProjectileSlashingBehaviour>(); slashingBehaviour.SlashVFX = fuckyouyoustupidfuckingvfxihateyousofuckingmuchyougoddamnmistakefuckyourubelaswellihateyousomuchformakingthevfxpoolcodesofuckingbadAAAAAAAAAAAAAAAAAAAAAAAAA; slashingBehaviour.SlashDimensions = 65; slashingBehaviour.SlashRange = 2.5f; ETGMod.Databases.Items.Add(gun, null, "ANY"); gun.AddToSubShop(ItemBuilder.ShopType.Goopton); gun.AddToSubShop(ItemBuilder.ShopType.Trorc); }
private void BeginState(FireState state) { switch (state) { case FireState.Idle: if (HideGun) { m_aiShooter.ToggleGunAndHandRenderers(true, "ChargeBehavior"); } m_aiActor.BehaviorOverridesVelocity = false; m_aiAnimator.LockFacingDirection = false; break; case FireState.Priming: if (HideGun) { m_aiShooter.ToggleGunAndHandRenderers(false, "ChargeBehavior"); } m_aiAnimator.PlayUntilFinished(primeAnim, true, null, -1f, false); if (primeTime > 0f) { m_timer = primeTime; } else { m_timer = m_aiAnimator.CurrentClipLength; } if (stopDuringPrime) { m_aiActor.ClearPath(); m_aiActor.BehaviorOverridesVelocity = true; m_aiActor.BehaviorVelocity = Vector2.zero; } else { m_aiActor.BehaviorOverridesVelocity = true; m_aiActor.BehaviorVelocity = m_aiActor.specRigidbody.Velocity; } break; case FireState.Charging: if (HideGun) { m_aiShooter.ToggleGunAndHandRenderers(false, "ChargeBehavior"); } m_chargeTime = 0f; Vector2 vector = m_aiActor.TargetRigidbody.specRigidbody.GetUnitCenter(ColliderType.HitBox); if (leadAmount > 0f) { Vector2 b = vector + m_aiActor.TargetRigidbody.specRigidbody.Velocity * 0.75f; b = BraveMathCollege.GetPredictedPosition(vector, m_aiActor.TargetVelocity, m_aiActor.specRigidbody.UnitCenter, chargeSpeed); vector = Vector2.Lerp(vector, b, leadAmount); } m_aiActor.ClearPath(); m_aiActor.BehaviorOverridesVelocity = true; m_currentSpeed = ((chargeAcceleration <= 0f) ? chargeSpeed : 0f); m_chargeDirection = (vector - m_aiActor.specRigidbody.UnitCenter).ToAngle(); m_aiActor.BehaviorVelocity = BraveMathCollege.DegreesToVector(m_chargeDirection, m_currentSpeed); m_aiAnimator.LockFacingDirection = true; m_aiAnimator.FacingDirection = m_chargeDirection; m_aiActor.CollisionKnockbackStrength = chargeKnockback; m_aiActor.CollisionDamage = chargeDamage; if (hitVfx) { VFXObject vfxobject = new VFXObject(); vfxobject.effect = hitVfx; VFXComplex vfxcomplex = new VFXComplex(); vfxcomplex.effects = new VFXObject[] { vfxobject }; VFXPool vfxpool = new VFXPool(); vfxpool.type = VFXPoolType.Single; vfxpool.effects = new VFXComplex[] { vfxcomplex }; m_aiActor.CollisionVFX = vfxpool; } if (nonActorHitVfx) { VFXObject vfxobject2 = new VFXObject(); vfxobject2.effect = nonActorHitVfx; VFXComplex vfxcomplex2 = new VFXComplex(); vfxcomplex2.effects = new VFXObject[] { vfxobject2 }; VFXPool vfxpool2 = new VFXPool(); vfxpool2.type = VFXPoolType.Single; vfxpool2.effects = new VFXComplex[] { vfxcomplex2 }; m_aiActor.NonActorCollisionVFX = vfxpool2; } m_aiActor.PathableTiles = (CellTypes.FLOOR | CellTypes.PIT); if (switchCollidersOnCharge) { m_enemyCollider.CollisionLayer = CollisionLayer.TileBlocker; m_enemyHitbox.Enabled = false; m_projectileCollider.Enabled = true; } m_aiActor.DoDustUps = chargeDustUps; m_aiActor.DustUpInterval = chargeDustUpInterval; m_aiAnimator.PlayUntilFinished(chargeAnim, true, null, -1f, false); if (launchVfx) { SpawnManager.SpawnVFX(launchVfx, m_aiActor.specRigidbody.UnitCenter, Quaternion.identity); } if (trailVfx) { m_trailVfx = SpawnManager.SpawnParticleSystem(trailVfx, m_aiActor.sprite.WorldCenter, Quaternion.Euler(0f, 0f, m_chargeDirection)); if (trailVfxParent) { m_trailVfx.transform.parent = trailVfxParent; } else { m_trailVfx.transform.parent = m_aiActor.transform; } ParticleKiller component = m_trailVfx.GetComponent <ParticleKiller>(); if (component != null) { component.Awake(); } } if (bulletScript != null && !bulletScript.IsNull) { Fire(); } m_aiActor.specRigidbody.ForceRegenerate(null, null); break; case FireState.Bouncing: m_aiAnimator.PlayUntilFinished(hitAnim, true, null, -1f, false); break; } }
public static void Init() { Gun gun = ETGMod.Databases.Items.NewGun("Lich's Gun", "lichsgun"); Game.Items.Rename("outdated_gun_mods:lich's_gun", "spapi:lichs_gun"); GunExt.SetShortDescription(gun, "Bullet Dance"); GunExt.SetLongDescription(gun, "This is Gun from Gungeon Master."); GunExt.SetupSprite(gun, null, "lichsgun_idle_001", 10); GunExt.SetAnimationFPS(gun, gun.shootAnimation, 12); GunExt.AddProjectileModuleFrom(gun, "klobb", true, false); gun.DefaultModule.shootStyle = ProjectileModule.ShootStyle.SemiAutomatic; gun.DefaultModule.angleVariance = 0; gun.DefaultModule.ammoType = GameUIAmmoType.AmmoType.MEDIUM_BULLET; InputGuidedProjectile projectile = CopyFields <InputGuidedProjectile>(UnityEngine.Object.Instantiate((PickupObjectDatabase.GetById(183) as Gun).DefaultModule.projectiles[0])); projectile.trackingSpeed = 500f; projectile.dumbfireTime = -1f; projectile.gameObject.SetActive(false); FakePrefab.MarkAsFakePrefab(projectile.gameObject); UnityEngine.Object.DontDestroyOnLoad(projectile); gun.DefaultModule.projectiles[0] = projectile; projectile.baseData.damage = 5f; projectile.shouldRotate = true; projectile.name = "LichsGun_Projectile"; projectile.baseData.range = 18f; projectile.baseData.speed = 22f; SetProjectileSpriteRight(projectile, "lichsgun_projectile_001", 6, 6, false, tk2dBaseSprite.Anchor.MiddleCenter, true, false, null, null, null, null, (PickupObjectDatabase.GetById(183) as Gun).DefaultModule.projectiles[0]); gun.reloadClipLaunchFrame = 0; gun.DefaultModule.cooldownTime = 0.1f; gun.DefaultModule.numberOfShotsInClip = 6; for (int i = 0; i < gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.shootAnimation).frames.Length; i++) { gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.shootAnimation).frames[i].triggerEvent = true; tk2dSpriteDefinition def = gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.shootAnimation).frames[i].spriteCollection.spriteDefinitions[gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.shootAnimation).frames[i].spriteId]; Vector2 offset = new Vector2(((float)fireOffsets[i].x) / 16f, ((float)fireOffsets[i].y) / 16f); LichsBookItem.MakeOffset(def, offset); } for (int i = 0; i < gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.reloadAnimation).frames.Length; i++) { gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.reloadAnimation).frames[i].triggerEvent = true; tk2dSpriteDefinition def = gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.reloadAnimation).frames[i].spriteCollection.spriteDefinitions[gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.reloadAnimation).frames[i].spriteId]; Vector2 offset = new Vector2(((float)reloadOffsets[i].x) / 16f, ((float)reloadOffsets[i].y) / 16f); LichsBookItem.MakeOffset(def, offset); } tk2dSpriteAnimationClip reloadClip = gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.reloadAnimation); reloadClip.frames = new tk2dSpriteAnimationFrame[0]; foreach (string text in reloadFrames) { tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame { spriteCollection = ETGMod.Databases.Items.WeaponCollection, spriteId = ETGMod.Databases.Items.WeaponCollection.GetSpriteIdByName(text) }; reloadClip.frames = reloadClip.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray(); } tk2dSpriteAnimationClip shootClip = gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.shootAnimation); shootClip.frames = new tk2dSpriteAnimationFrame[0]; foreach (string text in shootFrames) { tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame { spriteCollection = ETGMod.Databases.Items.WeaponCollection, spriteId = ETGMod.Databases.Items.WeaponCollection.GetSpriteIdByName(text) }; shootClip.frames = shootClip.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray(); } VFXPool muzzleFlashVfx = new VFXPool { type = VFXPoolType.All }; VFXComplex complex = new VFXComplex(); VFXObject vfxObj = new VFXObject { alignment = VFXAlignment.Fixed, attached = false, orphaned = true, persistsOnDeath = false, destructible = true, usesZHeight = true, zHeight = -0.25f }; List <int> muzzleFlashIds = new List <int> { VFXCollection.GetSpriteIdByName("lichsgun_vfx_001"), VFXCollection.GetSpriteIdByName("lichsgun_vfx_002"), VFXCollection.GetSpriteIdByName("lichsgun_vfx_003"), VFXCollection.GetSpriteIdByName("lichsgun_vfx_004") }; GameObject muzzleFlashVfxObject = new GameObject("LichsGunMuzzleflash"); muzzleFlashVfxObject.AddComponent <tk2dSprite>().SetSprite(VFXCollection, muzzleFlashIds[0]); muzzleFlashVfxObject.SetActive(false); FakePrefab.MarkAsFakePrefab(muzzleFlashVfxObject); UnityEngine.Object.DontDestroyOnLoad(muzzleFlashVfxObject); tk2dSpriteAnimator animator = muzzleFlashVfxObject.AddComponent <tk2dSpriteAnimator>(); SpriteBuilder.AddAnimation(animator, muzzleFlashVfxObject.GetComponent <tk2dBaseSprite>().Collection, muzzleFlashIds, "flash", tk2dSpriteAnimationClip.WrapMode.Once).fps = 16; animator.playAutomatically = true; animator.DefaultClipId = animator.GetClipIdByName("flash"); SpriteAnimatorKiller killer = muzzleFlashVfxObject.AddComponent <SpriteAnimatorKiller>(); killer.fadeTime = -1f; killer.delayDestructionTime = -1f; killer.animator = animator; foreach (int id in muzzleFlashIds) { LichsBookItem.ConstructOffsetsFromAnchor(VFXCollection.spriteDefinitions[id], tk2dBaseSprite.Anchor.MiddleLeft); } vfxObj.effect = muzzleFlashVfxObject; complex.effects = new VFXObject[] { vfxObj }; muzzleFlashVfx.effects = new VFXComplex[] { complex }; gun.gunSwitchGroup = "SAA"; gun.muzzleFlashEffects = muzzleFlashVfx; gun.reloadTime = 1.1f; gun.SetBaseMaxAmmo(350); gun.quality = PickupObject.ItemQuality.D; gun.barrelOffset.transform.localPosition = new Vector3(1.1875f, 0.5625f, 0f); gun.gunClass = GunClass.PISTOL; ETGMod.Databases.Items.Add(gun, null, "ANY"); InitSynergyForm(gun); }
public static void Init() { Gun gun = ETGMod.Databases.Items.NewGun("High-Quality Gun", "hd"); Game.Items.Rename("outdated_gun_mods:high-quality_gun", "spapi:high_quality_gun"); gun.gameObject.AddComponent <HDGun>(); GunExt.SetShortDescription(gun, "HD!"); GunExt.SetLongDescription(gun, "Bullets charm enemies.\n\nThis gun is just magnum, but but has 4 times more pixels. Because of that, it seems very weird among all other guns, but at the same time looks kinda cool!"); GunExt.SetupSprite(gun, null, "hd_idle_001", 8); GunExt.SetAnimationFPS(gun, gun.shootAnimation, 13); GunExt.SetAnimationFPS(gun, gun.reloadAnimation, 12); GunExt.AddProjectileModuleFrom(gun, Toolbox.GetGunById(38), true, false); gun.gunSwitchGroup = "Magnum"; VFXPool pool = new VFXPool(); pool.type = VFXPoolType.All; VFXComplex complex = new VFXComplex(); VFXObject vfObj = new VFXObject(); GameObject obj = new GameObject("hd_smoke"); obj.SetActive(false); FakePrefab.MarkAsFakePrefab(obj); UnityEngine.Object.DontDestroyOnLoad(obj); tk2dSprite sprite = obj.AddComponent <tk2dSprite>(); tk2dSpriteAnimator animator = obj.AddComponent <tk2dSpriteAnimator>(); tk2dSpriteAnimationClip clip = new tk2dSpriteAnimationClip(); GameObject origEffect = Toolbox.GetGunById(38).muzzleFlashEffects.effects[0].effects[0].effect; VFXObject origVfEffect = Toolbox.GetGunById(38).muzzleFlashEffects.effects[0].effects[0]; clip.fps = origEffect.GetAnyComponent <tk2dSpriteAnimator>().DefaultClip.fps; clip.frames = new tk2dSpriteAnimationFrame[0]; for (int i = 1; i < 4; i++) { tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame(); frame.spriteId = Toolbox.VFXCollection.GetSpriteIdByName("hd_smoke_00" + i); Toolbox.VFXCollection.inst.spriteDefinitions[frame.spriteId] = Toolbox.VFXCollection.inst.spriteDefinitions[origEffect.GetAnyComponent <tk2dSpriteAnimator>().DefaultClip.frames[i - 1].spriteId].CopyDefinitionFrom(); frame.spriteCollection = Toolbox.VFXCollection; clip.frames = clip.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray(); } clip.wrapMode = tk2dSpriteAnimationClip.WrapMode.Once; clip.name = "start"; animator.spriteAnimator.Library = animator.gameObject.AddComponent <tk2dSpriteAnimation>(); animator.spriteAnimator.Library.clips = new tk2dSpriteAnimationClip[] { clip }; animator.playAutomatically = true; animator.DefaultClipId = animator.GetClipIdByName("start"); SpriteAnimatorKiller kill = animator.gameObject.AddComponent <SpriteAnimatorKiller>(); kill.fadeTime = -1f; kill.animator = animator; kill.delayDestructionTime = -1f; obj.gameObject.SetLayerRecursively(LayerMask.NameToLayer("Unpixelated")); vfObj.orphaned = origVfEffect.orphaned; vfObj.attached = origVfEffect.attached; vfObj.persistsOnDeath = origVfEffect.persistsOnDeath; vfObj.usesZHeight = origVfEffect.usesZHeight; vfObj.zHeight = origVfEffect.zHeight; vfObj.alignment = origVfEffect.alignment; vfObj.destructible = origVfEffect.destructible; vfObj.effect = obj; VFXObject vfObj2 = new VFXObject(); GameObject obj2 = new GameObject("hd_flare"); obj2.SetActive(false); FakePrefab.MarkAsFakePrefab(obj2); UnityEngine.Object.DontDestroyOnLoad(obj2); tk2dSprite sprite2 = obj2.AddComponent <tk2dSprite>(); tk2dSpriteAnimator animator2 = obj2.AddComponent <tk2dSpriteAnimator>(); tk2dSpriteAnimationClip clip2 = new tk2dSpriteAnimationClip(); GameObject origEffect2 = Toolbox.GetGunById(38).muzzleFlashEffects.effects[0].effects[1].effect; VFXObject origVfEffect2 = Toolbox.GetGunById(38).muzzleFlashEffects.effects[0].effects[1]; clip2.fps = origEffect2.GetAnyComponent <tk2dSpriteAnimator>().DefaultClip.fps; clip2.frames = new tk2dSpriteAnimationFrame[0]; for (int i = 1; i < 6; i++) { tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame(); frame.spriteId = Toolbox.VFXCollection.GetSpriteIdByName("hd_flare_00" + i); Toolbox.VFXCollection.inst.spriteDefinitions[frame.spriteId] = Toolbox.VFXCollection.inst.spriteDefinitions[origEffect2.GetAnyComponent <tk2dSpriteAnimator>().DefaultClip.frames[i - 1].spriteId].CopyDefinitionFrom(); frame.spriteCollection = Toolbox.VFXCollection; clip2.frames = clip2.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray(); } clip2.wrapMode = tk2dSpriteAnimationClip.WrapMode.Once; clip2.name = "start"; animator2.spriteAnimator.Library = animator2.gameObject.AddComponent <tk2dSpriteAnimation>(); animator2.spriteAnimator.Library.clips = new tk2dSpriteAnimationClip[] { clip2 }; animator2.playAutomatically = true; animator2.DefaultClipId = animator2.GetClipIdByName("start"); SpriteAnimatorKiller kill2 = animator2.gameObject.AddComponent <SpriteAnimatorKiller>(); kill2.fadeTime = -1f; kill2.animator = animator2; kill2.delayDestructionTime = -1f; obj2.gameObject.SetLayerRecursively(LayerMask.NameToLayer("Unpixelated")); vfObj2.orphaned = origVfEffect2.orphaned; vfObj2.attached = origVfEffect2.attached; vfObj2.persistsOnDeath = origVfEffect2.persistsOnDeath; vfObj2.usesZHeight = origVfEffect2.usesZHeight; vfObj2.zHeight = origVfEffect2.zHeight; vfObj2.alignment = origVfEffect2.alignment; vfObj2.destructible = origVfEffect2.destructible; vfObj2.effect = obj2; complex.effects = new VFXObject[] { vfObj, vfObj2 }; pool.effects = new VFXComplex[] { complex }; gun.muzzleFlashEffects = pool; Projectile projectile = UnityEngine.Object.Instantiate <Projectile>((PickupObjectDatabase.GetById(38) as Gun).DefaultModule.projectiles[0]); projectile.gameObject.SetActive(false); FakePrefab.MarkAsFakePrefab(projectile.gameObject); UnityEngine.Object.DontDestroyOnLoad(projectile); gun.DefaultModule.projectiles[0] = projectile; gun.OverrideAngleSnap = null; projectile.transform.parent = gun.barrelOffset; projectile.AppliesCharm = true; projectile.CharmApplyChance = 100f; projectile.baseData.damage = 20f; projectile.charmEffect = (PickupObjectDatabase.GetById(527) as BulletStatusEffectItem).CharmModifierEffect; projectile.GetAnySprite().spriteId = ETGMod.Databases.Items.ProjectileCollection.inst.GetSpriteIdByName("hd_bullet_001"); ETGMod.Databases.Items.ProjectileCollection.inst.spriteDefinitions[projectile.GetAnySprite().spriteId] = ETGMod.Databases.Items.ProjectileCollection.inst.spriteDefinitions[(PickupObjectDatabase.GetById(38) as Gun).DefaultModule.projectiles[0].GetAnySprite().spriteId].CopyDefinitionFrom(); gun.DefaultModule.numberOfShotsInClip = 8; projectile.name = "Charmingly_HD_Projectile"; gun.reloadTime = 1.0f; gun.SetBaseMaxAmmo(280); gun.quality = PickupObject.ItemQuality.S; gun.encounterTrackable.EncounterGuid = "hd"; gun.gunClass = GunClass.PISTOL; GameObject shellCasing = UnityEngine.Object.Instantiate(Toolbox.GetGunById(38).shellCasing); shellCasing.SetActive(false); FakePrefab.MarkAsFakePrefab(shellCasing); tk2dSpriteAnimator gunAnim = gun.GetComponent <tk2dSpriteAnimator>(); tk2dSpriteAnimationClip reloadClip = gunAnim.GetClipByName(gun.reloadAnimation); reloadClip.frames = new tk2dSpriteAnimationFrame[0]; foreach (string text in reloadFrames) { tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame { spriteCollection = ETGMod.Databases.Items.WeaponCollection, spriteId = ETGMod.Databases.Items.WeaponCollection.GetSpriteIdByName(text) }; reloadClip.frames = reloadClip.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray(); } UnityEngine.Object.DontDestroyOnLoad(shellCasing); shellCasing.GetAnyComponent <tk2dBaseSprite>().SetSprite(Toolbox.VFXCollection, Toolbox.VFXCollection.GetSpriteIdByName("hd_shell_001")); Toolbox.VFXCollection.spriteDefinitions[shellCasing.GetAnyComponent <tk2dBaseSprite>().spriteId] = Toolbox.GetGunById(38).shellCasing.GetAnyComponent <tk2dBaseSprite>().Collection.spriteDefinitions[Toolbox.GetGunById(38).shellCasing.GetAnyComponent <tk2dBaseSprite>().spriteId].CopyDefinitionFrom(); shellCasing.AddComponent <AlwaysUnpixeledBehaviour>(); gun.shellCasing = shellCasing; gun.shellsToLaunchOnFire = 0; gun.shellsToLaunchOnReload = 6; gun.reloadShellLaunchFrame = 2; gun.barrelOffset.transform.localPosition = new Vector3(1.0625f, 0.5625f, 0f); ETGMod.Databases.Items.Add(gun, null, "ANY"); gun.AddToCursulaShop(); gun.AddToBlacksmithShop(); gun.RemovePeskyQuestionmark(); gun.PlaceItemInAmmonomiconAfterItemById(38); ItemBuilder.AddPassiveStatModifier(gun, PlayerStats.StatType.Coolness, 3, StatModifier.ModifyMethod.ADDITIVE); tk2dSpriteDefinition ammonomiconDef = AmmonomiconController.ForceInstance.EncounterIconCollection.spriteDefinitions[AmmonomiconController.ForceInstance.EncounterIconCollection.GetSpriteIdByName("hd_idle_001")]; ammonomiconDef.position1 = new Vector3(ammonomiconDef.position1.x / 2, ammonomiconDef.position1.y / 2, ammonomiconDef.position1.z / 2); ammonomiconDef.position2 = new Vector3(ammonomiconDef.position2.x / 2, ammonomiconDef.position2.y / 2, ammonomiconDef.position2.z / 2); ammonomiconDef.position3 = new Vector3(ammonomiconDef.position3.x / 2, ammonomiconDef.position3.y / 2, ammonomiconDef.position3.z / 2); ammonomiconDef.boundsDataCenter = new Vector3(ammonomiconDef.boundsDataCenter.x / 2, ammonomiconDef.boundsDataCenter.y / 2, ammonomiconDef.boundsDataCenter.z / 2); ammonomiconDef.boundsDataExtents = new Vector3(ammonomiconDef.boundsDataExtents.x / 2, ammonomiconDef.boundsDataExtents.y / 2, ammonomiconDef.boundsDataExtents.z / 2); ammonomiconDef.untrimmedBoundsDataCenter = new Vector3(ammonomiconDef.untrimmedBoundsDataCenter.x / 2, ammonomiconDef.untrimmedBoundsDataCenter.y / 2, ammonomiconDef.untrimmedBoundsDataCenter.z / 2); ammonomiconDef.untrimmedBoundsDataExtents = new Vector3(ammonomiconDef.untrimmedBoundsDataExtents.x / 2, ammonomiconDef.untrimmedBoundsDataExtents.y / 2, ammonomiconDef.untrimmedBoundsDataExtents.z / 2); List <tk2dSpriteDefinition> affected = new List <tk2dSpriteDefinition>(); foreach (tk2dSpriteAnimationClip clip3 in gun.GetGunAnimationClips()) { if (clip3.frames != null) { foreach (tk2dSpriteAnimationFrame frame in clip3.frames) { if (frame != null && frame.spriteCollection != null) { tk2dSpriteDefinition def = frame.spriteCollection.spriteDefinitions[frame.spriteId]; if (def != null && !affected.Contains(def)) { def.position1 = new Vector3(def.position1.x / 2, def.position1.y / 2, def.position1.z / 2); def.position2 = new Vector3(def.position2.x / 2, def.position2.y / 2, def.position2.z / 2); def.position3 = new Vector3(def.position3.x / 2, def.position3.y / 2, def.position3.z / 2); def.boundsDataCenter = new Vector3(def.boundsDataCenter.x / 2, def.boundsDataCenter.y / 2, def.boundsDataCenter.z / 2); def.boundsDataExtents = new Vector3(def.boundsDataExtents.x / 2, def.boundsDataExtents.y / 2, def.boundsDataExtents.z / 2); def.untrimmedBoundsDataCenter = new Vector3(def.untrimmedBoundsDataCenter.x / 2, def.untrimmedBoundsDataCenter.y / 2, def.untrimmedBoundsDataCenter.z / 2); def.untrimmedBoundsDataExtents = new Vector3(def.untrimmedBoundsDataExtents.x / 2, def.untrimmedBoundsDataExtents.y / 2, def.untrimmedBoundsDataExtents.z / 2); def.RemoveOffset(); affected.Add(def); } } } } } affected.Clear(); int index = 0; foreach (tk2dSpriteAnimationFrame frame in gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.idleAnimation).frames) { tk2dSpriteDefinition def = frame.spriteCollection.spriteDefinitions[frame.spriteId]; if (def != null && !affected.Contains(def)) { def.MakeOffset(offsets[0][index]); affected.Add(def); } index++; } index = 0; foreach (tk2dSpriteAnimationFrame frame in gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.shootAnimation).frames) { tk2dSpriteDefinition def = frame.spriteCollection.spriteDefinitions[frame.spriteId]; if (def != null && !affected.Contains(def)) { def.MakeOffset(offsets[1][index]); affected.Add(def); } index++; } index = 0; foreach (tk2dSpriteAnimationFrame frame in gun.GetComponent <tk2dSpriteAnimator>().GetClipByName(gun.reloadAnimation).frames) { tk2dSpriteDefinition def = frame.spriteCollection.spriteDefinitions[frame.spriteId]; if (def != null && !affected.Contains(def)) { def.MakeOffset(offsets[2][index]); affected.Add(def); } index++; } AdvancedHoveringGunSynergyProcessor processor = gun.gameObject.AddComponent <AdvancedHoveringGunSynergyProcessor>(); processor.RequiredSynergy = "#LOW-QUALITY_HELP"; processor.TargetGunID = 38; processor.UsesMultipleGuns = false; processor.PositionType = HoveringGunController.HoverPosition.CIRCULATE; processor.AimType = HoveringGunController.AimType.PLAYER_AIM; processor.FireType = HoveringGunController.FireType.ON_RELOAD; processor.FireCooldown = 0.2f; processor.FireDuration = 0f; processor.OnlyOnEmptyReload = false; processor.ShootAudioEvent = ""; processor.OnEveryShotAudioEvent = ""; processor.FinishedShootingAudioEvent = ""; processor.Trigger = AdvancedHoveringGunSynergyProcessor.TriggerStyle.CONSTANT; processor.NumToTrigger = 1; processor.TriggerDuration = 0f; processor.ConsumesTargetGunAmmo = false; processor.ChanceToConsumeTargetGunAmmo = 0f; }
public static void Add() { Gun gun = ETGMod.Databases.Items.NewGun("Blowgun", "blowgun"); Game.Items.Rename("outdated_gun_mods:blowgun", "nn:blowgun"); var behav = gun.gameObject.AddComponent <Blowgun>(); behav.preventNormalReloadAudio = true; gun.SetShortDescription("Huff and Puff"); gun.SetLongDescription("Relies on lung strength to propel poisonous darts." + "\n\nRobots may need to hold it up to a cooling vent or something."); gun.SetupSprite(null, "blowgun_idle_001", 8); gun.SetAnimationFPS(gun.shootAnimation, 15); gun.AddProjectileModuleFrom(PickupObjectDatabase.GetById(56) as Gun, true, false); gun.gunSwitchGroup = (PickupObjectDatabase.GetById(150) as Gun).gunSwitchGroup; //GUN STATS gun.muzzleFlashEffects = (PickupObjectDatabase.GetById(26) as Gun).muzzleFlashEffects; gun.DefaultModule.ammoCost = 1; gun.DefaultModule.shootStyle = ProjectileModule.ShootStyle.SemiAutomatic; gun.DefaultModule.sequenceStyle = ProjectileModule.ProjectileSequenceStyle.Random; gun.reloadTime = 0.5f; gun.DefaultModule.cooldownTime = 0.2f; gun.DefaultModule.numberOfShotsInClip = 1; gun.barrelOffset.transform.localPosition = new Vector3(1.12f, 0.18f, 0f); gun.SetBaseMaxAmmo(200); gun.gunClass = GunClass.POISON; //BULLET STATS Projectile projectile = UnityEngine.Object.Instantiate <Projectile>(gun.DefaultModule.projectiles[0]); projectile.gameObject.SetActive(false); FakePrefab.MarkAsFakePrefab(projectile.gameObject); UnityEngine.Object.DontDestroyOnLoad(projectile); gun.DefaultModule.projectiles[0] = projectile; projectile.transform.parent = gun.barrelOffset; projectile.baseData.speed *= 2f; projectile.damageTypes |= CoreDamageTypes.Poison; ExtremelySimplePoisonBulletBehaviour poisoning = projectile.gameObject.AddComponent <ExtremelySimplePoisonBulletBehaviour>(); poisoning.procChance = 1; poisoning.useSpecialTint = false; projectile.SetProjectileSpriteRight("blowgun_projectile", 16, 7, false, tk2dBaseSprite.Anchor.MiddleCenter, 15, 8); VFXPool HorizVFXOBj = VFXToolbox.CreateVFXPool("Blowgun Tilemap VFX Horiz", new List <string>() { "NevernamedsItems/Resources/MiscVFX/GunVFX/PoisonDarts/poisondart_impacthoriz_001", "NevernamedsItems/Resources/MiscVFX/GunVFX/PoisonDarts/poisondart_impacthoriz_002", "NevernamedsItems/Resources/MiscVFX/GunVFX/PoisonDarts/poisondart_impacthoriz_003", "NevernamedsItems/Resources/MiscVFX/GunVFX/PoisonDarts/poisondart_impacthoriz_004", }, 10, new IntVector2(12, 11), tk2dBaseSprite.Anchor.MiddleLeft, false, 0, true); projectile.hitEffects.deathTileMapHorizontal = HorizVFXOBj; projectile.hitEffects.tileMapHorizontal = HorizVFXOBj; projectile.hitEffects.deathTileMapVertical = HorizVFXOBj; projectile.hitEffects.tileMapVertical = HorizVFXOBj; gun.DefaultModule.ammoType = GameUIAmmoType.AmmoType.CUSTOM; gun.DefaultModule.customAmmoType = CustomClipAmmoTypeToolbox.AddCustomAmmoType("Blowgun Darts", "NevernamedsItems/Resources/CustomGunAmmoTypes/blowgun_clipfull", "NevernamedsItems/Resources/CustomGunAmmoTypes/blowgun_clipempty"); gun.quality = PickupObject.ItemQuality.D; gun.encounterTrackable.EncounterGuid = "this is the Blowgun"; ETGMod.Databases.Items.Add(gun, null, "ANY"); foreach (tk2dSpriteAnimationClip clip in AdjustGunPosition.GetGunAnimationClips(gun)) { foreach (tk2dSpriteAnimationFrame frame in clip.frames) { frame.spriteCollection.spriteDefinitions[frame.spriteId].ApplyOffset(new Vector2(0, 0f)); } } BlowgunID = gun.PickupObjectId; }
public void Emergence() { VFXPool.PlayVFX(VFXPool.VFXType.BoxStack, transform.position); }
public static VFXPool CreateVFXPool(string name, List <string> spritePaths, int fps, IntVector2 Dimensions, tk2dBaseSprite.Anchor anchor, bool usesZHeight, float zHeightOffset, bool persist = false, VFXAlignment alignment = VFXAlignment.NormalAligned, float emissivePower = -1, Color?emissiveColour = null) { GameObject Obj = new GameObject(name); VFXPool pool = new VFXPool(); pool.type = VFXPoolType.All; VFXComplex complex = new VFXComplex(); VFXObject vfObj = new VFXObject(); Obj.SetActive(false); FakePrefab.MarkAsFakePrefab(Obj); UnityEngine.Object.DontDestroyOnLoad(Obj); tk2dSpriteCollectionData VFXSpriteCollection = SpriteBuilder.ConstructCollection(Obj, (name + "_Collection")); int spriteID = SpriteBuilder.AddSpriteToCollection(spritePaths[0], VFXSpriteCollection); tk2dSprite sprite = Obj.GetOrAddComponent <tk2dSprite>(); sprite.SetSprite(VFXSpriteCollection, spriteID); tk2dSpriteDefinition defaultDef = sprite.GetCurrentSpriteDef(); defaultDef.colliderVertices = new Vector3[] { new Vector3(0f, 0f, 0f), new Vector3((Dimensions.x / 16), (Dimensions.y / 16), 0f) }; tk2dSpriteAnimator animator = Obj.GetOrAddComponent <tk2dSpriteAnimator>(); tk2dSpriteAnimation animation = Obj.GetOrAddComponent <tk2dSpriteAnimation>(); animation.clips = new tk2dSpriteAnimationClip[0]; animator.Library = animation; tk2dSpriteAnimationClip clip = new tk2dSpriteAnimationClip() { name = "start", frames = new tk2dSpriteAnimationFrame[0], fps = fps }; List <tk2dSpriteAnimationFrame> frames = new List <tk2dSpriteAnimationFrame>(); for (int i = 0; i < spritePaths.Count; i++) { tk2dSpriteCollectionData collection = VFXSpriteCollection; int frameSpriteId = SpriteBuilder.AddSpriteToCollection(spritePaths[i], collection); tk2dSpriteDefinition frameDef = collection.spriteDefinitions[frameSpriteId]; frameDef.ConstructOffsetsFromAnchor(anchor); frameDef.colliderVertices = defaultDef.colliderVertices; if (emissivePower > 0) { frameDef.material.shader = ShaderCache.Acquire("Brave/LitTk2dCustomFalloffTintableTiltedCutoutEmissive"); } if (emissivePower > 0) { frameDef.material.SetFloat("_EmissiveColorPower", emissivePower); } if (emissiveColour != null) { frameDef.material.SetColor("_EmissiveColor", (Color)emissiveColour); } if (emissivePower > 0) { frameDef.materialInst.shader = ShaderCache.Acquire("Brave/LitTk2dCustomFalloffTintableTiltedCutoutEmissive"); } if (emissivePower > 0) { frameDef.materialInst.SetFloat("_EmissiveColorPower", emissivePower); } if (emissiveColour != null) { frameDef.materialInst.SetColor("_EmissiveColor", (Color)emissiveColour); } frames.Add(new tk2dSpriteAnimationFrame { spriteId = frameSpriteId, spriteCollection = collection }); } if (emissivePower > 0) { sprite.renderer.material.shader = ShaderCache.Acquire("Brave/LitTk2dCustomFalloffTintableTiltedCutoutEmissive"); } if (emissivePower > 0) { sprite.renderer.material.SetFloat("_EmissiveColorPower", emissivePower); } if (emissiveColour != null) { sprite.renderer.material.SetColor("_EmissiveColor", (Color)emissiveColour); } clip.frames = frames.ToArray(); clip.wrapMode = tk2dSpriteAnimationClip.WrapMode.Once; animation.clips = animation.clips.Concat(new tk2dSpriteAnimationClip[] { clip }).ToArray(); if (!persist) { SpriteAnimatorKiller kill = animator.gameObject.AddComponent <SpriteAnimatorKiller>(); kill.fadeTime = -1f; kill.animator = animator; kill.delayDestructionTime = -1f; } animator.playAutomatically = true; animator.DefaultClipId = animator.GetClipIdByName("start"); vfObj.attached = true; vfObj.persistsOnDeath = persist; vfObj.usesZHeight = usesZHeight; vfObj.zHeight = zHeightOffset; vfObj.alignment = alignment; vfObj.destructible = false; vfObj.effect = Obj; complex.effects = new VFXObject[] { vfObj }; pool.effects = new VFXComplex[] { complex }; return(pool); }
public override void OnInteraction() { gameObject.SetActive(false); VFXPool.PlayVFX(VFXPool.VFXType.CoinCollect, transform.position); }
public static void Add() { Gun gun = ETGMod.Databases.Items.NewGun("Rebar Gun", "rebargun"); Game.Items.Rename("outdated_gun_mods:rebar_gun", "nn:rebar_gun"); gun.gameObject.AddComponent <RebarGun>(); gun.SetShortDescription("Raising the Bar"); gun.SetLongDescription("An incredibly satisfying piece of industrial machinery, designed specifically for killing adorable wildlife."); gun.SetupSprite(null, "rebargun_idle_001", 8); gun.gunSwitchGroup = (PickupObjectDatabase.GetById(806) as Gun).gunSwitchGroup; gun.SetAnimationFPS(gun.shootAnimation, 16); gun.AddProjectileModuleFrom(PickupObjectDatabase.GetById(56) as Gun, true, false); //VFX List <string> RebarGunImpactVFX = new List <string>() { "NevernamedsItems/Resources/MiscVFX/GunVFX/RebarGunImpactVFX2_001", "NevernamedsItems/Resources/MiscVFX/GunVFX/RebarGunImpactVFX2_002", "NevernamedsItems/Resources/MiscVFX/GunVFX/RebarGunImpactVFX2_003", "NevernamedsItems/Resources/MiscVFX/GunVFX/RebarGunImpactVFX2_004", "NevernamedsItems/Resources/MiscVFX/GunVFX/RebarGunImpactVFX2_005", "NevernamedsItems/Resources/MiscVFX/GunVFX/RebarGunImpactVFX2_006", }; VFXPool VFXOBj = VFXToolbox.CreateVFXPool("Rebar Gun Impact VFX", RebarGunImpactVFX, 16, new IntVector2(11, 8), tk2dBaseSprite.Anchor.MiddleLeft, false, 0, true); //GUN STATS gun.muzzleFlashEffects = (PickupObjectDatabase.GetById(12) as Gun).muzzleFlashEffects; gun.DefaultModule.ammoCost = 1; gun.DefaultModule.shootStyle = ProjectileModule.ShootStyle.SemiAutomatic; gun.DefaultModule.sequenceStyle = ProjectileModule.ProjectileSequenceStyle.Random; gun.reloadTime = 1.21f; gun.DefaultModule.cooldownTime = 0.3f; gun.DefaultModule.numberOfShotsInClip = 3; gun.barrelOffset.transform.localPosition = new Vector3(1.5f, 0.87f, 0f); gun.SetBaseMaxAmmo(170); gun.gunClass = GunClass.PISTOL; //BULLET STATS Projectile projectile = UnityEngine.Object.Instantiate <Projectile>(gun.DefaultModule.projectiles[0]); projectile.gameObject.SetActive(false); FakePrefab.MarkAsFakePrefab(projectile.gameObject); UnityEngine.Object.DontDestroyOnLoad(projectile); gun.DefaultModule.projectiles[0] = projectile; projectile.transform.parent = gun.barrelOffset; projectile.SetProjectileSpriteRight("rebargun_proj", 20, 2, false, tk2dBaseSprite.Anchor.MiddleCenter, 6, 2); projectile.baseData.speed *= 4f; projectile.baseData.damage = 20f; projectile.baseData.force *= 5; projectile.hitEffects.deathTileMapHorizontal = VFXOBj; projectile.hitEffects.tileMapHorizontal = VFXOBj; //Custom Clip VFX gun.DefaultModule.ammoType = GameUIAmmoType.AmmoType.CUSTOM; gun.DefaultModule.customAmmoType = CustomClipAmmoTypeToolbox.AddCustomAmmoType("Rebar Shells", "NevernamedsItems/Resources/CustomGunAmmoTypes/rebargun_clipfull", "NevernamedsItems/Resources/CustomGunAmmoTypes/rebargun_clipempty"); gun.quality = PickupObject.ItemQuality.B; ETGMod.Databases.Items.Add(gun, null, "ANY"); //gun.SetupUnlockOnCustomFlag(CustomDungeonFlags.PURCHASED_BLASMASTER, true); RebarGunID = gun.PickupObjectId; }
public void SetVFXPool(VFXPool vp) { vPool = vp; }
public static void Add() { Gun gun = ETGMod.Databases.Items.NewGun("Ancient Katana", "ancient_katana"); Game.Items.Rename("outdated_gun_mods:ancient_katana", "sts:ancient_katana"); gun.gameObject.AddComponent <Katana>(); gun.SetShortDescription("Blade Breathing, 1st Form"); gun.SetLongDescription("Can be charged to release a flurry of attacks."); gun.SetupSprite(null, "ancient_katana_idle_001", 8); gun.SetAnimationFPS(gun.shootAnimation, 12); gun.SetAnimationFPS(gun.reloadAnimation, 2); gun.AddProjectileModuleFrom("38_special", true, false); gun.DefaultModule.ammoType = GameUIAmmoType.AmmoType.SMALL_BULLET; gun.DefaultModule.ammoCost = 1; gun.DefaultModule.shootStyle = ProjectileModule.ShootStyle.Charged; gun.DefaultModule.sequenceStyle = ProjectileModule.ProjectileSequenceStyle.Random; gun.reloadTime = 0f; gun.DefaultModule.angleVariance = 0f; gun.DefaultModule.cooldownTime = .5f; gun.DefaultModule.numberOfShotsInClip = 350; Gun gun2 = PickupObjectDatabase.GetById(151) as Gun; gun.muzzleFlashEffects.type = VFXPoolType.None; gun.SetBaseMaxAmmo(350); gun.barrelOffset.transform.localPosition = new Vector3(2.5f, 0f, 0f); gun.quality = PickupObject.ItemQuality.EXCLUDED; gun.encounterTrackable.EncounterGuid = "wht the f**k did this break MTG AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaAAAA."; gun.sprite.IsPerpendicular = true; gun.gunClass = GunClass.NONE; Projectile projectile = UnityEngine.Object.Instantiate <Projectile>(gun.DefaultModule.projectiles[0]); Projectile projectile2 = UnityEngine.Object.Instantiate <Projectile>(gun.DefaultModule.projectiles[0]); projectile.gameObject.SetActive(false); FakePrefab.MarkAsFakePrefab(projectile.gameObject); UnityEngine.Object.DontDestroyOnLoad(projectile); projectile.transform.parent = gun.barrelOffset; projectile.baseData.damage *= 3f; projectile.baseData.speed = 0; ProjectileSlashingBehaviour slashingBehaviour = projectile.gameObject.AddComponent <ProjectileSlashingBehaviour>(); slashingBehaviour.SlashDimensions = 135; slashingBehaviour.SlashRange = 5f; slashingBehaviour.delayBeforeSlash = .1f; projectile2.gameObject.SetActive(false); FakePrefab.MarkAsFakePrefab(projectile2.gameObject); UnityEngine.Object.DontDestroyOnLoad(projectile2); projectile2.transform.parent = gun.barrelOffset; projectile2.baseData.damage *= 3f; projectile2.baseData.speed = 0; ProjectileSlashingBehaviour slashingBehaviour2 = projectile2.gameObject.AddComponent <ProjectileSlashingBehaviour>(); slashingBehaviour2.SlashDimensions = 135; slashingBehaviour2.SlashRange = 5f; slashingBehaviour2.delayBeforeSlash = .2f; slashingBehaviour2.DoesMultipleSlashes = true; slashingBehaviour2.AmountOfMultiSlashes = 5; slashingBehaviour2.DelayBetweenMultiSlashes = .2f; slashingBehaviour2.UsesAngleVariance = true; slashingBehaviour2.MinSlashAngleOffset = -8; slashingBehaviour2.MaxSlashAngleOffset = 8; ProjectileModule.ChargeProjectile chargeProjectile1 = new ProjectileModule.ChargeProjectile() { Projectile = projectile, ChargeTime = 0 }; ProjectileModule.ChargeProjectile chargeProjectile2 = new ProjectileModule.ChargeProjectile() { Projectile = projectile2, ChargeTime = .7f }; gun.DefaultModule.chargeProjectiles = new List <ProjectileModule.ChargeProjectile> { chargeProjectile1, chargeProjectile2 }; VFXPool SlashVFX = VFXLibrary.CreateMuzzleflash("katanaslice", new List <string> { "katanaslice_001", "katanaslice_002", "katanaslice_003", }, 10, new List <IntVector2> { new IntVector2(72, 67), new IntVector2(72, 67), new IntVector2(72, 67), }, new List <tk2dBaseSprite.Anchor> { tk2dBaseSprite.Anchor.MiddleLeft, tk2dBaseSprite.Anchor.MiddleLeft, tk2dBaseSprite.Anchor.MiddleLeft }, new List <Vector2> { Vector2.zero, Vector2.zero, Vector2.zero }, false, false, false, false, 0, VFXAlignment.Fixed, true, new List <float> { 0, 0, 0 }, new List <Color> { VFXLibrary.emptyColor, VFXLibrary.emptyColor, VFXLibrary.emptyColor }); slashingBehaviour.SlashVFX = SlashVFX; slashingBehaviour2.SlashVFX = SlashVFX; ETGMod.Databases.Items.Add(gun, null, "ANY"); gun.AddToSubShop(ItemBuilder.ShopType.Goopton); gun.AddToSubShop(ItemBuilder.ShopType.Trorc); }
public static void DoRadialDamage(float damage, Vector3 position, float radius, bool damagePlayers, bool damageEnemies, bool ignoreDamageCaps = false, VFXPool hitVFX = null) { List <HealthHaver> allHealthHavers = StaticReferenceManager.AllHealthHavers; if (allHealthHavers != null) { for (int i = 0; i < allHealthHavers.Count; i++) { HealthHaver healthHaver = allHealthHavers[i]; if (healthHaver) { if (healthHaver.gameObject.activeSelf) { if (!healthHaver.aiActor || !healthHaver.aiActor.IsGone) { if (!healthHaver.aiActor || healthHaver.aiActor.isActiveAndEnabled) { for (int j = 0; j < healthHaver.NumBodyRigidbodies; j++) { SpeculativeRigidbody bodyRigidbody = healthHaver.GetBodyRigidbody(j); Vector2 a = healthHaver.transform.position.XY(); Vector2 vector = a - position.XY(); bool flag = false; bool flag2 = false; float num; if (bodyRigidbody.HitboxPixelCollider != null) { a = bodyRigidbody.HitboxPixelCollider.UnitCenter; vector = a - position.XY(); num = BraveMathCollege.DistToRectangle(position.XY(), bodyRigidbody.HitboxPixelCollider.UnitBottomLeft, bodyRigidbody.HitboxPixelCollider.UnitDimensions); } else { a = healthHaver.transform.position.XY(); vector = a - position.XY(); num = vector.magnitude; } if (num < radius) { PlayerController component = healthHaver.GetComponent <PlayerController>(); if (component != null) { bool flag3 = true; if (PassiveItem.ActiveFlagItems.ContainsKey(component) && PassiveItem.ActiveFlagItems[component].ContainsKey(typeof(HelmetItem)) && num > radius * HelmetItem.EXPLOSION_RADIUS_MULTIPLIER) { flag3 = false; } if (IsPlayerBlockedByWall(component, position)) { flag3 = false; } if (damagePlayers && flag3 && !component.IsEthereal) { HealthHaver healthHaver2 = healthHaver; float damage2 = 0.5f; Vector2 direction = vector; string enemiesString = StringTableManager.GetEnemiesString("#EXPLOSION", -1); CoreDamageTypes damageTypes = CoreDamageTypes.None; DamageCategory damageCategory = DamageCategory.Normal; healthHaver2.ApplyDamage(damage2, direction, enemiesString, damageTypes, damageCategory, false, null, ignoreDamageCaps); flag2 = true; } } else if (damageEnemies) { AIActor aiActor = healthHaver.aiActor; if (damagePlayers || !aiActor || aiActor.IsNormalEnemy) { HealthHaver healthHaver3 = healthHaver; Vector2 direction = vector; string enemiesString = StringTableManager.GetEnemiesString("#EXPLOSION", -1); CoreDamageTypes damageTypes = CoreDamageTypes.None; DamageCategory damageCategory = DamageCategory.Normal; healthHaver3.ApplyDamage(damage, direction, enemiesString, damageTypes, damageCategory, false, null, ignoreDamageCaps); flag2 = true; } } flag = true; } if (flag2 && hitVFX != null) { if (bodyRigidbody.HitboxPixelCollider != null) { PixelCollider pixelCollider = bodyRigidbody.GetPixelCollider(ColliderType.HitBox); Vector2 v = BraveMathCollege.ClosestPointOnRectangle(position, pixelCollider.UnitBottomLeft, pixelCollider.UnitDimensions); hitVFX.SpawnAtPosition(v, 0f, null, null, null, null, false, null, null, false); } else { hitVFX.SpawnAtPosition(healthHaver.transform.position.XY(), 0f, null, null, null, null, false, null, null, false); } } if (flag) { break; } } } } } } } } }
public static void DoRadialIgnite(GameActorFireEffect fire, Vector3 position, float radius, VFXPool hitVFX = null) { List <HealthHaver> allHealthHavers = StaticReferenceManager.AllHealthHavers; if (allHealthHavers != null) { float num = radius * radius; for (int i = 0; i < allHealthHavers.Count; i++) { HealthHaver healthHaver = allHealthHavers[i]; if (healthHaver) { if (healthHaver.gameObject.activeSelf) { if (healthHaver.aiActor) { AIActor aiActor = healthHaver.aiActor; if (!aiActor.IsGone) { if (aiActor.isActiveAndEnabled) { if ((aiActor.CenterPosition - position.XY()).sqrMagnitude <= num) { aiActor.ApplyEffect(fire, 1f, null); if (hitVFX != null) { if (aiActor.specRigidbody.HitboxPixelCollider != null) { PixelCollider pixelCollider = aiActor.specRigidbody.GetPixelCollider(ColliderType.HitBox); Vector2 v = BraveMathCollege.ClosestPointOnRectangle(position, pixelCollider.UnitBottomLeft, pixelCollider.UnitDimensions); hitVFX.SpawnAtPosition(v, 0f, null, null, null, null, false, null, null, false); } else { hitVFX.SpawnAtPosition(aiActor.CenterPosition, 0f, null, null, null, null, false, null, null, false); } } } } } } } } } } }
/// <summary> /// Used to create new VFX. Place sprites inside of Mods/YourModFolder/sprites/VFX Collection, inside the EtG directory. Each parameter that is a list must have an entry for each sprite of the animation /// </summary> /// <param name="name">The name of the VFX</param> /// <param name="spriteNames">The name of the sprites for the VFX, like VFX_001, VFX_002, etc.</param> /// <param name="fps">The frame rate the animation will play at</param> /// <param name="spriteSizes">The size of each sprite in the animation. Must have an IntVector2 entry for each sprite in the animation</param> /// <param name="anchors">I don't know what exactly this does</param> /// <param name="manualOffsets">I don't know what exactly this does</param> /// <param name="orphaned">I don't know what exactly this does</param> /// <param name="attached">I don't know what exactly this does</param> /// <param name="persistsOnDeath">Best left false</param> /// <param name="usesZHeight">Change if needed</param> /// <param name="zHeight">Change if needed, but usually left at 0</param> /// <param name="alignment">Leave at Fixed</param> /// <param name="destructible">Always set to true</param> /// <param name="emissivePowers">Doesn't seem to work, set all entries at 0. Might cause bugs if tinkered with</param> /// <param name="emissiveColors">Does't seem to work, set all entries to VFXLibrary.emptyColor. Might cause bugs if tinkered with</param> /// <returns></returns> public static VFXPool CreateMuzzleflash(string name, List <string> spriteNames, int fps, List <IntVector2> spriteSizes, List <tk2dBaseSprite.Anchor> anchors, List <Vector2> manualOffsets, bool orphaned, bool attached, bool persistsOnDeath, bool usesZHeight, float zHeight, VFXAlignment alignment, bool destructible, List <float> emissivePowers, List <Color> emissiveColors) { VFXPool pool = new VFXPool(); pool.type = VFXPoolType.All; VFXComplex complex = new VFXComplex(); VFXObject vfObj = new VFXObject(); GameObject obj = new GameObject(name); obj.SetActive(false); FakePrefab.MarkAsFakePrefab(obj); UnityEngine.Object.DontDestroyOnLoad(obj); tk2dSprite sprite = obj.AddComponent <tk2dSprite>(); tk2dSpriteAnimator animator = obj.AddComponent <tk2dSpriteAnimator>(); tk2dSpriteAnimationClip clip = new tk2dSpriteAnimationClip(); clip.fps = fps; clip.frames = new tk2dSpriteAnimationFrame[0]; for (int i = 0; i < spriteNames.Count; i++) { string spriteName = spriteNames[i]; IntVector2 spriteSize = spriteSizes[i]; tk2dBaseSprite.Anchor anchor = anchors[i]; Vector2 manualOffset = manualOffsets[i]; float emissivePower = emissivePowers[i]; Color emissiveColor = emissiveColors[i]; tk2dSpriteAnimationFrame frame = new tk2dSpriteAnimationFrame(); frame.spriteId = VFXCollection.GetSpriteIdByName(spriteName); tk2dSpriteDefinition def = SetupDefinitionForShellSprite(spriteName, frame.spriteId, spriteSize.x, spriteSize.y); def.ConstructOffsetsFromAnchor(anchor, def.position3); def.MakeOffset(manualOffset); def.material.shader = ShaderCache.Acquire("Brave/LitTk2dCustomFalloffTintableTiltedCutoutEmissive"); def.material.SetFloat("_EmissiveColorPower", emissivePower); def.material.SetColor("_EmissiveColor", emissiveColor); def.material.SetTexture("_MainTex", def.material.GetTexture("_MainTex")); def.materialInst.shader = ShaderCache.Acquire("Brave/LitTk2dCustomFalloffTintableTiltedCutoutEmissive"); def.materialInst.SetFloat("_EmissiveColorPower", emissivePower); def.materialInst.SetColor("_EmissiveColor", emissiveColor); def.materialInst.SetTexture("_MainTex", def.materialInst.GetTexture("_MainTex")); frame.spriteCollection = VFXCollection; clip.frames = clip.frames.Concat(new tk2dSpriteAnimationFrame[] { frame }).ToArray(); } sprite.renderer.material.shader = ShaderCache.Acquire("Brave/LitTk2dCustomFalloffTintableTiltedCutoutEmissive"); sprite.renderer.material.SetFloat("_EmissiveColorPower", emissivePowers[0]); sprite.renderer.material.SetColor("_EmissiveColor", emissiveColors[0]); sprite.renderer.material.SetTexture("_MainTex", sprite.renderer.material.GetTexture("_MainTex")); clip.wrapMode = tk2dSpriteAnimationClip.WrapMode.Once; clip.name = "start"; animator.spriteAnimator.Library = animator.gameObject.AddComponent <tk2dSpriteAnimation>(); animator.spriteAnimator.Library.clips = new tk2dSpriteAnimationClip[] { clip }; animator.spriteAnimator.Library.enabled = true; SpriteAnimatorKiller kill = animator.gameObject.AddComponent <SpriteAnimatorKiller>(); kill.fadeTime = -1f; kill.animator = animator; kill.delayDestructionTime = -1f; vfObj.orphaned = orphaned; vfObj.attached = attached; vfObj.persistsOnDeath = persistsOnDeath; vfObj.usesZHeight = usesZHeight; vfObj.zHeight = zHeight; vfObj.alignment = alignment; vfObj.destructible = destructible; vfObj.effect = obj; complex.effects = new VFXObject[] { vfObj }; pool.effects = new VFXComplex[] { complex }; animator.playAutomatically = true; animator.DefaultClipId = animator.GetClipIdByName("start"); return(pool); }
public static void Add() { Gun gun = ETGMod.Databases.Items.NewGun("Photon Blade", "Photon Blade"); Game.Items.Rename("outdated_gun_mods:photon_blade", "sts:photon_blade"); gun.gameObject.AddComponent <PhotonBlade>(); gun.SetShortDescription("Not Just The Children..."); gun.SetLongDescription("Slices with deadly power."); gun.SetupSprite(null, "photon_blade_idle_001", 8); gun.SetAnimationFPS(gun.shootAnimation, 10); gun.SetAnimationFPS(gun.reloadAnimation, 2); gun.AddProjectileModuleFrom("38_special", true, false); gun.DefaultModule.ammoType = GameUIAmmoType.AmmoType.SMALL_BULLET; gun.DefaultModule.ammoCost = 1; gun.DefaultModule.shootStyle = ProjectileModule.ShootStyle.SemiAutomatic; gun.DefaultModule.sequenceStyle = ProjectileModule.ProjectileSequenceStyle.Random; gun.reloadTime = 0f; gun.DefaultModule.angleVariance = 0f; gun.DefaultModule.cooldownTime = .5f; gun.DefaultModule.numberOfShotsInClip = 350; Gun gun2 = PickupObjectDatabase.GetById(151) as Gun; gun.muzzleFlashEffects.type = VFXPoolType.None; gun.SetBaseMaxAmmo(350); gun.barrelOffset.transform.localPosition = new Vector3(1.5f, 0f, 0f); gun.quality = PickupObject.ItemQuality.EXCLUDED; gun.encounterTrackable.EncounterGuid = "zwoooop."; gun.sprite.IsPerpendicular = true; gun.gunClass = GunClass.NONE; Projectile projectile = UnityEngine.Object.Instantiate <Projectile>(gun.DefaultModule.projectiles[0]); projectile.gameObject.SetActive(false); FakePrefab.MarkAsFakePrefab(projectile.gameObject); UnityEngine.Object.DontDestroyOnLoad(projectile); gun.DefaultModule.projectiles[0] = projectile; projectile.transform.parent = gun.barrelOffset; projectile.baseData.damage *= 3f; projectile.baseData.speed = 0; ProjectileSlashingBehaviour slashingBehaviour = projectile.gameObject.AddComponent <ProjectileSlashingBehaviour>(); slashingBehaviour.SlashDimensions = 90; slashingBehaviour.SlashRange = 2.5f; VFXPool SlashVFX = VFXLibrary.CreateMuzzleflash("photon_blade_slice", new List <string> { "katanaslice_001", "katanaslice_002", "katanaslice_003", }, 10, new List <IntVector2> { new IntVector2(72, 67), new IntVector2(72, 67), new IntVector2(72, 67), }, new List <tk2dBaseSprite.Anchor> { tk2dBaseSprite.Anchor.MiddleLeft, tk2dBaseSprite.Anchor.MiddleLeft, tk2dBaseSprite.Anchor.MiddleLeft }, new List <Vector2> { Vector2.zero, Vector2.zero, Vector2.zero }, false, false, false, false, 0, VFXAlignment.Fixed, true, new List <float> { 0, 0, 0 }, new List <Color> { VFXLibrary.emptyColor, VFXLibrary.emptyColor, VFXLibrary.emptyColor }); slashingBehaviour.SlashVFX = SlashVFX; ETGMod.Databases.Items.Add(gun, null, "ANY"); gun.AddToSubShop(ItemBuilder.ShopType.Goopton); gun.AddToSubShop(ItemBuilder.ShopType.Trorc); }