Exemplo n.º 1
0
        ///<summary>Inserts one MountDef into the database.  Provides option to use the existing priKey.</summary>
        internal static long Insert(MountDef mountDef, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                mountDef.MountDefNum = ReplicationServers.GetKey("mountdef", "MountDefNum");
            }
            string command = "INSERT INTO mountdef (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "MountDefNum,";
            }
            command += "Description,ItemOrder,IsRadiograph,Width,Height) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(mountDef.MountDefNum) + ",";
            }
            command +=
                "'" + POut.String(mountDef.Description) + "',"
                + POut.Int(mountDef.ItemOrder) + ","
                + POut.Bool(mountDef.IsRadiograph) + ","
                + POut.Int(mountDef.Width) + ","
                + POut.Int(mountDef.Height) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                mountDef.MountDefNum = Db.NonQ(command, true);
            }
            return(mountDef.MountDefNum);
        }
Exemplo n.º 2
0
 ///<summary>Inserts one MountDef into the database.  Returns the new priKey.</summary>
 internal static long Insert(MountDef mountDef)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         mountDef.MountDefNum = DbHelper.GetNextOracleKey("mountdef", "MountDefNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(mountDef, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     mountDef.MountDefNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(mountDef, false));
     }
 }
Exemplo n.º 3
0
 ///<summary>Inserts one MountDef into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(MountDef mountDef,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         mountDef.MountDefNum=ReplicationServers.GetKey("mountdef","MountDefNum");
     }
     string command="INSERT INTO mountdef (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="MountDefNum,";
     }
     command+="Description,ItemOrder,IsRadiograph,Width,Height) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(mountDef.MountDefNum)+",";
     }
     command+=
          "'"+POut.String(mountDef.Description)+"',"
         +    POut.Int   (mountDef.ItemOrder)+","
         +    POut.Bool  (mountDef.IsRadiograph)+","
         +    POut.Int   (mountDef.Width)+","
         +    POut.Int   (mountDef.Height)+")";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         mountDef.MountDefNum=Db.NonQ(command,true);
     }
     return mountDef.MountDefNum;
 }
Exemplo n.º 4
0
 ///<summary>Inserts one MountDef into the database.  Returns the new priKey.</summary>
 internal static long Insert(MountDef mountDef)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         mountDef.MountDefNum=DbHelper.GetNextOracleKey("mountdef","MountDefNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(mountDef,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     mountDef.MountDefNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(mountDef,false);
     }
 }
Exemplo n.º 5
0
        ///<summary>Inserts one MountDef into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(MountDef mountDef, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO mountdef (";

            if (!useExistingPK && isRandomKeys)
            {
                mountDef.MountDefNum = ReplicationServers.GetKeyNoCache("mountdef", "MountDefNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "MountDefNum,";
            }
            command += "Description,ItemOrder,IsRadiograph,Width,Height) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(mountDef.MountDefNum) + ",";
            }
            command +=
                "'" + POut.String(mountDef.Description) + "',"
                + POut.Int(mountDef.ItemOrder) + ","
                + POut.Bool(mountDef.IsRadiograph) + ","
                + POut.Int(mountDef.Width) + ","
                + POut.Int(mountDef.Height) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                mountDef.MountDefNum = Db.NonQ(command, true, "MountDefNum", "mountDef");
            }
            return(mountDef.MountDefNum);
        }
Exemplo n.º 6
0
 ///<summary></summary>
 public FormMountDefEdit(MountDef mountDefCur)
 {
     //
     // Required for Windows Form Designer support
     //
     MountDefCur = mountDefCur;
     InitializeComponent();
     Lan.F(this);
 }
Exemplo n.º 7
0
        private void butAdd_Click(object sender, System.EventArgs e)
        {
            MountDef         mount = new MountDef();
            FormMountDefEdit FormM = new FormMountDefEdit(mount);

            FormM.IsNew = true;
            FormM.ShowDialog();
            FillList();
            changed = true;
        }
Exemplo n.º 8
0
        List <LoaderError> CheckTextures(MountDef def)
        {
            var ret = new List <LoaderError>();

            if (def.Front.Normal == null && def.Back.Normal == null)
            {
                ret.Add(new LoaderError(def.Mod, "Front.Normal and Back.Normal of MountDef " + def + " are both null."));
            }

            return(ret);
        }
