public override void Load() { SteamHelper.Initialize(); On.Terraria.Main.DrawTiles += Main_DrawTiles; On.Terraria.Main.DrawBlack += Main_DrawBlack; On.Terraria.Main.DrawWalls += Main_DrawWalls; //VoiceRecognitionSystem.Load(); TBAInputs.Load(this); TimeStopManagement.Load(); if (!Main.dedServ) { Textures.Load(); Ref <Effect> screenRef = new Ref <Effect>(GetEffect("Effects/ShockwaveEffect")); // The path to the compiled shader file. Filters.Scene["Shockwave"] = new Filter(new ScreenShaderData(screenRef, "Shockwave"), EffectPriority.VeryHigh); Filters.Scene["Shockwave"].Load(); SkyManager.Instance["TBA:TimeStopInvert"] = new PerfectlyNormalSky(); Filters.Scene["TBA:TimeStopInvert"] = new Filter(new ScreenShaderData("FilterInvert"), EffectPriority.High); UIManager.Load(); Filters.Scene["TBA:FreezeSky"] = new Filter(new ScreenShaderData("FilterMiniTower").UseColor(.7f, .7f, .7f), EffectPriority.VeryHigh); SkyManager.Instance["TBA:FreezeSky"] = new FreezeSky(); AddEquipTexture(null, EquipType.Head, "DiavoloHead", "TerrarianBizzareAdventure/Items/Armor/Vanity/Vinegar/DiavoloHead_Head"); AddEquipTexture(null, EquipType.Body, "DiavoloBody", "TerrarianBizzareAdventure/Items/Armor/Vanity/Vinegar/DiavoloChest_Body", "TerrarianBizzareAdventure/Items/Armor/Vanity/Vinegar/DiavoloChest_Arms"); } }
public override void PreUpdate() { if (Main.netMode == NetmodeID.SinglePlayer || Main.dedServ) { TimeSkipManager.UpdateTimeSkip(); TimeStopManagement.MainOnOnTick(); } TBAPlayer plr = TimeStopManagement.TimeStopper as TBAPlayer; if (TimeStopManagement.TimeStoppedFor <= 78 && TimeStopManagement.TimeStoppedFor > 76) { if (plr.StandUser) { if (plr.Stand is TheWorldStand) { TBAMod.PlayVoiceLine("Sounds/TheWorld/TimeResume"); Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/TheWorld/TheWorld_ZaWarudoReleaseSFX")); } if (plr.Stand is StarPlatinumStand) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/StarPlatinum/SP_TimeRestore")); } } } base.PreUpdate(); }
public override bool PreAI(Projectile projectile) { int tickLimit = TimeStopManagement.TimeStopped && projectile.owner == TimeStopManagement.TimeStopper.player.whoAmI ? 10 : 1; IsStopped = !TBAMod.Instance.TimeStopImmuneProjectiles.Contains(projectile.type) && TimeStopManagement.TimeStopped && !(projectile.modProjectile is IProjectileHasImmunityToTimeStop iisitts && iisitts.IsNativelyImmuneToTimeStop()) && RanForTicks > tickLimit && (!(projectile.modProjectile is Stand) && projectile.owner == TimeStopManagement.TimeStopper.player.whoAmI); var IsTimeSkipped = TimeSkipManager.IsTimeSkipped && projectile.hostile; RanForTicks++; PreTimeSkipAI(projectile); if (IsTimeSkipped && RanForTicks > 2 && RanForTicks < 60) { return(false); } if (IsStopped) { if (!TimeStopManagement.projectileStates.ContainsKey(projectile)) { TimeStopManagement.RegisterStoppedProjectile(projectile); } TimeStopManagement.projectileStates[projectile].PreAI(projectile); projectile.frameCounter = 0; return(false); } return(true); }
public override bool PreAI(NPC npc) { if (TimeStopManagement.TimeStopped && TimeStopManagement.IsNPCImmune(npc)) { return(true); } IsStopped = TimeStopManagement.TimeStopped; if (IsStopped) { if (!TimeStopManagement.npcStates.ContainsKey(npc)) { TimeStopManagement.RegisterStoppedNPC(npc); } TimeStopManagement.npcStates[npc].PreAI(npc); npc.frameCounter = 0; return(false); } PreTimeSkipAI(npc); return(true); }
public override void OnEnterWorld(Player player) { TimeStopManagement.OnPlayerEnterWorld(player); //string text = VoiceRecognitionSystem.SuccesfulBoot ? "Successfully booted up Voice Recognition System;" : "Unsuccessful boot attempt at Voice Recognition System;"; //Main.NewText(text + VoiceRecognitionSystem.FailReason, VoiceRecognitionSystem.SuccesfulBoot ? Color.Lime : Color.Red); ActiveStandProjectile = null; }
public override void PostDrawTiles() { if (Main.netMode == NetmodeID.MultiplayerClient) { TimeSkipManager.UpdateTimeSkip(); TimeStopManagement.MainOnOnTick(); } base.PostDrawTiles(); }
public override void Unload() { Instance = null; On.Terraria.Main.DrawTiles -= Main_DrawTiles; On.Terraria.Main.DrawBlack -= Main_DrawBlack; On.Terraria.Main.DrawWalls -= Main_DrawWalls; TBAInputs.Unload(); TimeStopManagement.Unload(); Textures.Unload(); StandLoader.Instance.Unload(); }
public override void NetReceive(BinaryReader reader) { bool timeStopped = reader.ReadBoolean(); if (timeStopped) { TimeStopManagement.MainTime = reader.ReadDouble(); TimeStopManagement.MainRainTimer = reader.ReadInt32(); TimeStopManagement.StopTime(TBAPlayer.Get(Main.player[reader.ReadInt32()]), reader.ReadInt32()); } else { TimeStopManagement.ResumeTime(); } }
public void TimeStop() { if (TimeStopManagement.TimeStopped) { TimeStopManagement.TryResumeTime(TBAPlayer.Get(Owner)); Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, TimeStopRestorePath)); return; } if (!TBAPlayer.Get(Owner).ShatteredTime&& TBAPlayer.Get(Owner).CheckStaminaCost(TimeStopCost)) { TBAPlayer.Get(Owner).TirePlayer(15); if (!TimeStopManagement.TimeStopped) { TBAMod.PlayVoiceLine(TimeStopVoiceLinePath); } CurrentState = TIMESTOP_ANIMATION; } }
public override void Update(Item item, ref float gravity, ref float maxFallSpeed) { if (TimeStopManagement.TimeStopped && !TimeStopManagement.IsImmune(item)) { IsStopped = true; } else { IsStopped = false; } if (IsStopped) { if (!TimeStopManagement.itemStates.ContainsKey(item)) { TimeStopManagement.RegisterStoppedItem(item); } TimeStopManagement.itemStates[item].PreAI(item); } }
public override void AI() { base.AI(); Opacity = 1f; IsFlipped = Owner.direction == 1; projectile.timeLeft = 200; int xOffset = CurrentState.Contains("PUNCH") || CurrentState.Contains("RUSH") || CurrentState == "THROW_KNIVES" || CurrentState == TIMESTOP_ANIMATION ? 34 : -16; PositionOffset = Owner.Center + new Vector2(xOffset * Owner.direction, -24 + Owner.gfxOffY); if (CurrentState.Contains("PUNCH") || CurrentState == "SLAM" || CurrentState == "THROW_KNIVES" || CurrentState == TIMESTOP_ANIMATION) { Owner.heldProj = projectile.whoAmI; } projectile.Center = Vector2.Lerp(projectile.Center, PositionOffset, 0.26f); if (CurrentState == "THROW_KNIVES") { if (CurrentAnimation.CurrentFrame == 10) { Vector2 direction = VectorHelpers.DirectToMouse(projectile.Center, 14f); if (Owner.Center.X + direction.X > Owner.Center.X) { Owner.direction = 1; } else { Owner.direction = -1; } for (int i = 0; i < 2; i++) { Projectile.NewProjectile(projectile.Center + direction * 2.2f + new Vector2(Main.rand.Next(-5, 5), Main.rand.Next(-34, 34)).RotatedBy(direction.ToRotation()), direction, ModContent.ProjectileType <Knife>(), 80, 3.5f, Owner.whoAmI, projectile.whoAmI); } } } if (CurrentState == ANIMATION_DESPAWN && CurrentAnimation.Finished && TimeStopDelay <= 0) { KillStand(); } if (InIdleState) { if (Owner.whoAmI == Main.myPlayer) { if (TBAInputs.StandPose.JustPressed) { if (CurrentState == ANIMATION_IDLE) { IsTaunting = true; } else { IsTaunting = false; } } if (TBAInputs.ExtraAction02.JustPressed && TBAPlayer.Get(Owner).CheckStaminaCost(10)) { CurrentState = "THROW_KNIVES"; } if (TBAInputs.SummonStand.JustPressed) { CurrentState = ANIMATION_DESPAWN; } int roadRollerCost = TimeStopManagement.TimeStopped ? 10 : 50; if (TBAInputs.ExtraAction01.JustPressed && !BeganAscending && TBAPlayer.Get(Owner).CheckStaminaCost(roadRollerCost)) { projectile.netUpdate = true; if (!TimeStopManagement.TimeStopped) { if (!TimeStopManagement.TimeStopped) { TBAMod.PlayVoiceLine("Sounds/TheWorld/TimeStop"); } IsTaunting = false; TimeStopDelay = 25; } Owner.Center -= new Vector2(0, 16); Owner.velocity.Y = -16; CurrentState = "FLY_UP"; projectile.netUpdate = true; TBAPlayer.Get(Owner).PointOfInterest = Main.screenPosition + new Vector2(Main.screenWidth, Main.screenHeight) * 0.5f; BeganAscending = true; } if (TBAInputs.ContextAction.JustPressed) { TimeStop(); } } if (StopsItemUse) { 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); 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 = 32; Projectile.NewProjectile(projectile.Center, VectorHelpers.DirectToMouse(projectile.Center, 22f), ModContent.ProjectileType <Punch>(), 80, 3.5f, Owner.whoAmI, projectile.whoAmI); } } } else if (Owner.controlUseItem) { projectile.netUpdate = true; TBAMod.PlayVoiceLine("Sounds/TheWorld/MudaRush"); 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 <WorldBarrage>(), 60, 0, Owner.whoAmI); if (Main.projectile[barrage].modProjectile is WorldBarrage worldBarrage) { worldBarrage.RushDirection = PunchRushDirection; worldBarrage.ParentProjectile = projectile.whoAmI; } } } } if (TimeStopDelay > 1) { TimeStopDelay--; } else if (TimeStopDelay == 1) { if (!TimeStopManagement.TimeStopped) { Projectile.NewProjectile(Owner.Center, Vector2.Zero, ModContent.ProjectileType <TimeStopVFX>(), 0, 0, Owner.whoAmI); Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/TheWorld/TheWorld_ZaWarudoSFX")); } TimeStopManagement.ToggleTimeStopIfStopper(TBAPlayer.Get(Owner), 11 * Constants.TICKS_PER_SECOND); TimeStopDelay--; } if (Animations.Count > 0) { Animations["RUSH_DOWN"].AutoLoop = RushTimer > 0; Animations["RUSH_UP"].AutoLoop = RushTimer > 0; Animations["RUSH_MID"].AutoLoop = RushTimer > 0; } if (BeganAscending) { if (AscensionTimer >= (int)(2 * Constants.TICKS_PER_SECOND)) { if (RoadRollerXAxis == -1.0f) { RoadRollerXAxis = Main.MouseWorld.X; } TBAPlayer.Get(Owner).PointOfInterest = new Vector2(MathHelper.Lerp(TBAPlayer.Get(Owner).PointOfInterest.X, RoadRollerXAxis, 0.1f), TBAPlayer.Get(Owner).PointOfInterest.Y); } if (++AscensionTimer >= (int)(2.5 * Constants.TICKS_PER_SECOND)) { TBAPlayer.Get(Owner).TirePlayer(30); projectile.netUpdate = true; TBAMod.PlayVoiceLine("Sounds/TheWorld/RoadRoller"); BeganAscending = false; AscensionTimer = 0; CurrentState = "SLAM"; HasResetRoadRollerDrop = false; RoadRollerID = Projectile.NewProjectile(new Vector2(RoadRollerXAxis, Owner.Center.Y), Vector2.Zero, ModContent.ProjectileType <RoadRoller>(), 20, 0, projectile.owner); RoadaRollaDa.spriteDirection = Owner.direction * -1; RoadaRollaDa.Center = new Vector2(RoadRollerXAxis, Owner.Center.Y); RoadRollerXAxis = -1.0f; } else { Owner.velocity = Vector2.Zero; Owner.Center -= new Vector2(0f, 10f); } } if (RoadaRollaDa.modProjectile is RoadRoller roller) { if (RushTimer > 0 && roller.HasTouchedGround || !roller.HasTouchedGround) { Owner.direction = RoadaRollaDa.spriteDirection * -1; Owner.Center = projectile.Center + new Vector2(20 * Owner.direction * -1, -20); projectile.Center = RoadaRollaDa.Center + new Vector2(40 * Owner.direction * -1, -40); } if (roller.HasTouchedGround && !HasResetRoadRollerDrop) { TBAMod.PlayVoiceLine("Sounds/TheWorld/MudaRush"); CurrentState = "RUSH_DOWN"; RushTimer = 180; PunchRushDirection = (RoadaRollaDa.Center - projectile.Center).SafeNormalize(-Vector2.UnitX) * 12f; TBAPlayer.Get(Owner).AttackDirectionResetTimer = RushTimer; TBAPlayer.Get(Owner).AttackDirection = RoadaRollaDa.Center.X < projectile.Center.X ? -1 : 1; TBAPlayer.Get(Owner).PointOfInterest = Vector2.Zero; HasResetRoadRollerDrop = true; int barrage = Projectile.NewProjectile(projectile.Center, PunchRushDirection, ModContent.ProjectileType <WorldBarrage>(), 60, 0, Owner.whoAmI); if (Main.projectile[barrage].modProjectile is WorldBarrage worldBarrage) { worldBarrage.RushDirection = PunchRushDirection; worldBarrage.ParentProjectile = projectile.whoAmI; } } } }
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"; } }