Exemple #1
0
		internal static void SetupMount(Mount.MountData mount)
		{
			if (IsModMountData(mount))
			{
				GetMount(mount.modMountData.Type).SetupMount(mount);
			}
		}
		internal void SetupMount(Mount.MountData mountData)
		{
			ModMountData newMountData = (ModMountData)MemberwiseClone();
			newMountData.mountData = mountData;
			mountData.modMountData = newMountData;
			newMountData.mod = mod;
			newMountData.SetDefaults();
		}
        internal static float OnJumpSpeed(Mount m, float xVel)
        {
            var bh = m.P_BHandler as MountBHandler;

            var r = m.RealJumpSpeed(xVel);

            return bh != null ? bh.JumpSpeed(xVel) ?? r : r;
        }
		internal void SetupMount(Mount.MountData mountData)
		{
			ModMountData newMountData = (ModMountData)Activator.CreateInstance(GetType());
			newMountData.mountData = mountData;
			mountData.modMountData = newMountData;
			newMountData.mod = mod;
			newMountData.SetDefaults();
		}
Exemple #5
0
		internal static bool CustomBodyFrame(Mount.MountData mount)
		{
			if (IsModMountData(mount) && mount.modMountData.CustomBodyFrame())
			{
				return true;
			}
			return false;
		}
        internal static void OnSetMount(Mount m, int type, Player p, bool faceLeft)
        {
            m.RealSetMount(type, p, faceLeft);

            var h = AttachBHandler(m, type);

            if (h != null)
                h.OnMount(p, faceLeft);
        }
        internal static bool OnHover(Mount m, Player p)
        {
            var bh = m.P_BHandler as MountBHandler;

            var r = m.RealHover(p);

            if (bh != null)
                bh.Hover(p);

            return r;
        }
        internal static void OnDraw(Mount m, List<DrawData> playerDrawData, int drawType, Player p, Vector2 pos, Color colour, SpriteEffects playerEffect, float shadow)
        {
            var bh = m.P_BHandler as MountBHandler;

            if (bh == null || bh.PreDraw(Main.spriteBatch, playerDrawData, drawType, p, pos, colour, playerEffect, shadow))
            {
                m.RealDraw(playerDrawData, drawType, p, pos, colour, playerEffect, shadow);

                if (bh != null)
                    bh.OnDraw(Main.spriteBatch, playerDrawData, drawType, p, pos, colour, playerEffect, shadow);
            }
        }
        internal static void OnDismount(Mount m, Player p)
        {
            var bh = m.P_BHandler as MountBHandler;

            if (bh != null)
                bh.OnDismount(p);

            m.RealDismount(p);

            if (bh != null)
            {
                bh.Clear();

                m.P_BHandler = bh = null;
            }
        }
Exemple #10
0
        internal static void OnUpdateEffects(Mount m, Player p)
        {
            var bh = m.P_BHandler as MountBHandler;

            if (bh == null || bh.PreUpdateEffects(p))
            {
                m.RealUpdateEffects(p);

                if (bh != null)
                    bh.OnUpdateEffects(p);
            }
        }
Exemple #11
0
        internal static void OnUpdateFrame(Mount m, Player p, int state, Vector2 vel)
        {
            var bh = m.P_BHandler as MountBHandler;

            m.RealUpdateFrame(p, state, vel);

            if (bh != null)
                bh.UpdateFrame(p, state, vel);
        }
Exemple #12
0
		internal static bool IsModMountData(Mount.MountData mountData)
		{
			return mountData.modMountData != null;
		}