Exemplo n.º 9
0
        ///<summary>Updates one MountDef in the database.</summary>
        internal static void Update(MountDef mountDef)
        {
            string command = "UPDATE mountdef SET "
                             + "Description = '" + POut.String(mountDef.Description) + "', "
                             + "ItemOrder   =  " + POut.Int(mountDef.ItemOrder) + ", "
                             + "IsRadiograph=  " + POut.Bool(mountDef.IsRadiograph) + ", "
                             + "Width       =  " + POut.Int(mountDef.Width) + ", "
                             + "Height      =  " + POut.Int(mountDef.Height) + " "
                             + "WHERE MountDefNum = " + POut.Long(mountDef.MountDefNum);

            Db.NonQ(command);
        }
Exemplo n.º 10
0
        ///<summary>Updates one MountDef in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
        public static bool Update(MountDef mountDef, MountDef oldMountDef)
        {
            string command = "";

            if (mountDef.Description != oldMountDef.Description)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Description = '" + POut.String(mountDef.Description) + "'";
            }
            if (mountDef.ItemOrder != oldMountDef.ItemOrder)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ItemOrder = " + POut.Int(mountDef.ItemOrder) + "";
            }
            if (mountDef.IsRadiograph != oldMountDef.IsRadiograph)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "IsRadiograph = " + POut.Bool(mountDef.IsRadiograph) + "";
            }
            if (mountDef.Width != oldMountDef.Width)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Width = " + POut.Int(mountDef.Width) + "";
            }
            if (mountDef.Height != oldMountDef.Height)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Height = " + POut.Int(mountDef.Height) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE mountdef SET " + command
                      + " WHERE MountDefNum = " + POut.Long(mountDef.MountDefNum);
            Db.NonQ(command);
            return(true);
        }
Exemplo n.º 11
0
        ///<summary></summary>
        public static void Insert(MountDef def)
        {
            string command = "INSERT INTO mountdef (Description,ItemOrder,IsRadiograph,Width,Height"
                             + ") VALUES("
                             + "'" + POut.PString(def.Description) + "', "
                             + "'" + POut.PInt(def.ItemOrder) + "', "
                             + "'" + POut.PBool(def.IsRadiograph) + "', "
                             + "'" + POut.PInt(def.Width) + "', "
                             + "'" + POut.PInt(def.Height) + "')";

            def.MountDefNum = General.NonQ(command, true);
        }
Exemplo n.º 12
0
        ///<summary></summary>
        public static void Update(MountDef def)
        {
            string command = "UPDATE mountdef SET "
                             + "Description = '" + POut.PString(def.Description) + "'"
                             + ",ItemOrder = '" + POut.PInt(def.ItemOrder) + "'"
                             + ",IsRadiograph = '" + POut.PBool(def.IsRadiograph) + "'"
                             + ",Width = '" + POut.PInt(def.Width) + "'"
                             + ",Height = '" + POut.PInt(def.Height) + "'"
                             + " WHERE MountDefNum  ='" + POut.PInt(def.MountDefNum) + "'";

            General.NonQ(command);
        }
Exemplo n.º 13
0
 ///<summary>Inserts one MountDef into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(MountDef mountDef)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(mountDef, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             mountDef.MountDefNum = DbHelper.GetNextOracleKey("mountdef", "MountDefNum");                  //Cacheless method
         }
         return(InsertNoCache(mountDef, true));
     }
 }
Exemplo n.º 14
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<MountDef> TableToList(DataTable table){
			List<MountDef> retVal=new List<MountDef>();
			MountDef mountDef;
			for(int i=0;i<table.Rows.Count;i++) {
				mountDef=new MountDef();
				mountDef.MountDefNum = PIn.Long  (table.Rows[i]["MountDefNum"].ToString());
				mountDef.Description = PIn.String(table.Rows[i]["Description"].ToString());
				mountDef.ItemOrder   = PIn.Int   (table.Rows[i]["ItemOrder"].ToString());
				mountDef.IsRadiograph= PIn.Bool  (table.Rows[i]["IsRadiograph"].ToString());
				mountDef.Width       = PIn.Int   (table.Rows[i]["Width"].ToString());
				mountDef.Height      = PIn.Int   (table.Rows[i]["Height"].ToString());
				retVal.Add(mountDef);
			}
			return retVal;
		}
Exemplo n.º 15
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <MountDef> TableToList(DataTable table)
        {
            List <MountDef> retVal = new List <MountDef>();
            MountDef        mountDef;

            foreach (DataRow row in table.Rows)
            {
                mountDef              = new MountDef();
                mountDef.MountDefNum  = PIn.Long(row["MountDefNum"].ToString());
                mountDef.Description  = PIn.String(row["Description"].ToString());
                mountDef.ItemOrder    = PIn.Int(row["ItemOrder"].ToString());
                mountDef.IsRadiograph = PIn.Bool(row["IsRadiograph"].ToString());
                mountDef.Width        = PIn.Int(row["Width"].ToString());
                mountDef.Height       = PIn.Int(row["Height"].ToString());
                retVal.Add(mountDef);
            }
            return(retVal);
        }
