public override void Start() { ItemBuilder.Init(); CrossChamber.Init(); LichsBookItem.Init(); LichsGun.Init(); CustomSynergies.Add("Master of Gungeon", new List <string> { "spapi:lichs_gun", "spapi:lichs_book", "lichs_eye_bullets" }); CustomSynergies.Add("Baby Peacemaker", new List <string> { "spapi:cross_chamber", "magnum" }); Hook getNicknamehook = new Hook( typeof(StringTableManager).GetMethod("GetTalkingPlayerNick", BindingFlags.NonPublic | BindingFlags.Static), typeof(LichModule).GetMethod("GetTalkingPlayerNickHook") ); Hook getNamehook = new Hook( typeof(StringTableManager).GetMethod("GetTalkingPlayerName", BindingFlags.NonPublic | BindingFlags.Static), typeof(LichModule).GetMethod("GetTalkingPlayerNameHook") ); Hook getValueHook = new Hook( typeof(dfLanguageManager).GetMethod("GetValue", BindingFlags.Public | BindingFlags.Instance), typeof(LichModule).GetMethod("GetValueHook") ); ETGMod.StartGlobalCoroutine(this.DelayedStartCR()); }
public static void InitSynergyForm(Gun original) { Gun gun = ETGMod.Databases.Items.NewGun("Synergy Lich's Gun", "lichsgun2"); Game.Items.Rename("outdated_gun_mods:synergy_lich's_gun", "spapi:lichs_gun+master_of_the_gungeon"); GunExt.SetShortDescription(gun, "Bullet Dance"); GunExt.SetLongDescription(gun, "This is Gun from Gungeon Master."); GunExt.SetupSprite(gun, null, "lichsgun2_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 = 8f; projectile.shouldRotate = true; projectile.name = "LichsGun2_Projectile"; projectile.baseData.range = 40f; 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 = 17; 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)synergyFireOffsets[i].x) / 16f, ((float)synergyFireOffsets[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)synergyReloadOffsets[i].x) / 16f, ((float)synergyReloadOffsets[i].y) / 16f); LichsBookItem.MakeOffset(def, offset); } gun.gunSwitchGroup = "Colt1851"; gun.gunHandedness = GunHandedness.HiddenOneHanded; gun.muzzleFlashEffects = original.muzzleFlashEffects; gun.reloadTime = 1.1f; gun.SetBaseMaxAmmo(700); gun.quality = PickupObject.ItemQuality.SPECIAL; gun.barrelOffset.transform.localPosition = new Vector3(1.1875f, 0.5625f, 0f); gun.gunClass = GunClass.PISTOL; ETGMod.Databases.Items.Add(gun, null, "ANY"); AdvancedTransformGunSynergyProcessor processor = original.gameObject.AddComponent <AdvancedTransformGunSynergyProcessor>(); processor.NonSynergyGunId = original.PickupObjectId; processor.SynergyGunId = gun.PickupObjectId; processor.SynergyToCheck = "Master of Gungeon"; }
private void Update() { if (Dungeon.IsGenerating || Dungeon.ShouldAttemptToLoadFromMidgameSave) { return; } if (this.m_gun && this.m_gun.CurrentOwner is PlayerController) { PlayerController playerController = this.m_gun.CurrentOwner as PlayerController; if (!this.m_gun.enabled) { return; } if (LichsBookItem.PlayerHasActiveSynergy(playerController, this.SynergyToCheck) && !this.m_transformed) { this.m_transformed = true; this.m_gun.TransformToTargetGun(PickupObjectDatabase.GetById(this.SynergyGunId) as Gun); if (this.ShouldResetAmmoAfterTransformation) { this.m_gun.ammo = this.ResetAmmoCount; } } else if (!LichsBookItem.PlayerHasActiveSynergy(playerController, this.SynergyToCheck) && this.m_transformed) { this.m_transformed = false; this.m_gun.TransformToTargetGun(PickupObjectDatabase.GetById(this.NonSynergyGunId) as Gun); if (this.ShouldResetAmmoAfterTransformation) { this.m_gun.ammo = this.ResetAmmoCount; } } } else if (this.m_gun && !this.m_gun.CurrentOwner && this.m_transformed) { this.m_transformed = false; this.m_gun.TransformToTargetGun(PickupObjectDatabase.GetById(this.NonSynergyGunId) as Gun); if (this.ShouldResetAmmoAfterTransformation) { this.m_gun.ammo = this.ResetAmmoCount; } } this.ShouldResetAmmoAfterTransformation = false; }
public static void SetProjectileSpriteRight(Projectile proj, string name, int pixelWidth, int pixelHeight, bool lightened = true, tk2dBaseSprite.Anchor anchor = tk2dBaseSprite.Anchor.LowerLeft, bool anchorChangesCollider = true, bool fixesScale = false, int?overrideColliderPixelWidth = null, int?overrideColliderPixelHeight = null, int?overrideColliderOffsetX = null, int?overrideColliderOffsetY = null, Projectile overrideProjectileToCopyFrom = null) { try { proj.GetAnySprite().spriteId = ETGMod.Databases.Items.ProjectileCollection.inst.GetSpriteIdByName(name); tk2dSpriteDefinition def = SetupDefinitionForProjectileSprite(name, proj.GetAnySprite().spriteId, pixelWidth, pixelHeight, lightened, overrideColliderPixelWidth, overrideColliderPixelHeight, overrideColliderOffsetX, overrideColliderOffsetY, overrideProjectileToCopyFrom); LichsBookItem.ConstructOffsetsFromAnchor(def, anchor, def.position3, fixesScale, anchorChangesCollider); proj.GetAnySprite().scale = new Vector3(1f, 1f, 1f); proj.transform.localScale = new Vector3(1f, 1f, 1f); proj.GetAnySprite().transform.localScale = new Vector3(1f, 1f, 1f); proj.AdditionalScaleMultiplier = 1f; } catch (Exception ex) { ETGModConsole.Log("Ooops! Seems like something got very, Very, VERY wrong. Here's the exception:"); ETGModConsole.Log(ex.ToString()); } }
public static void BuildSynergyPrefab() { if (synergyPrefab == null && !CompanionBuilder.companionDictionary.ContainsKey("Synergy_Cross_Chamber")) { synergyPrefab = CompanionBuilder.BuildPrefab("Synergy Cross Chamber", "Synergy_Cross_Chamber", "LichItems/Resources/CrossChamber/IdleRight/tomb_idle_right_001", new IntVector2(0, 0), new IntVector2(14, 16)); var companion = synergyPrefab.AddComponent <CompanionController>(); PixelCollider collider = new PixelCollider(); collider.ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual; collider.CollisionLayer = CollisionLayer.PlayerHitBox; collider.ManualWidth = 14; collider.ManualHeight = 16; collider.ManualOffsetX = 0; collider.ManualOffsetY = 0; KnockbackDoer knockback = companion.gameObject.GetOrAddComponent <KnockbackDoer>(); knockback.weight = 100f; companion.aiActor.IsNormalEnemy = false; companion.CanInterceptBullets = true; companion.specRigidbody.PrimaryPixelCollider.CollisionLayer = CollisionLayer.PlayerCollider; companion.specRigidbody.PixelColliders.Add(collider); companion.gameObject.AddComponent <IgnoreEnemyCollisions>(); companion.specRigidbody.AddCollisionLayerIgnoreOverride(CollisionMask.LayerToMask(CollisionLayer.EnemyHitBox)); companion.specRigidbody.AddCollisionLayerIgnoreOverride(CollisionMask.LayerToMask(CollisionLayer.EnemyCollider)); companion.specRigidbody.CollideWithOthers = true; companion.aiActor.CollisionDamage = 0f; companion.aiActor.MovementSpeed = 3f; companion.aiActor.CanDropCurrency = false; companion.healthHaver.PreventAllDamage = false; GameObject gunAttachPointObject = new GameObject("GunAttachPoint"); FakePrefab.MarkAsFakePrefab(gunAttachPointObject); UnityEngine.Object.DontDestroyOnLoad(gunAttachPointObject); Transform gunAttachPoint = gunAttachPointObject.transform; gunAttachPoint.parent = synergyPrefab.transform; gunAttachPoint.localPosition = new Vector3(-0.1250f, 0.3125f, 0f); GameObject hand = SpriteBuilder.SpriteFromResource("LichItems/Resources/CrossChamber/Hand/hand_001", new GameObject("SynergyCrossChamberHand")); FakePrefab.MarkAsFakePrefab(hand); UnityEngine.Object.DontDestroyOnLoad(hand); LichsBookItem.ConstructOffsetsFromAnchor(hand.GetComponent <tk2dBaseSprite>().GetCurrentSpriteDef(), tk2dBaseSprite.Anchor.MiddleCenter); PlayerHandController handController = hand.AddComponent <PlayerHandController>(); handController.ForceRenderersOff = false; handController.attachPoint = null; handController.handHeightFromGun = 0.05f; SetupBasicAIShooter(synergyPrefab, 38 /*38 is the id of magnum*/, gunAttachPoint, hand); synergyPrefab.AddAnimation("idle_right", "LichItems/Resources/CrossChamber/IdleRight", 4, AnimationType.Idle, DirectionType.TwoWayHorizontal); synergyPrefab.AddAnimation("idle_left", "LichItems/Resources/CrossChamber/IdleLeft", 4, AnimationType.Idle, DirectionType.TwoWayHorizontal); synergyPrefab.AddAnimation("run_right", "LichItems/Resources/CrossChamber/MoveRight", 10, AnimationType.Move, DirectionType.TwoWayHorizontal); synergyPrefab.AddAnimation("run_left", "LichItems/Resources/CrossChamber/MoveLeft", 10, AnimationType.Move, DirectionType.TwoWayHorizontal); synergyPrefab.AddAnimation("hit_left", "LichItems/Resources/CrossChamber/HitLeft", 6, AnimationType.Hit, DirectionType.TwoWayHorizontal).wrapMode = tk2dSpriteAnimationClip.WrapMode.Once; synergyPrefab.AddAnimation("hit_right", "LichItems/Resources/CrossChamber/HitRight", 6, AnimationType.Hit, DirectionType.TwoWayHorizontal).wrapMode = tk2dSpriteAnimationClip.WrapMode.Once; BehaviorSpeculator component = CrossChamber.synergyPrefab.GetComponent <BehaviorSpeculator>(); component.MovementBehaviors.Add(new CompanionFollowPlayerBehavior { IdleAnimations = new string[] { "idle" }, DisableInCombat = false }); component.TargetBehaviors = new List <TargetBehaviorBase> { new TargetPlayerBehavior { Radius = 35f, LineOfSight = true, ObjectPermanence = true, SearchInterval = 0.25f, PauseOnTargetSwitch = false, PauseTime = 0.25f } }; component.AttackBehaviors = new List <AttackBehaviorBase> { new ShootGunBehavior() { GroupCooldownVariance = -1f, LineOfSight = true, WeaponType = WeaponType.AIShooterProjectile, OverrideBulletName = "default", BulletScript = null, FixTargetDuringAttack = false, StopDuringAttack = false, LeadAmount = 0f, LeadChance = 1f, RespectReload = true, MagazineCapacity = 6, ReloadSpeed = 2f, EmptiesClip = false, SuppressReloadAnim = false, TimeBetweenShots = -1f, PreventTargetSwitching = false, OverrideAnimation = string.Empty, OverrideDirectionalAnimation = string.Empty, HideGun = false, UseLaserSight = false, UseGreenLaser = false, PreFireLaserTime = -1f, AimAtFacingDirectionWhenSafe = false } }; AIBulletBank bulletBank = synergyPrefab.GetOrAddComponent <AIBulletBank>(); bulletBank.Bullets = new List <AIBulletBank.Entry> { new AIBulletBank.Entry() { Name = "default", OverrideProjectile = true, ProjectileData = new ProjectileData() { damage = 10f, speed = 16f, range = 60f, force = 20f, damping = 0f, UsesCustomAccelerationCurve = false, AccelerationCurve = null, CustomAccelerationCurveDuration = 0f, IgnoreAccelCurveTime = 0f, onDestroyBulletScript = null }, BulletObject = null } }; bulletBank.useDefaultBulletIfMissing = false; bulletBank.transforms = new List <Transform> { synergyPrefab.transform }; bulletBank.rampBullets = false; bulletBank.rampStartHeight = 0f; bulletBank.rampTime = 0f; bulletBank.OverrideGun = null; bulletBank.OnProjectileCreated = null; bulletBank.OnProjectileCreatedWithSource = null; bulletBank.FixedPlayerPosition = null; } }
private void CreateCompanion(PlayerController owner) { if (this.PreventRespawnOnFloorLoad) { return; } if (this.BabyGoodMimicOrbitalOverridden) { GameObject extantCompanion = PlayerOrbitalItem.CreateOrbital(owner, (!this.OverridePlayerOrbitalItem.OrbitalFollowerPrefab) ? this.OverridePlayerOrbitalItem.OrbitalPrefab.gameObject : this.OverridePlayerOrbitalItem.OrbitalFollowerPrefab.gameObject, this.OverridePlayerOrbitalItem.OrbitalFollowerPrefab, null); this.SetExtantCompanion(extantCompanion); return; } string guid = this.CompanionGuid; this.m_lastActiveSynergyTransformation = -1; if (this.UsesAlternatePastPrefab && GameManager.Instance.CurrentLevelOverrideState == GameManager.LevelOverrideState.CHARACTER_PAST) { guid = this.CompanionPastGuid; } else { if (this.UseAdvancedSynergies && this.AdvancedSynergies.Length > 0) { for (int i = 0; i < this.AdvancedSynergies.Length; i++) { if ((this.AdvancedSynergies[i].UseStringSynergyDetectionInstead && LichsBookItem.PlayerHasActiveSynergy(this.m_owner, this.AdvancedSynergies[i].RequiredStringSynergy)) || (!this.AdvancedSynergies[i].UseStringSynergyDetectionInstead && owner.HasActiveBonusSynergy(this.AdvancedSynergies[i].RequiredSynergy, false))) { guid = this.AdvancedSynergies[i].SynergyCompanionGuid; this.m_lastActiveSynergyTransformation = i; } } } else if (this.Synergies.Length > 0) { for (int i = 0; i < this.Synergies.Length; i++) { if (owner.HasActiveBonusSynergy(this.Synergies[i].RequiredSynergy, false)) { guid = this.Synergies[i].SynergyCompanionGuid; this.m_lastActiveSynergyTransformation = i; } } } } AIActor orLoadByGuid = EnemyDatabase.GetOrLoadByGuid(guid); Vector3 vector = owner.transform.position; if (GameManager.Instance.CurrentLevelOverrideState == GameManager.LevelOverrideState.FOYER) { vector += new Vector3(1.125f, -0.3125f, 0f); } GameObject extantCompanion2 = UnityEngine.Object.Instantiate <GameObject>(orLoadByGuid.gameObject, vector, Quaternion.identity); this.SetExtantCompanion(extantCompanion2); CompanionController orAddComponent = this.ExtantCompanion.GetOrAddComponent <CompanionController>(); orAddComponent.Initialize(owner); if (orAddComponent.specRigidbody) { PhysicsEngine.Instance.RegisterOverlappingGhostCollisionExceptions(orAddComponent.specRigidbody, null, false); } if (orAddComponent.companionID == CompanionController.CompanionIdentifier.BABY_GOOD_MIMIC) { GameStatsManager.Instance.SetFlag(GungeonFlags.ITEMSPECIFIC_GOT_BABY_MIMIC, true); } }
protected override void Update() { base.Update(); if (!Dungeon.IsGenerating && this.m_owner && this.UseAdvancedSynergies && this.AdvancedSynergies.Length > 0) { if (!this.UsesAlternatePastPrefab || GameManager.Instance.CurrentLevelOverrideState != GameManager.LevelOverrideState.CHARACTER_PAST) { bool flag = false; for (int i = this.AdvancedSynergies.Length - 1; i >= 0; i--) { if ((this.AdvancedSynergies[i].UseStringSynergyDetectionInstead && LichsBookItem.PlayerHasActiveSynergy(this.m_owner, this.AdvancedSynergies[i].RequiredStringSynergy)) || (!this.AdvancedSynergies[i].UseStringSynergyDetectionInstead && this.m_owner.HasActiveBonusSynergy(this.AdvancedSynergies[i].RequiredSynergy, false))) { if (this.m_lastActiveSynergyTransformation != i) { this.DestroyCompanion(); this.CreateCompanion(this.m_owner); } flag = true; break; } } if (!flag && this.m_lastActiveSynergyTransformation != -1) { this.DestroyCompanion(); this.CreateCompanion(this.m_owner); } } } }
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); }
private static void BuildLibrary(LichsBookItem targetBook) { List <string> spriteNames = new List <string>(); string[] resources = ResourceExtractor.GetResourceNames(); string spriteDirectory = "LichItems/Resources/InfinilichTransformation"; for (int i = 0; i < resources.Length; i++) { if (resources[i].StartsWith(spriteDirectory.Replace('/', '.'), StringComparison.OrdinalIgnoreCase)) { spriteNames.Add(resources[i]); } } List <Texture2D> sprites = new List <Texture2D>(); foreach (string name in spriteNames) { sprites.Add(ResourceExtractor.GetTextureFromResource(name)); } tk2dSpriteAnimation library = Instantiate((PickupObjectDatabase.GetById(163) as BulletArmorItem).knightLibrary); DontDestroyOnLoad(library); var orig = library.clips[0].frames[0].spriteCollection; var copyCollection = Instantiate(orig); tk2dSpriteDefinition copydef = CopyDefinitionFrom((PickupObjectDatabase.GetById(607) as BankMaskItem).OverrideHandSprite.GetCurrentSpriteDef()); copydef.name = "knight_hand_001"; int handId = SpriteBuilder.AddSpriteToCollection(copydef, copyCollection); DontDestroyOnLoad(copyCollection); RuntimeAtlasPage page = new RuntimeAtlasPage(); for (int i = 0; i < sprites.Count; i++) { var tex = sprites[i]; var def = copyCollection.GetSpriteDefinition(tex.name); if (def != null) { def.ReplaceTexture(tex); def.name = def.name.Replace("knight", "inflich"); MakeOffset(def, new Vector2(-0.0625f, 0f), false); } } page.Apply(); foreach (var clip in library.clips) { for (int i = 0; i < clip.frames.Length; i++) { clip.frames[i].spriteCollection = copyCollection; } } foreach (tk2dSpriteAnimationClip clip in library.clips) { foreach (tk2dSpriteAnimationFrame frame in clip.frames) { if (!string.IsNullOrEmpty(frame.eventAudio) && (frame.eventAudio == "Play_FS" || frame.eventAudio == "Play_CHR_boot_stairs_01")) { frame.eventAudio = ""; } } } GameObject spriteObj = new GameObject("OverrideHandSprite"); spriteObj.SetActive(false); DontDestroyOnLoad(spriteObj); tk2dSprite sprite = spriteObj.AddComponent <tk2dSprite>(); sprite.SetSprite(copyCollection, handId); targetBook.replacementHandSprite = sprite; targetBook.replacementLibrary = library; }