Exemple #13
0
        static MountBHandler AttachBHandler(Mount m, int type)
        {
            MountBHandler h = null;

            var def = type == -1 ? null : Handler.MountDef.DefsByType[type];

            if (def != null && def.CreateBehaviour != null)
            {
                var b = def.CreateBehaviour();

                if (b != null)
                {
                    h = new MountBHandler();

                    b.Mod = ModData.mods[def.Mod];
                    b.Mount = m;

                    h.behaviours.Add(b);
                }
            }

            var bs = ModData.mods.Values.Select(d =>
            {
                var mb = d.ContentHandler.CreateGlobalMountBInternally();

                if (mb != null)
                    mb.Mod = d;

                return mb;
            }).Where(bb => bb != null);

            if (!bs.IsEmpty())
            {
                if (h == null)
                    h = new MountBHandler();

                h.behaviours.AddRange(bs);
            }

            if (h != null)
                h.Create();

            m.P_BHandler = h;

            return h;
        }
Exemple #14
0
 private Point16 DrillSmartCursor(Player mountedPlayer, Mount.DrillMountData data)
 {
     Vector2 value;
     if (mountedPlayer.whoAmI == Main.myPlayer)
     {
         value = Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY);
     }
     else
     {
         value = data.crosshairPosition;
     }
     Vector2 center = mountedPlayer.Center;
     Vector2 value2 = value - center;
     float num = value2.Length();
     if (num > 224f)
     {
         num = 224f;
     }
     num += 32f;
     value2.Normalize();
     Vector2 start = center;
     Vector2 end = center + value2 * num;
     Point16 tilePoint = new Point16(-1, -1);
     bool flag = !Utils.PlotTileLine(start, end, 65.6f, delegate(int x, int y)
     {
         tilePoint = new Point16(x, y);
         for (int i = 0; i < data.beams.Length; i++)
         {
             if (data.beams[i].curTileTarget == tilePoint)
             {
                 return true;
             }
         }
         return !WorldGen.CanKillTile(x, y) || Main.tile[x, y] == null || Main.tile[x, y].inActive() || !Main.tile[x, y].active();
     });
     if (flag)
     {
         return tilePoint;
     }
     return new Point16(-1, -1);
 }
Exemple #15
0
        public Player()
        {
            this.width = 20;
            this.height = 42;
            this.name = string.Empty;
            for (int index = 0; index < 59; ++index)
            {
                if (index < this.armor.Length)
                {
                    this.armor[index] = new Item();
                    this.armor[index].name = "";
                }
                this.inventory[index] = new Item();
                this.inventory[index].name = "";
            }
            for (int index = 0; index < 40; ++index)
            {
                this.bank.item[index] = new Item();
                this.bank.item[index].name = "";
                this.bank2.item[index] = new Item();
                this.bank2.item[index].name = "";
            }
            for (int index = 0; index < this.dye.Length; ++index)
                this.dye[index] = new Item();
            for (int index = 0; index < this.miscEquips.Length; ++index)
                this.miscEquips[index] = new Item();
            for (int index = 0; index < this.miscDyes.Length; ++index)
                this.miscDyes[index] = new Item();
            this.trashItem = new Item();
            this.grappling[0] = -1;
			GiveStartEquipment();
            this.statManaMax = 20;
            if (Main.cEd)
                this.inventory[3].SetDefaults(603, false);
            for (int index = 0; index < 419; ++index)
            {
                this.adjTile[index] = false;
                this.oldAdjTile[index] = false;
            }
            this.hitTile = new HitTile();
            this.mount = new Mount();
		}
Exemple #16
0
        public override bool UpdateFrame(Player mountedPlayer, int state, Vector2 velocity)
        {
            MyPlayer modPlayer = mountedPlayer.GetSpiritPlayer();

            Terraria.Mount mount = mountedPlayer.mount;
            //Part of vanilla code, mount will glitch out
            // if this is not executed.
            if (mount._frameState != state)
            {
                mount._frameState = state;
            }
            //End of required vanilla code

            //Adjust animation speed after landing/takeoff
            if (state == 0)
            {
                if (mount._idleTime > 0)
                {
                    mount._idleTime--;
                }
            }
            else
            {
                if (mount._idleTime < revUpFrames)
                {
                    mount._idleTime += 4;
                }
            }
            float throttle = 1;

            if (mount._idleTime < revUpFrames)
            {
                throttle = (mount._idleTime) / (float)revUpFrames;
            }

            //Choose next frame
            mount._frameCounter += throttle;
            if ((int)mount._frameCounter >= mountData.inAirFrameDelay)
            {
                mount._frameCounter -= mountData.inAirFrameDelay;
                mount._frameExtra++;
                if (mount._frameExtra >= mountData.inAirFrameCount)
                {
                    mount._frameExtra = 0;
                }
            }

            mount._frame = mount._frameExtra;
            if (modPlayer.copterFireFrame >= muzzleFrames)
            {
                mount._frame = mount._frameExtra;
            }
            else if (modPlayer.copterFireFrame >= muzzleFrames >> 1)
            {
                mount._frame = mount._frameExtra + mountData.inAirFrameCount;
            }
            else
            {
                mount._frame = mount._frameExtra + 2 * mountData.inAirFrameCount;
            }

            return(false);
        }