Exemplo n.º 16
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <MountDef> TableToList(DataTable table)
        {
            List <MountDef> retVal = new List <MountDef>();
            MountDef        mountDef;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                mountDef              = new MountDef();
                mountDef.MountDefNum  = PIn.Long(table.Rows[i]["MountDefNum"].ToString());
                mountDef.Description  = PIn.String(table.Rows[i]["Description"].ToString());
                mountDef.ItemOrder    = PIn.Int(table.Rows[i]["ItemOrder"].ToString());
                mountDef.IsRadiograph = PIn.Bool(table.Rows[i]["IsRadiograph"].ToString());
                mountDef.Width        = PIn.Int(table.Rows[i]["Width"].ToString());
                mountDef.Height       = PIn.Int(table.Rows[i]["Height"].ToString());
                retVal.Add(mountDef);
            }
            return(retVal);
        }
Exemplo n.º 17
0
        internal void FillVanilla()
        {
            if (!hasReset)
            {
                Reset();
                hasReset = true;
            }

            FillingVanilla = true;

            Mount.Initialize();

            MountDef def;

            for (int id = MinVanillaID; id < MaxVanillaID; id++)
            {
                if (id == -1)
                {
                    continue;
                }

                var index = Array.IndexOf(IDValues, id);
                if (index == -1)
                {
                    continue;
                }

                def = new MountDef(IDNames[index], null);

                DefsByType.Add(id, def);
                VanillaDefsByName.Add(IDNames[index], def);

                def.Mod = PrismApi.VanillaInfo;

                CopyEntityToDef(id, Mount.mounts[id], def); // TEntityDef is a class -> dictionary entries are updated, too

                def.InternalName = IDNames[index];
            }

            FillingVanilla = false;
        }
Exemplo n.º 18
0
        ///<summary>Gets a list of all MountDefs when program first opens.  Also refreshes MountItemDefs and attaches all items to the appropriate mounts.</summary>
        public static void Refresh()
        {
            MountItemDefs.Refresh();
            string    command = "SELECT * FROM mountdef ORDER BY ItemOrder";
            DataTable table   = General.GetTable(command);

            Listt = new List <MountDef>();
            MountDef mount;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                mount              = new MountDef();
                mount.MountDefNum  = PIn.PInt(table.Rows[i][0].ToString());
                mount.Description  = PIn.PString(table.Rows[i][1].ToString());
                mount.ItemOrder    = PIn.PInt(table.Rows[i][2].ToString());
                mount.IsRadiograph = PIn.PBool(table.Rows[i][3].ToString());
                mount.Width        = PIn.PInt(table.Rows[i][4].ToString());
                mount.Height       = PIn.PInt(table.Rows[i][5].ToString());
                Listt.Add(mount);
            }
        }
Exemplo n.º 19
0
        List <LoaderError> LoadTextures(MountDef def)
        {
            var ret = new List <LoaderError>();

            Texture2D main = null;

            if (def.Back.Normal != null)
            {
                var t = def.Back.Normal();

                if (t == null)
                {
                    ret.Add(new LoaderError(def.Mod, "Return value of Front.Back of MountDef " + def + " is null."));
                }

                main = t;
            }
            if (def.Front.Normal != null)
            {
                var t = def.Front.Normal();

                if (t == null && main == null) // don't return it if the other error has been returned, too
                {
                    ret.Add(new LoaderError(def.Mod, "Return value of Front.Normal of MountDef " + def + " is null."));
                }

                if (t != null)
                {
                    main = t;
                }
            }

            if (main != null)
            {
                def.texSize = new Point(main.Width, main.Height);
            }

            return(ret);
        }
