Example #1
0
        public static void WarpPlayerToTrain(Player player)
        {
            if (!SaveableEntityComponent.HaveAllEntitiesLoaded)
            {
                throw new HamstarException("OnARail.TrainEntityHandler.WarpPlayerToTrain - Entities not loaded.");
            }

            var myplayer = player.GetModPlayer <OnARailPlayer>();

            if (myplayer.MyTrainWho == -1)
            {
                throw new HamstarException("OnARail.TrainEntityHandler.WarpPlayerToTrain - Player " + player.name + " (" + player.whoAmI + ") has no train.");
            }

            CustomEntity train_ent = CustomEntityManager.GetEntityByWho(myplayer.MyTrainWho);

            if (train_ent == null)
            {
                throw new HamstarException("OnARail.TrainEntityHandler.WarpPlayerToTrain - Player " + player.name + " (" + player.whoAmI + ") has no train entity.");
            }

            PlayerHelpers.Teleport(player, train_ent.Core.Center - new Vector2(player.width / 2, (player.height / 2) + 16));

            int train_buff_id = OnARailMod.Instance.BuffType <TrainMountBuff>();

            player.AddBuff(train_buff_id, 30);
        }
Example #2
0
        protected virtual void Teleport(Player player, Vector2 dest)
        {
            var             mymod    = WormholesMod.Instance;
            WormholesPlayer myplayer = player.GetModPlayer <WormholesPlayer>(mymod);

            if (myplayer.MyPortal == null || (myplayer.MyPortal != null && this.ID != myplayer.MyPortal.ID))
            {
                myplayer.ChartedLinks.Add(this.ID);
            }

            PlayerHelpers.Teleport(player, dest);

            if (player.FindBuffIndex(88) != -1)
            {
                int def = player.statDefense;
                player.statDefense = 0;
                var dmg = player.Hurt(PlayerDeathReason.ByOther(13), player.statLifeMax2 / 7, 0);
                player.statDefense = def;
            }

            player.AddBuff(164, (int)(60f * 2.5f));      // Distorted
            player.AddBuff(88, 60 * 10);                 // Chaos State

            float vel_x = player.velocity.X * 3;
            float vel_y = player.velocity.Y * 3;

            if (vel_x > 0 && vel_x < 1)
            {
                vel_x = 1;
            }
            else if (vel_x < 0 && vel_x > 1)
            {
                vel_x = -1;
            }
            if (vel_y > 0 && vel_y < 1)
            {
                vel_y = 1;
            }
            else if (vel_y < 0 && vel_y > 1)
            {
                vel_y = -1;
            }

            for (int i = 0; i < 24; i++)
            {
                Dust.NewDust(player.position, player.width, player.height, 245, vel_x, vel_y);
            }

            //Main.PlaySound( 2, player.position, 100 );
            var snd = SoundID.Item100.WithVolume(mymod.Config.WormholeEntrySoundVolume);

            Main.PlaySound(snd, player.position);
        }
        private void TraverseToTunnel(CustomEntity train_ent, TrainTunnelTileEntity to_tunnel)
        {
            if (this.IsMountedBy == -1 || train_ent.MyOwnerPlayerWho == -1)
            {
                // TODO train-only traversal
            }
            else
            {
                Vector2 to_tunnel_pos = to_tunnel.GetWorldRectangle().Center.ToVector2();
                to_tunnel_pos.Y -= 32;

                Player  plr = Main.player[train_ent.MyOwnerPlayerWho];
                Vector2 vel = plr.velocity;

                PlayerHelpers.Teleport(plr, to_tunnel_pos);
                plr.velocity = vel;
            }
        }
Example #4
0
        private void HandleRecall()
        {
            CustomEntity ent        = CustomEntityManager.GetEntityByWho(this.MyTrainWho);
            var          train_comp = ent.GetComponentByType <TrainBehaviorEntityComponent>();

            if (train_comp.IsMountedBy != -1)
            {
                PlayerHelpers.Teleport(this.player, this.PrevPosition);                         // return to train's last position
            }
            else
            {
                if (((OnARailMod)this.mod).Config.DebugModeInfo)
                {
                    Main.NewText("Warping to train...");
                }

                TrainEntity.WarpPlayerToTrain(player);                          // return to train
            }
        }