Exemple #17
0
 public Player()
 {
     int[] array = new int[2];
     this.hurtCooldowns = array;
     this.width = 20;
     this.height = 42;
     this.name = string.Empty;
     for (int i = 0; i < 59; i++)
     {
         if (i < (int)this.armor.Length)
         {
             this.armor[i] = new Item();
             this.armor[i].name = "";
         }
         this.inventory[i] = new Item();
         this.inventory[i].name = "";
     }
     for (int j = 0; j < 40; j++)
     {
         this.bank.item[j] = new Item();
         this.bank.item[j].name = "";
         this.bank2.item[j] = new Item();
         this.bank2.item[j].name = "";
     }
     for (int k = 0; k < (int)this.dye.Length; k++)
     {
         this.dye[k] = new Item();
     }
     for (int l = 0; l < (int)this.miscEquips.Length; l++)
     {
         this.miscEquips[l] = new Item();
     }
     for (int m = 0; m < (int)this.miscDyes.Length; m++)
     {
         this.miscDyes[m] = new Item();
     }
     this.grappling[0] = -1;
     this.inventory[0].SetDefaults("Copper Shortsword");
     this.inventory[1].SetDefaults("Copper Pickaxe");
     this.inventory[2].SetDefaults("Copper Axe");
     this.statManaMax = 20;
     if (Main.cEd)
     {
         this.inventory[3].SetDefaults(603, false);
     }
     for (int n = 0; n < 419; n++)
     {
         this.adjTile[n] = false;
         this.oldAdjTile[n] = false;
     }
     this.hitTile = new HitTile();
     this.mount = new Mount();
 }
        void CopyEntityToDef(int id, Mount.MountData mount, MountDef def)
        {
            def.Type = id;

            def.MaxAbilityCharge = mount.abilityChargeMax;
            def.AbilityCooldown  = mount.abilityCooldown ;
            def.AbilityDuration  = mount.abilityDuration ;

            def.AdditionalHeight = mount.heightBoost     ;
            def.PlayerHeadOffset = mount.playerHeadOffset;

            def.MaxFatigue    = mount.fatigueMax   ;
            def.MaxFlightTime = mount.flightTimeMax;
            def.JumpHeight    = mount.jumpHeight   ;
            def.SpawnDust     = mount.spawnDust    ;

            def.BodyFrame   = mount.bodyFrame  ;
            def.TotalFrames = mount.totalFrames;

            def.FallDamageMult = mount.fallDamage  ;
            def.Acceleration   = mount.acceleration;
            def.DashSpeed      = mount.dashSpeed   ;
            def.JumpSpeed      = mount.jumpSpeed   ;
            def.RunSpeed       = mount.runSpeed    ;
            def.SwimSpeed      = mount.swimSpeed   ;

            def.BlockExtraJumps       = mount.blockExtraJumps              ;
            def.ConstantJump          = mount.constantJump                 ;
            def.EmitsLight            = mount.emitsLight                   ;
            def.IdleFrameLoop         = mount.idleFrameLoop                ;
            def.IsMinecart            = mount.Minecart | MountSets.Cart[id];
            def.IsDirectionalMinecart = mount.MinecartDirectional          ;
            def.SpawnDustNoGravity    = mount.spawnDustNoGravity           ;
            def.UsesHover             = mount.usesHover                    ;

            def.PlayerYOffset = mount.playerYOffsets;

            def.MinecartDust = mount.MinecartDust;

            def.Offset = new Point(mount.xOffset, mount.yOffset);
            def.LightColour = new Color(mount.lightColor);

            def.Dashing  = new MountFrameData(mount.dashingFrameCount , mount.dashingFrameDelay , mount.dashingFrameStart );
            def.Flying   = new MountFrameData(mount.flyingFrameCount  , mount.flyingFrameDelay  , mount.flyingFrameStart  );
            def.Idle     = new MountFrameData(mount.idleFrameCount    , mount.idleFrameDelay    , mount.idleFrameStart    );
            def.InAir    = new MountFrameData(mount.inAirFrameCount   , mount.inAirFrameDelay   , mount.inAirFrameStart   );
            def.Running  = new MountFrameData(mount.runningFrameCount , mount.runningFrameDelay , mount.runningFrameStart );
            def.Standing = new MountFrameData(mount.standingFrameCount, mount.standingFrameDelay, mount.standingFrameStart);
            def.Swim     = new MountFrameData(mount.swimFrameCount    , mount.swimFrameDelay    , mount.swimFrameStart    );

            def.Buff       = new BuffRef(mount.buff     );
            def.ExpertBuff = new BuffRef(mount.extraBuff);

            def.Front = new MountTextureData(
                () => mount.frontTexture,
                () => mount.frontTextureExtra,
                () => mount.frontTextureGlow,
                () => mount.frontTextureExtraGlow
            );
            def.Back  = new MountTextureData(
                () => mount.backTexture,
                () => mount.backTextureExtra,
                () => mount.backTextureGlow,
                () => mount.backTextureExtraGlow
            );
        }
        void CopyDefToEntity(MountDef def, ref Mount.MountData mount)
        {
            if (mount == null)
                mount = new Mount.MountData();

            mount.abilityChargeMax = def.MaxAbilityCharge;
            mount.abilityCooldown  = def.AbilityCooldown ;
            mount.abilityDuration  = def.AbilityDuration ;

            mount.heightBoost      = def.AdditionalHeight;
            mount.playerHeadOffset = def.PlayerHeadOffset;

            mount.fatigueMax    = def.MaxFatigue   ;
            mount.flightTimeMax = def.MaxFlightTime;
            mount.jumpHeight    = def.JumpHeight   ;
            mount.spawnDust     = def.SpawnDust    ;

            mount.bodyFrame   = def.BodyFrame  ;
            mount.totalFrames = def.TotalFrames;

            mount.fallDamage   = def.FallDamageMult;
            mount.acceleration = def.Acceleration  ;
            mount.dashSpeed    = def.DashSpeed     ;
            mount.jumpSpeed    = def.JumpSpeed     ;
            mount.runSpeed     = def.RunSpeed      ;
            mount.swimSpeed    = def.SwimSpeed     ;

            mount.blockExtraJumps     = def.BlockExtraJumps      ;
            mount.constantJump        = def.ConstantJump         ;
            mount.emitsLight          = def.EmitsLight           ;
            mount.idleFrameLoop       = def.IdleFrameLoop        ;
            mount.Minecart            = def.IsMinecart           ;
            mount.MinecartDirectional = def.IsDirectionalMinecart;
            mount.spawnDustNoGravity  = def.SpawnDustNoGravity   ;
            mount.usesHover           = def.UsesHover            ;

            mount.playerYOffsets = def.PlayerYOffset;

            mount.MinecartDust = def.MinecartDust;

            mount.xOffset = def.Offset.X;
            mount.yOffset = def.Offset.Y;
            mount.lightColor = def.LightColour.ToVector3();

            mount.dashingFrameCount  = def.Dashing.Count ;
            mount.dashingFrameDelay  = def.Dashing.Delay ;
            mount.dashingFrameStart  = def.Dashing.Start ;
            mount.flyingFrameCount   = def.Flying.Count  ;
            mount.flyingFrameDelay   = def.Flying.Delay  ;
            mount.flyingFrameStart   = def.Flying.Start  ;
            mount.idleFrameCount     = def.Idle.Count    ;
            mount.idleFrameDelay     = def.Idle.Delay    ;
            mount.idleFrameStart     = def.Idle.Start    ;
            mount.inAirFrameCount    = def.InAir.Count   ;
            mount.inAirFrameDelay    = def.InAir.Delay   ;
            mount.inAirFrameStart    = def.InAir.Start   ;
            mount.runningFrameCount  = def.Running.Count ;
            mount.runningFrameDelay  = def.Running.Delay ;
            mount.runningFrameStart  = def.Running.Start ;
            mount.standingFrameCount = def.Standing.Count;
            mount.standingFrameDelay = def.Standing.Delay;
            mount.standingFrameStart = def.Standing.Start;
            mount.swimFrameCount     = def.Swim.Count    ;
            mount.swimFrameDelay     = def.Swim.Delay    ;
            mount.swimFrameStart     = def.Swim.Start    ;

            mount.buff      =                    def.Buff .Resolve().Type;
            mount.extraBuff = (def.ExpertBuff ?? def.Buff).Resolve().Type;

            mount.frontTexture          = def.Front.GetNormal   ();
            mount.frontTextureExtra     = def.Front.GetExtra    ();
            mount.frontTextureGlow      = def.Front.GetGlow     ();
            mount.frontTextureExtraGlow = def.Front.GetExtraGlow();

            mount.backTexture          = def.Back.GetNormal   ();
            mount.backTextureExtra     = def.Back.GetExtra    ();
            mount.backTextureGlow      = def.Back.GetGlow     ();
            mount.backTextureExtraGlow = def.Back.GetExtraGlow();

            mount.textureWidth  = def.texSize.X;
            mount.textureHeight = def.texSize.Y;
        }
