Example #1
0
        public override void Action(CommandCaller caller, string input, string[] args)
        {
            StarSailorMod sm = ModContent.GetInstance <StarSailorMod>();

            sm.GenerateStars(250, Distribution.Atan);
        }
Example #2
0
        public override void ModifyDrawInfo(ref PlayerDrawInfo drawInfo)
        {
            drawInfo.drawPlayer.fullRotationOrigin = 0.5f * new Vector2(drawInfo.drawPlayer.width, drawInfo.drawPlayer.height);
            StarSailorMod sm    = (StarSailorMod)mod;
            Color         invis = new Color(0, 0, 0, 0);

            if (player.mount.Type == ModContent.GetInstance <Rocket>().Type)
            {
                drawInfo.bodyColor         = invis;
                drawInfo.hairColor         = invis;
                drawInfo.headGlowMaskColor = invis;
                drawInfo.armGlowMaskColor  = invis;
                drawInfo.bodyGlowMaskColor = invis;

                drawInfo.eyeColor         = invis;
                drawInfo.eyeWhiteColor    = invis;
                drawInfo.faceColor        = invis;
                drawInfo.legColor         = invis;
                drawInfo.legGlowMaskColor = invis;
                drawInfo.lowerArmorColor  = invis;
                drawInfo.middleArmorColor = invis;
                drawInfo.pantsColor       = invis;
                drawInfo.shirtColor       = invis;
                drawInfo.shoeColor        = invis;
                drawInfo.underShirtColor  = invis;
                drawInfo.upperArmorColor  = invis;
            }

            if (custGravity)
            {
                drawInfo.drawPlayer.mount.SetMount(ModContent.GetInstance <SpaceControls>().Type, drawInfo.drawPlayer);
                //Main.blockInput = true;
                drawInfo.drawPlayer.maxFallSpeed = 0;
                drawInfo.drawPlayer.vortexDebuff = true;
                if (gravSources.Count > 0)
                {
                    Vector2 displ       = new Vector2(20020020);
                    float   closestDist = 1000000f;
                    foreach (Vector2 v in gravSources)
                    {
                        if (ModContent.GetInstance <GravitySource>().boundingTiles.TryGetValue(v, out List <BoundingTile> boundTiles))
                        {
                            foreach (BoundingTile f in boundTiles)
                            {
                                float currDist = Vector2.Distance(f.pos, drawInfo.position / 16f);
                                if (currDist < closestDist)
                                {
                                    closestDist = currDist;
                                    displ       = v - (drawInfo.position / 16f);
                                }
                                else if (currDist == closestDist)
                                {
                                    Vector2 tdis = v - (drawInfo.position / 16f);
                                    if (tdis.Length() < displ.Length())
                                    {
                                        displ = tdis;
                                    }
                                }
                            }
                        }
                    }
                    dirToGrav = displ;
                    //drawInfo.drawPlayer.velocity += (displ / 100);
                    float idealRotation = (float)Math.Atan(displ.Y / displ.X) + (float)Math.PI / 2f;
                    if (Math.Sign(displ.X) == 1)
                    {
                        idealRotation += (float)Math.PI;
                    }
                    float diff = idealRotation - drawInfo.drawPlayer.fullRotation;
                    diff %= (float)(Math.PI * 2);
                    if (Math.Abs(diff) > Math.PI)
                    {
                        diff = -diff;
                    }
                    if (Math.Abs(diff) < Math.PI * ROT_VELOCITY)
                    {
                        drawInfo.drawPlayer.fullRotation = idealRotation;
                    }
                    else
                    {
                        drawInfo.drawPlayer.fullRotation += (float)(Math.Sign(diff) * Math.PI * ROT_VELOCITY);
                    }
                    drawInfo.drawPlayer.fullRotation %= 2 * (float)Math.PI;
                }
                else
                {
                    Main.blockInput = false;
                    drawInfo.drawPlayer.QuickMount();
                    drawInfo.drawPlayer.fullRotation = 0;
                }

                if (drawInfo.drawPlayer.controlRight && !drawInfo.drawPlayer.controlLeft)
                {
                    drawInfo.spriteEffects = SpriteEffects.None;
                }
                else if (player.controlLeft && !player.controlRight)
                {
                    drawInfo.spriteEffects = SpriteEffects.FlipHorizontally;
                }
                if (dirToGrav != Vector2.Zero)
                {
                    Vector2 direction = dirToGrav / dirToGrav.Length();
                    Vector2 perpDir   = new Vector2(-direction.Y, direction.X);
                    float   tangVel   = Vector2.Dot(gravVelocity, perpDir);
                    float   radVel    = Vector2.Dot(gravVelocity, direction);
                    if (!ModContent.GetInstance <GravitySource>().CheckIntersectSurface(player))
                    {
                        bodyFrameY         = player.bodyFrame.Height * 5;
                        bodyFrameCounter   = 0.0f;
                        legFrameY          = player.legFrame.Height * 5;
                        legFrameCounter    = 0.0f;
                        player.legFrame.Y  = legFrameY;
                        player.bodyFrame.Y = bodyFrameY;
                    }
                    else if (tangVel != 0f)
                    {
                        legFrameCounter  += Math.Abs(tangVel) * 0.3f;
                        bodyFrameCounter += Math.Abs(tangVel) * 0.3f;
                        while (legFrameCounter > 8.0)
                        {
                            legFrameCounter -= 8.0f;
                            legFrameY       += player.legFrame.Height;
                        }
                        if (legFrameY < player.legFrame.Height * 7)
                        {
                            legFrameY = player.legFrame.Height * 19;
                        }
                        else if (legFrameY > player.legFrame.Height * 19)
                        {
                            legFrameY = player.legFrame.Height * 7;
                        }
                        while (bodyFrameCounter > 8.0)
                        {
                            bodyFrameCounter -= 8.0f;
                            bodyFrameY       += player.bodyFrame.Height;
                        }
                        if (bodyFrameY < player.bodyFrame.Height * 7)
                        {
                            bodyFrameY = player.bodyFrame.Height * 19;
                        }
                        else if (bodyFrameY > player.bodyFrame.Height * 19)
                        {
                            bodyFrameY = player.bodyFrame.Height * 7;
                        }
                        player.legFrame.Y  = legFrameY;
                        player.bodyFrame.Y = bodyFrameY;
                    }
                }
            }
            else
            {
                drawInfo.drawPlayer.fullRotation = 0;
            }
            if (drawInfo.drawPlayer.mount.Type == ModContent.GetInstance <Mech>().Type)
            {
                drawInfo.spriteEffects = SpriteEffects.None;
            }

            base.ModifyDrawInfo(ref drawInfo);
        }
Example #3
0
        public override void Action(CommandCaller caller, string input, string[] args)
        {
            StarSailorMod sm = ModContent.GetInstance <StarSailorMod>();

            SequenceBuilder.CloneSequence(Sequence.IntroCutscene).Execute();
        }