public void Play(string name) { if (_animations.ContainsKey(name)) { CurrentAnimation = _animations[name]; CurrentAnimation.ResetAnimation(); } }
public override void PostAI() { base.PostAI(); if (CurrentState == TIMESTOP_ANIMATION) { if (CurrentAnimation.CurrentFrame == 10) { TimeStopDelay = 4; } if (CurrentAnimation.Finished) { CurrentAnimation.ResetAnimation(); CurrentState = ANIMATION_IDLE; } } }
public override void AI() { base.AI(); Opacity = 1f; projectile.Center = Owner.Center + new Vector2(34 * Owner.direction, -10 + Owner.gfxOffY); IsFlipped = Owner.direction == 1; if (CurrentState == ANIMATION_SUMMON) { if (InstantEnvironment == null && Owner == Main.LocalPlayer) { InstantEnvironment = new InstantEnvironment(); } if (!InitialSummonComplete) { Opacity = CurrentAnimation.FrameRect.Y / CurrentAnimation.FrameRect.Height * 0.25f; } if (CurrentAnimation.Finished) { InitialSummonComplete = true; CurrentState = ANIMATION_IDLE; } } projectile.timeLeft = 200; if (Owner.IsLocalPlayer()) { if (TBAInputs.SummonStand.JustPressed && CurrentState == ANIMATION_IDLE) { CurrentState = ANIMATION_DESPAWN; } if (TBAInputs.ContextAction.JustPressed && CurrentState == ANIMATION_IDLE) { UIManager.RATMState.Visible = true; } if (TBAInputs.StandPose.JustPressed && CurrentState == ANIMATION_IDLE) { if (!InstantEnvironment.CompileAssembly(Path.Combine(Main.SavePath, "Mods", "Cache", "TBA"))) { CurrentState = ANIMATION_ERROR; } } if (TBAInputs.ExtraAction01.JustPressed && CurrentState == ANIMATION_IDLE) { InstantEnvironment?.Run(TBAPlayer.Get(Owner)); } if (TBAInputs.ExtraAction02.JustPressed && CurrentState == ANIMATION_IDLE) { InstantEnvironment?.Selected?.Stop(); } } if (CurrentState == ANIMATION_ERROR && _errorLoopCount < ERROR_LOOP_COUNT) { if (CurrentAnimation.Finished) { _errorLoopCount++; CurrentAnimation.ResetAnimation(); } if (_errorLoopCount == 1) { _errorLoopCount = 0; CurrentState = ANIMATION_SUMMON; CurrentAnimation.ResetAnimation(); } } if (CurrentState == ANIMATION_DESPAWN) { Opacity = (Animations[ANIMATION_DESPAWN].FrameCount - CurrentAnimation.FrameRect.Y / (int)CurrentAnimation.FrameSize.Y) * 0.2f; if (CurrentAnimation.Finished) { KillStand(); } } }
public override void AI() { base.AI(); if (Animations.Count <= 0) { return; } OwnerCtrlUse = Owner.controlUseTile; projectile.width = (int)CurrentAnimation.FrameSize.X; projectile.height = (int)CurrentAnimation.FrameSize.Y; IsFlipped = Owner.direction == 1; projectile.timeLeft = 200; projectile.friendly = true; if (Owner.whoAmI == Main.myPlayer) { /*if (TBAInputs.StandPose.JustPressed) * if (CurrentState == ANIMATION_IDLE) * IsTaunting = true; * else * IsTaunting = false;*/ if (TBAInputs.SummonStand.JustPressed && InIdleState) { CurrentState = ANIMATION_DESPAWN; } } int xOffset = IsTaunting || CurrentState.Contains("PUNCH") || CurrentState.Contains("ATT") || CurrentState == "DONUT_UNDO" || CurrentState == "DONUT_MISS" || RushTimer > 0? 34 : -16; int yOffset = CurrentState.Contains("POSE") ? 36 : 0; xOffset = CurrentState.Contains("POSE") ? 24 : xOffset; PositionOffset = Owner.Center + new Vector2(xOffset * Owner.direction, -24 + Owner.gfxOffY + yOffset); projectile.Center = Vector2.Lerp(projectile.Center, PositionOffset, 0.26f); if (CurrentState == ANIMATION_SUMMON) { Opacity = 1; } #region Punching if (InIdleState) { if (TBAInputs.StandPose.JustPressed && Owner.whoAmI == Main.myPlayer) { CurrentState = "POSE_PREP"; } if (StopsItemUse) { if (PunchCounter < 2) { projectile.netUpdate = true; if (TBAPlayer.Get(Owner).MouseOneTimeReset > 0) { if (TBAPlayer.Get(Owner).MouseOneTime < 15 && !Owner.controlUseItem) { TBAPlayer.Get(Owner).Stamina -= 2; Owner.direction = Main.MouseWorld.X < Owner.Center.X ? -1 : 1; if (Main.MouseWorld.Y > Owner.Center.Y + 60) { CurrentState = "PUNCH_" + (Main.rand.NextBool() ? "R" : "L") + "D"; } else if (Main.MouseWorld.Y < Owner.Center.Y - 60) { CurrentState = "PUNCH_" + (Main.rand.NextBool() ? "R" : "L") + "U"; } else { CurrentState = "PUNCH_" + (Main.rand.NextBool() ? "R" : "L"); } PunchCounter++; PunchCounterReset = 28; Projectile.NewProjectile(projectile.Center, VectorHelpers.DirectToMouse(projectile.Center, 22f), ModContent.ProjectileType <Punch>(), 60, 3.5f, Owner.whoAmI, projectile.whoAmI); } if (TBAPlayer.Get(Owner).MouseOneTime >= 15) { TBAPlayer.Get(Owner).Stamina -= 10; Owner.direction = Main.MouseWorld.X < Owner.Center.X ? -1 : 1; CurrentState = "CUT_PREP"; } } } else if (Owner.controlUseItem) { projectile.netUpdate = true; TBAPlayer.Get(Owner).CheckStaminaCost(16, true); if (Main.MouseWorld.Y > Owner.Center.Y + 60) { CurrentState = "RUSH_DOWN"; } else if (Main.MouseWorld.Y < Owner.Center.Y - 60) { CurrentState = "RUSH_UP"; } else { CurrentState = "RUSH_MID"; } RushTimer = 180; PunchRushDirection = VectorHelpers.DirectToMouse(projectile.Center, 18f); TBAPlayer.Get(Owner).AttackDirectionResetTimer = RushTimer; TBAPlayer.Get(Owner).AttackDirection = Main.MouseWorld.X < projectile.Center.X ? -1 : 1; int barrage = Projectile.NewProjectile(projectile.Center, PunchRushDirection, ModContent.ProjectileType <CrimsonBarrage>(), 60, 0, Owner.whoAmI); if (Main.projectile[barrage].modProjectile is CrimsonBarrage crimsonBarrage) { crimsonBarrage.RushDirection = PunchRushDirection; crimsonBarrage.ParentProjectile = projectile.whoAmI; } } } } #endregion #region Rush Animations["RUSH_DOWN"].AutoLoop = RushTimer > 0; Animations["RUSH_UP"].AutoLoop = RushTimer > 0; Animations["RUSH_MID"].AutoLoop = RushTimer > 0; #endregion if (CurrentState.Contains("PUNCH") || CurrentState.Contains("ATT") || CurrentState.Contains("UNDO") || CurrentState == "DONUT_MISS") { Owner.heldProj = projectile.whoAmI; } #region Yeet attacc // If we do a YEET attack, damage is dealt by stand itself instead of a seperate projectile bool yeeting = CurrentState == "CUT_ATT" && CurrentAnimation.CurrentFrame > 3 && CurrentAnimation.CurrentFrame < 9; bool donuting = CurrentState == "DONUT_ATT" && CurrentAnimation.CurrentFrame == 3; projectile.damage = yeeting ? 400 : 0; if (donuting && Owner.ownedProjectileCounts[ModContent.ProjectileType <DonutPunch>()] <= 1) { Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType <DonutPunch>(), 60, 0, Owner.whoAmI, projectile.whoAmI, -1); } if (CurrentState == "CUT_IDLE" && !Owner.controlUseItem) { CurrentAnimation.ResetAnimation(); CurrentState = "CUT_ATT"; } #endregion if (StopsItemUse && TBAPlayer.Get(Owner).MouseTwoTime > 20 && InIdleState) { TBAPlayer.Get(Owner).CheckStaminaCost(10, true); CurrentState = "DONUT_PREP"; } if (CurrentState == "DONUT_IDLE" && !OwnerCtrlUse) { CurrentAnimation.ResetAnimation(); CurrentState = "DONUT_ATT"; } Animations["DONUT_UNDO"].FrameSpeed = Animations["DONUT_UNDO"].CurrentFrame < 5 ? 12 : 5; if (InIdleState && CurrentAnimation.Finished) { CurrentAnimation.ResetAnimation(); } if (CurrentState == ANIMATION_DESPAWN) { Opacity = (5 - CurrentAnimation.FrameRect.Y / (int)CurrentAnimation.FrameSize.Y) * 0.2f; if (CurrentAnimation.Finished) { KillStand(); } } if (InIdleState) { HasMissedDonut = true; } if (CurrentState == "DONUT_ATT") { Animations["DONUT_ATT"].SetNextAnimation(HasMissedDonut ? Animations["DONUT_MISS"] : Animations["DONUT_UNDO"]); } if (TBAInputs.ContextAction.JustPressed && Owner.whoAmI == Main.myPlayer && !CurrentState.Contains("RUSH")) { EraseTime(); } if (TBAInputs.StandPose.JustPressed && Owner.whoAmI == Main.myPlayer && CurrentState == "POSE_IDLE") { CurrentState = "POSE_END"; } if (CurrentState.Contains("POSE")) { Owner.heldProj = projectile.whoAmI; } }
public override bool PreAI() { projectile.timeLeft = 200; if (CurrentState != LastState) { projectile.netUpdate = true; } if (!ReverseOffset) { if (DrawOffset < 5.0f) { DrawOffset += 0.1f; } else { ReverseOffset = true; } } else { if (DrawOffset > 0.0f) { DrawOffset -= 0.1f; } else { ReverseOffset = false; } } if (DrawRotation < MathHelper.Pi) { DrawRotation += 0.07f; } else { DrawRotation = 0.0f; } LastState = CurrentState; if (TBAPlayer.Get(Owner).ActiveStandProjectile != projectile.modProjectile) { KillStand(); } if (Main.dedServ) { return(false); } if (TBAPlayer.Get(Owner).Stamina <= 0) { ShouldDie = true; } if (!HasSetAnimations) { AddAnimations(); if (Animations.Count >= 1) { Width = (int)Animations[CurrentState].FrameSize.X; Height = (int)Animations[CurrentState].FrameSize.Y; } HasSetAnimations = true; } if (ShouldDie && CanDie && CurrentState != ANIMATION_DESPAWN) { CurrentState = ANIMATION_DESPAWN; } if (Animations.Count >= 1 && !TimeStopManagement.projectileStates.ContainsKey(projectile)) { Animations[CurrentState].Update(); SpriteAnimation nextAnimation = CurrentAnimation.NextAnimation; bool reverseAnimation = CurrentAnimation.ReverseNextAnimation; if (CurrentAnimation.Finished && nextAnimation != null && Animations.ContainsValue(nextAnimation)) { CurrentAnimation.ResetAnimation(CurrentAnimation.ReversePlayback); CurrentState = Animations.Where(x => x.Value == nextAnimation).Select(x => x.Key).First(); CurrentAnimation.ResetAnimation(reverseAnimation); } } if (Owner.dead || !Owner.active) { KillStand(); } return(true); }
public override void AI() { base.AI(); IsFlipped = Owner.direction == 1; if (Animations.Count > 0) { Animations["RUSH_DOWN"].AutoLoop = RushTimer > 0; Animations["RUSH_UP"].AutoLoop = RushTimer > 0; Animations["RUSH_MID"].AutoLoop = RushTimer > 0; } if (CurrentState == ANIMATION_SUMMON) { Width = Height = 40; if (CurrentAnimation.CurrentFrame < 9) { IsFlipped = Owner.direction == -1; } Opacity = 1f; XPosOffset = 18; YPosOffset = -24; } PositionOffset = Owner.Center + new Vector2(XPosOffset * -Owner.direction, YPosOffset); projectile.Center = Vector2.Lerp(projectile.Center, PositionOffset, 0.26f); if (CurrentState == ANIMATION_DESPAWN) { Opacity -= 0.12f; YPosOffset += 4; XPosOffset -= 3; if (CurrentAnimation.Finished) { KillStand(); } } if (InIdleState) { XPosOffset = 18; } if (CurrentState.Contains("SLASH") || CurrentState.Contains("RUSH")) { XPosOffset = -32; } #region controls if (Owner.whoAmI == Main.myPlayer) { if (InIdleState) { if (TBAInputs.SummonStand.JustPressed) { CurrentState = ANIMATION_DESPAWN; } if (PunchCounter < 2) { if (TBAPlayer.Get(Owner).MouseOneTimeReset > 0) { projectile.netUpdate = true; if (TBAPlayer.Get(Owner).MouseOneTime < 15 && !Owner.controlUseItem) { TBAPlayer.Get(Owner).CheckStaminaCost(2, true); Owner.direction = Main.MouseWorld.X < Owner.Center.X ? -1 : 1; string useAlt = (Main.rand.NextBool() ? "" : "ALT"); if (Main.MouseWorld.Y > Owner.Center.Y + 60) { CurrentState = "SLASH_DOWN" + useAlt; } else if (Main.MouseWorld.Y < Owner.Center.Y - 60) { CurrentState = "SLASH_UP" + useAlt; } else { CurrentState = "SLASH_MID" + useAlt; } PunchCounter++; PunchCounterReset = 28; Projectile.NewProjectile(projectile.Center, VectorHelpers.DirectToMouse(projectile.Center, 32f), ModContent.ProjectileType <Punch>(), 80, 3.5f, Owner.whoAmI, projectile.whoAmI); CurrentAnimation.ResetAnimation(); } } } else if (Owner.controlUseItem) { projectile.netUpdate = true; TBAPlayer.Get(Owner).CheckStaminaCost(16); if (Main.MouseWorld.Y > Owner.Center.Y + 60) { CurrentState = "RUSH_DOWN"; } else if (Main.MouseWorld.Y < Owner.Center.Y - 60) { CurrentState = "RUSH_UP"; } else { CurrentState = "RUSH_MID"; } RushTimer = 180; PunchRushDirection = VectorHelpers.DirectToMouse(projectile.Center, 22f); TBAPlayer.Get(Owner).AttackDirectionResetTimer = RushTimer; TBAPlayer.Get(Owner).AttackDirection = Main.MouseWorld.X < projectile.Center.X ? -1 : 1; int barrage = Projectile.NewProjectile(projectile.Center, PunchRushDirection, ModContent.ProjectileType <ChariotBarrage>(), 60, 0, Owner.whoAmI); if (Main.projectile[barrage].modProjectile is ChariotBarrage silverBarrage) { silverBarrage.RushDirection = PunchRushDirection; silverBarrage.ParentProjectile = projectile.whoAmI; } } } } #endregion }
public void Punching(bool left) { if (PunchCounter < 2) { TBAPlayer.Get(Owner).CheckStaminaCost(2); if (Main.MouseWorld.Y > Owner.Center.Y + 60) { CurrentState = left ? "DOWNPUNCH_LEFTHAND" : "DOWNPUNCH_RIGHTHAND"; } else if (Main.MouseWorld.Y < Owner.Center.Y - 60) { CurrentState = left ? "UPPUNCH_LEFTHAND" : "UPPUNCH_RIGHTHAND"; } else { CurrentState = left ? "MIDDLEPUNCH_LEFTHAND" : "MIDDLEPUNCH_RIGHTHAND"; } SpawnPunch(); SetOwnerDirection(); PunchCounter++; PunchCounterReset = 26; IsPunching = true; CurrentAnimation.ResetAnimation(); } else { TBAPlayer.Get(Owner).CheckStaminaCost(16, true); TBAMod.PlayVoiceLine("Sounds/StarPlatinum/Ora"); if (Main.MouseWorld.Y > Owner.Center.Y + 60) { CurrentState = "RUSH_DOWN"; } else if (Main.MouseWorld.Y < Owner.Center.Y - 60) { CurrentState = "RUSH_UP"; } else { CurrentState = "RUSH_MIDDLE"; } PunchCounter = 0; PunchCounterReset = 0; PunchRushDirection = VectorHelpers.DirectToMouse(projectile.Center, 18f); RushTimer = 180; int barrage = Projectile.NewProjectile(projectile.Center, PunchRushDirection, ModContent.ProjectileType <StarBarrage>(), 60, 0, Owner.whoAmI); if (Main.projectile[barrage].modProjectile is StarBarrage starBarrage) { starBarrage.RushDirection = PunchRushDirection; starBarrage.ParentProjectile = projectile.whoAmI; } SetOwnerDirection(180); CurrentAnimation.ResetAnimation(); } }
public override void AI() { base.AI(); Penetrate = -1; projectile.friendly = true; if (Animations.Count <= 0) { return; } if (CurrentState == ANIMATION_SUMMON) { if (CurrentAnimation.CurrentFrame < 3) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/StarPlatinum/SP_Spawn")); } Opacity = CurrentAnimation.FrameRect.Y / CurrentAnimation.FrameRect.Height * 0.25f; XPosOffset = -16; YPosOffset = -24; } if (InIdleState) { XPosOffset = -16; } #region Rush if (Animations.Count > 0) { Animations["RUSH_DOWN"].AutoLoop = RushTimer > 0; Animations["RUSH_UP"].AutoLoop = RushTimer > 0; Animations["RUSH_MIDDLE"].AutoLoop = RushTimer > 0; } #endregion TimeLeft = 200; // Runs on clients only if (Owner.whoAmI == Main.myPlayer) { if (TBAInputs.StandPose.JustPressed) { if (CurrentState == ANIMATION_IDLE) { IsTaunting = true; } else { IsTaunting = false; } } if (TBAInputs.SummonStand.JustPressed && CurrentState == ANIMATION_IDLE) { CurrentState = ANIMATION_DESPAWN; } if (TBAInputs.ContextAction.JustPressed && InIdleState) { TimeStop(); } } if (IsPunching || RushTimer > 0 || CurrentState.Contains("POSE") || CurrentState == "DONUT_PUNCH" || CurrentState == "DONUT_PULL" || CurrentState == TIMESTOP_ANIMATION) { XPosOffset = 34; } if (CurrentState == "DONUT_PUNCH" || CurrentState == "DONUT_PULL" || CurrentState == TIMESTOP_ANIMATION) { Owner.heldProj = projectile.whoAmI; } if (CurrentState == "DONUT_PUNCH" && CurrentAnimation.CurrentFrame == 4) { TBAMod.PlayVoiceLine("Sounds/StarPlatinum/Donut"); } if (CurrentState == "DONUT_PUNCH" && CurrentAnimation.CurrentFrame > 4) { Damage = 350; } else { Damage = 0; } if (CurrentState.Contains("BLOCK")) { Owner.heldProj = projectile.whoAmI; PositionOffset = Owner.Center + new Vector2(6 * Owner.direction, YPosOffset + Owner.gfxOffY); } else { PositionOffset = Owner.Center + new Vector2(XPosOffset * Owner.direction, YPosOffset + Owner.gfxOffY); } if (CurrentState.Contains("PUNCH")) { Owner.heldProj = projectile.whoAmI; } Center = Vector2.Lerp(projectile.Center, PositionOffset, 0.26f); if (IsTaunting) { if (!CurrentState.Contains("POSE")) { CurrentState = "POSE_TRANSITION"; CurrentAnimation.ResetAnimation(); } } if (!CurrentState.Contains("PUNCH")) { IsPunching = false; } #region Punch if (StopsItemUse) { if (InIdleState && TBAPlayer.Get(Owner).MouseOneTimeReset > 0 && TBAPlayer.Get(Owner).MouseOneTime < 15 && !Owner.controlUseItem) { projectile.netUpdate = true; Punching(Main.rand.Next(2) == 0); } } #endregion if (CurrentState == ANIMATION_DESPAWN) { Opacity = (5 - CurrentAnimation.FrameRect.Y / (int)CurrentAnimation.FrameSize.Y) * 0.2f; XPosOffset += 1; YPosOffset += 0.75f; if (CurrentAnimation.Finished) { KillStand(); } } if (CurrentState == ANIMATION_IDLE && Owner.controlDown) { CurrentState = "BLOCK_TRANSITION"; CurrentAnimation.ResetAnimation(); } IsFlipped = Owner.direction == 1; if (projectile.active) { Animations["POSE_IDLE"].AutoLoop = IsTaunting; Animations["BLOCK_IDLE"].AutoLoop = Owner.controlDown; } #region Time Stop if (TimeStopDelay > 1) { TimeStopDelay--; } else if (TimeStopDelay == 1) { projectile.netUpdate = true; if (!TimeStopManagement.TimeStopped) { Projectile.NewProjectile(Owner.Center, Vector2.Zero, ModContent.ProjectileType <TimeStopVFX>(), 0, 0, Owner.whoAmI); Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/StarPlatinum/SP_TimeStopSignal")); } TimeStopManagement.ToggleTimeStopIfStopper(TBAPlayer.Get(Owner), 7 * Constants.TICKS_PER_SECOND); TimeStopDelay--; } #endregion if (CurrentState == "POSE_IDLE" && !IsTaunting) { CurrentState = ANIMATION_IDLE; } if (StopsItemUse && TBAPlayer.Get(Owner).MouseOneTime >= 20 && InIdleState) { TBAPlayer.Get(Owner).CheckStaminaCost(15, true); CurrentState = "DONUT_PREP"; } if (CurrentState == "DONUT_IDLE" && !Owner.controlUseItem) { CurrentAnimation.ResetAnimation(); CurrentState = "DONUT_PUNCH"; } }