Exemple #20
0
 private Point16 DrillSmartCursor(Player mountedPlayer, Mount.DrillMountData data)
 {
     Vector2 vector2_1 = mountedPlayer.whoAmI != Main.myPlayer ? data.crosshairPosition : Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY);
     Vector2 center = mountedPlayer.Center;
     Vector2 vector2_2 = vector2_1 - center;
     float num1 = vector2_2.Length();
     if ((double)num1 > 224.0)
         num1 = 224f;
     float num2 = num1 + 32f;
     vector2_2.Normalize();
     Vector2 start = center;
     Vector2 end = center + vector2_2 * num2;
     Point16 tilePoint = new Point16(-1, -1);
     if (!Utils.PlotTileLine(start, end, 65.6f, (Utils.PerLinePoint)((x, y) =>
     {
         tilePoint = new Point16(x, y);
         for (int index = 0; index < data.beams.Length; ++index)
         {
             if (data.beams[index].curTileTarget == tilePoint)
                 return true;
         }
         return !WorldGen.CanKillTile(x, y) || Main.tile[x, y] == null || (Main.tile[x, y].inActive() || !Main.tile[x, y].active());
     })))
         return tilePoint;
     return new Point16(-1, -1);
 }
Exemple #21
0
 private Point16 DrillSmartCursor(Player mountedPlayer, Mount.DrillMountData data)
 {
     Vector2 vector2;
     vector2 = (mountedPlayer.whoAmI != Main.myPlayer ? data.crosshairPosition : Main.screenPosition + new Vector2((float)Main.mouseX, (float)Main.mouseY));
     Vector2 center = mountedPlayer.Center;
     Vector2 vector21 = vector2 - center;
     float single = vector21.Length();
     if (single > 224f)
     {
         single = 224f;
     }
     single = single + 32f;
     vector21.Normalize();
     Vector2 vector22 = center;
     Vector2 vector23 = center + (vector21 * single);
     Point16 point16 = new Point16(-1, -1);
     if (!Utils.PlotTileLine(vector22, vector23, 65.6f, (int x, int y) => {
         point16 = new Point16(x, y);
         for (int i = 0; i < (int)data.beams.Length; i++)
         {
             if (data.beams[i].curTileTarget == point16)
             {
                 return true;
             }
         }
         if (!WorldGen.CanKillTile(x, y))
         {
             return true;
         }
         if (Main.tile[x, y] != null && !Main.tile[x, y].inActive() && Main.tile[x, y].active())
         {
             return false;
         }
         return true;
     }))
     {
         return point16;
     }
     return new Point16(-1, -1);
 }
