Ejemplo n.º 1
0
        public override void ReceiveExtraAI(BinaryReader reader)
        {
            oldTileCollide = reader.ReadBoolean();
            readyToStick   = reader.ReadBoolean();
            stuck          = reader.ReadBoolean();
            stuckToTiles   = reader.ReadBoolean();
            stuckTimer     = reader.ReadInt32();
            stuckPosition  = reader.ReadVector2();
            int whoAmI = reader.ReadInt32(); //Read the whoami value sent

            if (whoAmI == -1)                //If its a -1, sync that the npc hasn't been set yet
            {
                stickTarget = default;
            }
            else
            {
                stickTarget = Main.npc[whoAmI];
            }

            if (stuck)
            {
                if (trail2 == null)
                {
                    trail2 = new PlugTrail2(projectile, Main.player[projectile.owner]);
                    SpiritMod.primitives.CreateTrail(trail2);
                }
                if (trail == null)
                {
                    trail = new PlugTrail(projectile, Main.player[projectile.owner]);
                    SpiritMod.primitives.CreateTrail(trail);
                }
            }
        }
Ejemplo n.º 2
0
        public override bool OnTileCollide(Vector2 oldVelocity)
        {
            if (!readyToStick)
            {
                if (stuck)
                {
                    return(false);
                }
                return(base.OnTileCollide(oldVelocity));
            }

            trail2 = new PlugTrail2(projectile, Main.player[projectile.owner]);
            SpiritMod.primitives.CreateTrail(trail2);

            trail = new PlugTrail(projectile, Main.player[projectile.owner]);
            SpiritMod.primitives.CreateTrail(trail);

            oldTileCollide = projectile.tileCollide;
            readyToStick   = false;
            stuck          = true;
            stuckToTiles   = true;
            stuckTimer     = 100;
            stuckPosition  = projectile.Center;
            struckTile     = true;

            if (oldVelocity.X != projectile.velocity.X)             //if its an X axis collision
            {
                if (projectile.velocity.X > 0)
                {
                    projectile.rotation = 1.57f;
                }
                else
                {
                    projectile.rotation = 4.71f;
                }
            }

            if (oldVelocity.Y != projectile.velocity.Y)             //if its a Y axis collision
            {
                if (projectile.velocity.Y > 0)
                {
                    projectile.rotation = 0f;
                }
                else
                {
                    projectile.rotation = 3.14f;
                }
            }

            return(base.OnTileCollide(oldVelocity));
        }
Ejemplo n.º 3
0
 public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
 {
     if (readyToStick && released && target.life > 0)
     {
         trail2 = new PlugTrail2(projectile, Main.player[projectile.owner]);
         trail  = new PlugTrail(projectile, Main.player[projectile.owner]);
         SpiritMod.primitives.CreateTrail(trail2);
         SpiritMod.primitives.CreateTrail(trail);
         oldTileCollide      = projectile.tileCollide;
         readyToStick        = false;
         stuck               = true;
         stuckToTiles        = false;
         stuckTimer          = 100;
         stickTarget         = target;
         stuckPosition       = projectile.Center - target.Center;
         projectile.rotation = projectile.DirectionTo(target.Center).ToRotation() - 1.57f;
         if (Main.netMode != NetmodeID.SinglePlayer)
         {
             NetMessage.SendData(MessageID.SyncProjectile, -1, -1, null, projectile.whoAmI);
         }
     }
 }