Exemplo n.º 20
0
 ///<summary>Returns true if Update(MountDef,MountDef) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(MountDef mountDef, MountDef oldMountDef)
 {
     if (mountDef.Description != oldMountDef.Description)
     {
         return(true);
     }
     if (mountDef.ItemOrder != oldMountDef.ItemOrder)
     {
         return(true);
     }
     if (mountDef.IsRadiograph != oldMountDef.IsRadiograph)
     {
         return(true);
     }
     if (mountDef.Width != oldMountDef.Width)
     {
         return(true);
     }
     if (mountDef.Height != oldMountDef.Height)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 21
0
        internal void FillVanilla()
        {
            if (!hasReset)
            {
                Reset();
                hasReset = true;
            }

            FillingVanilla = true;

            Mount.Initialize();

            MountDef def;

            for (int id = MinVanillaID; id < MaxVanillaID; id++)
            {
                if (id == -1)
                    continue;

                var index = Array.IndexOf(IDValues, id);
                if (index == -1)
                    continue;

                def = new MountDef(IDNames[index], null);

                DefsByType.Add(id, def);
                VanillaDefsByName.Add(IDNames[index], def);

                def.Mod = PrismApi.VanillaInfo;

                CopyEntityToDef(id, Mount.mounts[id], def); // TEntityDef is a class -> dictionary entries are updated, too

                def.InternalName = IDNames[index];
            }

            FillingVanilla = false;
        }
Exemplo n.º 22
0
		///<summary>Updates one MountDef in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.</summary>
		public static void Update(MountDef mountDef,MountDef oldMountDef){
			string command="";
			if(mountDef.Description != oldMountDef.Description) {
				if(command!=""){ command+=",";}
				command+="Description = '"+POut.String(mountDef.Description)+"'";
			}
			if(mountDef.ItemOrder != oldMountDef.ItemOrder) {
				if(command!=""){ command+=",";}
				command+="ItemOrder = "+POut.Int(mountDef.ItemOrder)+"";
			}
			if(mountDef.IsRadiograph != oldMountDef.IsRadiograph) {
				if(command!=""){ command+=",";}
				command+="IsRadiograph = "+POut.Bool(mountDef.IsRadiograph)+"";
			}
			if(mountDef.Width != oldMountDef.Width) {
				if(command!=""){ command+=",";}
				command+="Width = "+POut.Int(mountDef.Width)+"";
			}
			if(mountDef.Height != oldMountDef.Height) {
				if(command!=""){ command+=",";}
				command+="Height = "+POut.Int(mountDef.Height)+"";
			}
			if(command==""){
				return;
			}
			command="UPDATE mountdef SET "+command
				+" WHERE MountDefNum = "+POut.Long(mountDef.MountDefNum);
			Db.NonQ(command);
		}
Exemplo n.º 23
0
		///<summary>Updates one MountDef in the database.</summary>
		public static void Update(MountDef mountDef){
			string command="UPDATE mountdef SET "
				+"Description = '"+POut.String(mountDef.Description)+"', "
				+"ItemOrder   =  "+POut.Int   (mountDef.ItemOrder)+", "
				+"IsRadiograph=  "+POut.Bool  (mountDef.IsRadiograph)+", "
				+"Width       =  "+POut.Int   (mountDef.Width)+", "
				+"Height      =  "+POut.Int   (mountDef.Height)+" "
				+"WHERE MountDefNum = "+POut.Long(mountDef.MountDefNum);
			Db.NonQ(command);
		}
Exemplo n.º 24
0
 ///<summary>Inserts one MountDef into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(MountDef mountDef)
 {
     return(InsertNoCache(mountDef, false));
 }
Exemplo n.º 25
0
 void CopySetProperties(MountDef def)
 {
     MountSets.Cart[def.Type] = def.IsMinecart;
 }
Exemplo n.º 26
0
        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
                );
        }
Exemplo n.º 27
0
        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;
        }
Exemplo n.º 28
0
        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
            );
        }
Exemplo n.º 29
0
        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;
        }
Exemplo n.º 30
0
 void CopySetProperties(MountDef def)
 {
     MountSets.Cart[def.Type] = def.IsMinecart;
 }
Exemplo n.º 31
0
        List<LoaderError> CheckTextures(MountDef def)
        {
            var ret = new List<LoaderError>();

            if (def.Front.Normal == null && def.Back.Normal == null)
                ret.Add(new LoaderError(def.Mod, "Front.Normal and Back.Normal of MountDef " + def + " are both null."));

            return ret;
        }
Exemplo n.º 32
0
        List<LoaderError> LoadTextures(MountDef def)
        {
            var ret = new List<LoaderError>();

            Texture2D main = null;
            if (def.Back.Normal != null)
            {
                var t = def.Back.Normal();

                if (t == null)
                    ret.Add(new LoaderError(def.Mod, "Return value of Front.Back of MountDef " + def + " is null."));

                main = t;
            }
            if (def.Front.Normal != null)
            {
                var t = def.Front.Normal();

                if (t == null && main == null) // don't return it if the other error has been returned, too
                    ret.Add(new LoaderError(def.Mod, "Return value of Front.Normal of MountDef " + def + " is null."));

                if (t != null)
                    main = t;
            }

            if (main != null)
                def.texSize = new Point(main.Width, main.Height);

            return ret;
        }