Exemple #22
0
		public static void AimAbility(Mount mount, Player player, Vector2 mousePosition)
		{
			if (IsModMountData(mount._data))
			{
				mount._data.modMountData.AimAbility(player, mousePosition);
			}
		}
Exemple #23
0
		public Player()
		{
			this.name = string.Empty;
			for (int i = 0; i < 59; i++)
			{
				if (i < 16)
				{
					this.armor[i] = new Item();
					this.armor[i].name = "";
				}
				this.inventory[i] = new Item();
				this.inventory[i].name = "";
			}
			for (int j = 0; j < Chest.maxItems; j++)
			{
				this.bank.item[j] = new Item();
				this.bank.item[j].name = "";
				this.bank2.item[j] = new Item();
				this.bank2.item[j].name = "";
			}
			for (int k = 0; k < 8; k++)
			{
				this.dye[k] = new Item();
			}
			this.grappling[0] = -1;
			this.inventory[0].SetDefaults("Copper Shortsword");
			this.inventory[1].SetDefaults("Copper Pickaxe");
			this.inventory[2].SetDefaults("Copper Axe");
			this.statManaMax = 20;
			if (Main.cEd)
			{
				this.inventory[3].SetDefaults(603, false);
			}
			for (int l = 0; l < 340; l++)
			{
				this.adjTile[l] = false;
				this.oldAdjTile[l] = false;
			}
			this.mount = new Mount();
		}
