protected override void PostProcessBeam(BeamController beam) { if (beam && beam.projectile && beam.projectile.ProjectilePlayerOwner()) { if (beam.projectile.ProjectilePlayerOwner().PlayerHasActiveSynergy("It won't actually show up on screen, but there's no hard limit on how long you can make synergy names.")) { beam.AdjustPlayerBeamTint(Color.green, 1); beam.projectile.fireEffect = StaticStatusEffects.greenFireEffect; } if (beam.projectile.ProjectilePlayerOwner().PlayerHasActiveSynergy("Re-Heat")) { beam.GetComponent <BasicBeamController>().TimeToStatus = 0.1f; beam.GetComponent <BasicBeamController>().statusEffectChance = 1f; } if (beam.projectile.ProjectilePlayerOwner().PlayerHasActiveSynergy("Don't Trust The Toaster")) { beam.projectile.baseData.speed *= 5; beam.projectile.UpdateSpeed(); beam.projectile.RuntimeUpdateScale(1.3f); beam.projectile.baseData.damage *= 2; EmmisiveBeams emission = beam.projectile.gameObject.GetOrAddComponent <EmmisiveBeams>(); } } base.PostProcessBeam(beam); }
public static BasicBeamController GenerateBeamPrefab(this Projectile projectile, string spritePath, Vector2 colliderDimensions, Vector2 colliderOffsets, List <string> beamAnimationPaths = null, int beamFPS = -1, List <string> impactVFXAnimationPaths = null, int beamImpactFPS = -1, Vector2?impactVFXColliderDimensions = null, Vector2?impactVFXColliderOffsets = null, List <string> endVFXAnimationPaths = null, int beamEndFPS = -1, Vector2?endVFXColliderDimensions = null, Vector2?endVFXColliderOffsets = null, List <string> muzzleVFXAnimationPaths = null, int beamMuzzleFPS = -1, Vector2?muzzleVFXColliderDimensions = null, Vector2?muzzleVFXColliderOffsets = null, float glowAmount = 0, float emissivecolouramt = 0) { try { projectile.specRigidbody.CollideWithOthers = false; float convertedColliderX = colliderDimensions.x / 16f; float convertedColliderY = colliderDimensions.y / 16f; float convertedOffsetX = colliderOffsets.x / 16f; float convertedOffsetY = colliderOffsets.y / 16f; int spriteID = SpriteBuilder.AddSpriteToCollection(spritePath, ETGMod.Databases.Items.ProjectileCollection); tk2dTiledSprite tiledSprite = projectile.gameObject.GetOrAddComponent <tk2dTiledSprite>(); tiledSprite.SetSprite(ETGMod.Databases.Items.ProjectileCollection, spriteID); tk2dSpriteDefinition def = tiledSprite.GetCurrentSpriteDef(); def.colliderVertices = new Vector3[] { new Vector3(convertedOffsetX, convertedOffsetY, 0f), new Vector3(convertedColliderX, convertedColliderY, 0f) }; def.ConstructOffsetsFromAnchor(tk2dBaseSprite.Anchor.MiddleLeft); //tiledSprite.anchor = tk2dBaseSprite.Anchor.MiddleCenter; tk2dSpriteAnimator animator = projectile.gameObject.GetOrAddComponent <tk2dSpriteAnimator>(); tk2dSpriteAnimation animation = projectile.gameObject.GetOrAddComponent <tk2dSpriteAnimation>(); animation.clips = new tk2dSpriteAnimationClip[0]; animator.Library = animation; UnityEngine.Object.Destroy(projectile.GetComponentInChildren <tk2dSprite>()); BasicBeamController beamController = projectile.gameObject.GetOrAddComponent <BasicBeamController>(); projectile.sprite = tiledSprite; //---------------- Sets up the animation for the main part of the beam if (beamAnimationPaths != null) { tk2dSpriteAnimationClip clip = new tk2dSpriteAnimationClip() { name = "beam_idle", frames = new tk2dSpriteAnimationFrame[0], fps = beamFPS }; List <string> spritePaths = beamAnimationPaths; List <tk2dSpriteAnimationFrame> frames = new List <tk2dSpriteAnimationFrame>(); foreach (string path in spritePaths) { tk2dSpriteCollectionData collection = ETGMod.Databases.Items.ProjectileCollection; int frameSpriteId = SpriteBuilder.AddSpriteToCollection(path, collection); tk2dSpriteDefinition frameDef = collection.spriteDefinitions[frameSpriteId]; frameDef.ConstructOffsetsFromAnchor(tk2dBaseSprite.Anchor.MiddleLeft); frameDef.colliderVertices = def.colliderVertices; frames.Add(new tk2dSpriteAnimationFrame { spriteId = frameSpriteId, spriteCollection = collection }); } clip.frames = frames.ToArray(); animation.clips = animation.clips.Concat(new tk2dSpriteAnimationClip[] { clip }).ToArray(); beamController.beamAnimation = "beam_idle"; } //------------- Sets up the animation for the part of the beam that touches the wall if (endVFXAnimationPaths != null && endVFXColliderDimensions != null && endVFXColliderOffsets != null) { SetupBeamPart(animation, endVFXAnimationPaths, "beam_end", beamEndFPS, (Vector2)endVFXColliderDimensions, (Vector2)endVFXColliderOffsets); beamController.beamEndAnimation = "beam_end"; } else { SetupBeamPart(animation, beamAnimationPaths, "beam_end", beamFPS, null, null, def.colliderVertices); beamController.beamEndAnimation = "beam_end"; } //---------------Sets up the animaton for the VFX that plays over top of the end of the beam where it hits stuff if (impactVFXAnimationPaths != null && impactVFXColliderDimensions != null && impactVFXColliderOffsets != null) { SetupBeamPart(animation, impactVFXAnimationPaths, "beam_impact", beamImpactFPS, (Vector2)impactVFXColliderDimensions, (Vector2)impactVFXColliderOffsets); beamController.impactAnimation = "beam_impact"; } //--------------Sets up the animation for the very start of the beam if (muzzleVFXAnimationPaths != null && muzzleVFXColliderDimensions != null && muzzleVFXColliderOffsets != null) { SetupBeamPart(animation, muzzleVFXAnimationPaths, "beam_start", beamMuzzleFPS, (Vector2)muzzleVFXColliderDimensions, (Vector2)muzzleVFXColliderOffsets); beamController.beamStartAnimation = "beam_start"; } else { SetupBeamPart(animation, beamAnimationPaths, "beam_start", beamFPS, null, null, def.colliderVertices); beamController.beamStartAnimation = "beam_start"; } if (glowAmount > 0) { EmmisiveBeams emission = projectile.gameObject.GetOrAddComponent <EmmisiveBeams>(); emission.EmissivePower = glowAmount; if (emissivecolouramt != 0) { emission.EmissiveColorPower = emissivecolouramt; } //emission } return(beamController); } catch (Exception e) { ETGModConsole.Log(e.ToString()); return(null); } }