Exemple #24
0
 public Player()
 {
     int[] array = new int[2];
     this.hurtCooldowns = array;
     //base..ctor();
     this.width = 20;
     this.height = 42;
     this.name = string.Empty;
     for (int i = 0; i < 59; i++)
     {
         if (i < this.armor.Length)
         {
             this.armor[i] = new Item();
             this.armor[i].name = "";
         }
         this.inventory[i] = new Item();
         this.inventory[i].name = "";
     }
     for (int j = 0; j < 40; j++)
     {
         this.bank.item[j] = new Item();
         this.bank.item[j].name = "";
         this.bank2.item[j] = new Item();
         this.bank2.item[j].name = "";
     }
     for (int k = 0; k < this.dye.Length; k++)
     {
         this.dye[k] = new Item();
     }
     for (int l = 0; l < this.miscEquips.Length; l++)
     {
         this.miscEquips[l] = new Item();
     }
     for (int m = 0; m < this.miscDyes.Length; m++)
     {
         this.miscDyes[m] = new Item();
     }
     this.trashItem = new Item();
     this.grappling[0] = -1;
     this.inventory[0].SetDefaults("Copper Shortsword");
     this.inventory[1].SetDefaults("Copper Pickaxe");
     this.inventory[2].SetDefaults("Copper Axe");
     this.statManaMax = 20;
     this.extraAccessory = false;
     if (Main.cEd)
     {
         this.inventory[3].SetDefaults(603, false);
     }
     this.inventory[6].SetDefaults(ItemID.WireCutter);
     this.inventory[7].SetDefaults(ItemID.Wrench);
     this.inventory[8].SetDefaults(ItemID.BlueWrench);
     this.inventory[9].SetDefaults(ItemID.GreenWrench);
     this.inventory[19].SetDefaults(ItemID.Wire);
     this.inventory[18].SetDefaults(ItemID.Actuator);
     for (int n = 0; n < 419; n++)
     {
         this.adjTile[n] = false;
         this.oldAdjTile[n] = false;
     }
     this.hitTile = new HitTile();
     this.mount = new Mount();
 }