Exemplo n.º 1
0
        public override void LoadFromRules()
        {
            base.LoadFromArtEssential();

            if (IsVoxel)
            {
                var vxl = new VoxelDrawable(Rules, Art);
                vxl.OwnerCollection = OwnerCollection;
                vxl.Props           = Props;
                vxl.LoadFromRules();
                vxl.Vxl = VFS.Open <VxlFile>(vxl.Image + ".vxl");
                vxl.Hva = VFS.Open <HvaFile>(vxl.Image + ".hva");
                SubDrawables.Add(vxl);
            }
            else
            {
                var shp = new ShpDrawable(Rules, Art);
                shp.Props           = Props;
                shp.OwnerCollection = OwnerCollection;
                shp.LoadFromRules();
                shp.Shp = VFS.Open <ShpFile>(shp.GetFilename());
                shp.Props.FrameDecider = FrameDeciders.SHPVehicleFrameDecider(shp.StartStandFrame, shp.StandingFrames, shp.Facings);
                if (Ready_Start != -1 && Ready_Count != -1 && Ready_CountNext != -1)
                {
                    shp.Props.FrameDecider = FrameDeciders.InfantryFrameDecider(Ready_Start, Ready_Count, Ready_CountNext);
                }
                SubDrawables.Add(shp);
            }

            if (Rules.ReadBool("Turret") && IsVoxel)
            {
                var turretVxl = VFS.Open <VxlFile>(Image + "TUR.vxl");
                var turretHva = VFS.Open <HvaFile>(Image + "TUR.hva");
                var turret    = new VoxelDrawable(turretVxl, turretHva);
                turret.Props.Offset            = Props.Offset;
                turret.Props.Offset           += new Size(Rules.ReadInt("TurretAnimX"), Rules.ReadInt("TurretAnimY"));
                turret.Props.TurretVoxelOffset = Art.ReadFloat("TurretOffset");
                SubDrawables.Add(turret);

                var barrelVxl = VFS.Open <VxlFile>(Image + "BARL.vxl");
                var barrelHva = VFS.Open <HvaFile>(Image + "BARL.hva");
                if (barrelVxl != null && barrelHva != null)
                {
                    var barrel = new VoxelDrawable(barrelVxl, barrelHva);
                    barrel.Props = turret.Props;
                    SubDrawables.Add(barrel);
                }
            }
        }
Exemplo n.º 2
0
        public override void LoadFromRules()
        {
            base.LoadFromArtEssential();

            if (IsVoxel)
            {
                var vxl = new VoxelDrawable(Rules, Art);
                vxl.OwnerCollection = OwnerCollection;
                vxl.Props           = Props;
                vxl.LoadFromRules();
                vxl.Vxl = VFS.Open <VxlFile>(vxl.Image + ".vxl");
                vxl.Hva = VFS.Open <HvaFile>(vxl.Image + ".hva");
                SubDrawables.Add(vxl);
            }
            else
            {
                var shp = new ShpDrawable(Rules, Art);
                shp.Props           = Props;
                shp.OwnerCollection = OwnerCollection;
                shp.LoadFromRules();
                shp.Shp = VFS.Open <ShpFile>(shp.GetFilename());
                SubDrawables.Add(shp);
            }

            if (Rules.ReadBool("Turret") && IsVoxel)
            {
                var turretVxl = VFS.Open <VxlFile>(Image + "TUR.vxl");
                var turretHva = VFS.Open <HvaFile>(Image + "TUR.hva");
                var turret    = new VoxelDrawable(turretVxl, turretHva);
                turret.Props.Offset            = Props.Offset;
                turret.Props.Offset           += new Size(Rules.ReadInt("TurretAnimX"), Rules.ReadInt("TurretAnimY"));
                turret.Props.TurretVoxelOffset = Art.ReadFloat("TurretOffset");
                SubDrawables.Add(turret);

                var barrelVxl = VFS.Open <VxlFile>(Image + "BARL.vxl");
                var barrelHva = VFS.Open <HvaFile>(Image + "BARL.hva");
                if (barrelVxl != null && barrelHva != null)
                {
                    var barrel = new VoxelDrawable(barrelVxl, barrelHva);
                    barrel.Props = turret.Props;
                    SubDrawables.Add(barrel);
                }
            }
        }
Exemplo n.º 3
0
		public override void LoadFromRules() {
			base.LoadFromArtEssential();

			if (IsVoxel) {
				var vxl = new VoxelDrawable(Rules, Art);
				vxl.OwnerCollection = OwnerCollection;
				vxl.Props = Props;
				vxl.LoadFromRules();
				vxl.Vxl = VFS.Open<VxlFile>(vxl.Image + ".vxl");
				vxl.Hva = VFS.Open<HvaFile>(vxl.Image + ".hva");
				SubDrawables.Add(vxl);
			}
			else {
				var shp = new ShpDrawable(Rules, Art);
				shp.Props = Props;
				shp.OwnerCollection = OwnerCollection;
				shp.LoadFromRules();
				shp.Shp = VFS.Open<ShpFile>(shp.GetFilename());
                shp.Props.FrameDecider = FrameDeciders.SHPVehicleFrameDecider(shp.StartStandFrame, shp.StandingFrames, shp.Facings);
				SubDrawables.Add(shp);
			}

			if (Rules.ReadBool("Turret") && IsVoxel) {
				var turretVxl = VFS.Open<VxlFile>(Image + "TUR.vxl");
				var turretHva = VFS.Open<HvaFile>(Image + "TUR.hva");
				var turret = new VoxelDrawable(turretVxl, turretHva);
				turret.Props.Offset = Props.Offset;
				turret.Props.Offset += new Size(Rules.ReadInt("TurretAnimX"), Rules.ReadInt("TurretAnimY"));
				turret.Props.TurretVoxelOffset = Art.ReadFloat("TurretOffset");
				SubDrawables.Add(turret);

				var barrelVxl = VFS.Open<VxlFile>(Image + "BARL.vxl");
				var barrelHva = VFS.Open<HvaFile>(Image + "BARL.hva");
				if (barrelVxl != null && barrelHva != null) {
					var barrel = new VoxelDrawable(barrelVxl, barrelHva);
					barrel.Props = turret.Props;
					SubDrawables.Add(barrel);
				}
			}
		}
Exemplo n.º 4
0
        public override void LoadFromRules()
        {
            base.LoadFromArtEssential();

            ShpDrawable   shp = null;
            VoxelDrawable vxl = null;

            if (IsVoxel)
            {
                vxl = new VoxelDrawable(Rules, Art);
                vxl.OwnerCollection = OwnerCollection;
                vxl.Props           = Props;
                vxl.LoadFromRules();
                vxl.Vxl = VFS.Open <VxlFile>(vxl.Image + ".vxl");
                vxl.Hva = VFS.Open <HvaFile>(vxl.Image + ".hva");
                SubDrawables.Add(vxl);
            }
            else
            {
                shp                 = new ShpDrawable(Rules, Art);
                shp.Props           = Props;
                shp.OwnerCollection = OwnerCollection;
                shp.LoadFromRules();
                shp.Shp = VFS.Open <ShpFile>(shp.GetFilename());
                shp.Props.FrameDecider = FrameDeciders.SHPVehicleFrameDecider(shp.StartStandFrame, shp.StandingFrames, shp.StartWalkFrame, shp.WalkFrames, shp.Facings);
                SubDrawables.Add(shp);
            }

            if (shp != null || vxl != null)
            {
                if (Rules.ReadBool("Turret"))
                {
                    VoxelDrawable vxlturret = null;
                    ShpDrawable   shpturret = null;
                    var           turretVxl = VFS.Open <VxlFile>(Image + "TUR.vxl");
                    var           turretHva = VFS.Open <HvaFile>(Image + "TUR.hva");

                    if (turretVxl != null && turretHva != null)
                    {
                        vxlturret = new VoxelDrawable(turretVxl, turretHva);
                        vxlturret.Props.Offset            = Props.Offset;
                        vxlturret.Props.Offset           += new Size(Rules.ReadInt("TurretAnimX"), Rules.ReadInt("TurretAnimY"));
                        vxlturret.Props.TurretVoxelOffset = Art.ReadFloat("TurretOffset");
                        vxlturret.Props.Cloakable         = Props.Cloakable;
                        SubDrawables.Add(vxlturret);
                    }

                    if (vxlturret == null && shp != null)
                    {
                        shpturret                 = new ShpDrawable(Rules, Art);
                        shpturret.Props           = (DrawProperties)shp.Props.Clone();
                        shpturret.OwnerCollection = OwnerCollection;
                        shpturret.LoadFromRules();
                        shpturret.Shp = VFS.Open <ShpFile>(shpturret.GetFilename());
                        shpturret.Props.FrameDecider = FrameDeciders.SHPVehicleSHPTurretFrameDecider(shpturret.StartWalkFrame, shpturret.WalkFrames, shpturret.Facings);
                        shpturret.Props.Cloakable    = Props.Cloakable;
                        SubDrawables.Add(shpturret);
                    }

                    var barrelVxl = VFS.Open <VxlFile>(Image + "BARL.vxl");
                    var barrelHva = VFS.Open <HvaFile>(Image + "BARL.hva");
                    if (barrelVxl != null && barrelHva != null)
                    {
                        var barrel = new VoxelDrawable(barrelVxl, barrelHva);
                        if (vxlturret != null)
                        {
                            barrel.Props = vxlturret.Props;
                        }
                        else if (shp != null)
                        {
                            barrel.Props.Offset            = Props.Offset;
                            barrel.Props.Offset           += new Size(Rules.ReadInt("TurretAnimX"), Rules.ReadInt("TurretAnimY"));
                            barrel.Props.TurretVoxelOffset = Art.ReadFloat("TurretOffset");
                        }
                        barrel.Props.Cloakable = Props.Cloakable;
                        SubDrawables.Add(barrel);
                    }
                }
            }
        }
Exemplo n.º 5
0
        public override void LoadFromRules()
        {
            base.LoadFromRules();

            IsBuildingPart  = true;
            InvisibleInGame = Rules.ReadBool("InvisibleInGame") || LampNames.Contains(Name.ToUpper());

            string foundation = Art.ReadString("Foundation", "1x1");

            if (!foundation.Equals("custom", StringComparison.InvariantCultureIgnoreCase))
            {
                int fx = foundation[0] - '0';
                int fy = foundation[2] - '0';
                Foundation = new Size(fx, fy);
            }
            else
            {
                int fx = Art.ReadInt("Foundation.X", 1);
                int fy = Art.ReadInt("Foundation.Y", 1);
                Foundation = new Size(fx, fy);
            }
            Props.SortIndex = Art.ReadInt("NormalYSort") - Art.ReadInt("NormalZAdjust");             // "main" building image before anims

            _baseShp = new ShpDrawable(Rules, Art);
            _baseShp.OwnerCollection = OwnerCollection;
            _baseShp.LoadFromArtEssential();
            _baseShp.Props = Props;
            _baseShp.Shp   = VFS.Open <ShpFile>(_baseShp.GetFilename());

            var extraProps = Props.Clone();

            extraProps.SortIndex = 0;
            foreach (string extraImage in AnimImages)
            {
                var extra = LoadExtraImage(extraImage, extraProps);
                if (extra != null && extra.Shp != null)
                {
                    _anims.Add(extra);

                    var extraDmg = LoadExtraImage(extraImage + "Damaged", extra.Props);
                    if (extraDmg != null && extraDmg.Shp != null)
                    {
                        _animsDamaged.Add(extraDmg);
                    }
                    else                     // no damaged anim --> use normal anim also in damaged state
                    {
                        _animsDamaged.Add(extra);
                    }
                }
            }

            // Starkku: New code for adding fire animations to buildings, supports custom-paletted animations.
            if (OwnerCollection.Engine >= EngineType.RedAlert2)
            {
                LoadFireAnimations();
            }

            // Add turrets
            if (Rules.ReadBool("Turret") && Rules.HasKey("TurretAnim"))
            {
                string   turretName = Rules.ReadString("TurretAnim");
                Drawable turret     = Rules.ReadBool("TurretAnimIsVoxel")
                                        ? (Drawable) new VoxelDrawable(VFS.Open <VxlFile>(turretName + ".vxl"), VFS.Open <HvaFile>(turretName + ".hva"))
                                        : new ShpDrawable(VFS.Open <ShpFile>(turretName + ".shp"));
                turret.Props.Offset       = Props.Offset + new Size(Rules.ReadInt("TurretAnimX"), Rules.ReadInt("TurretAnimY"));
                turret.Props.HasShadow    = Rules.ReadBool("UseTurretShadow");
                turret.Props.FrameDecider = FrameDeciders.TurretFrameDecider;
                turret.Props.ZAdjust      = Rules.ReadInt("TurretAnimZAdjust");
                SubDrawables.Add(turret);

                if (turret is VoxelDrawable && turretName.ToUpper().Contains("TUR"))
                {
                    string barrelName = turretName.Replace("TUR", "BARL");
                    if (VFS.Exists(barrelName + ".vxl"))
                    {
                        var barrel = new VoxelDrawable(VFS.Open <VxlFile>(barrelName + ".vxl"), VFS.Open <HvaFile>(barrelName + ".hva"));
                        SubDrawables.Add(barrel);
                        barrel.Props = turret.Props;
                    }
                }
            }

            // Bib
            if (Art.HasKey("BibShape"))
            {
                var bibImg = Art.ReadString("BibShape") + ".shp";
                if (NewTheater)
                {
                    bibImg = OwnerCollection.ApplyNewTheaterIfNeeded(bibImg, bibImg);
                }
                var bibShp = VFS.Open <ShpFile>(bibImg);
                if (bibShp != null)
                {
                    var bib = new ShpDrawable(bibShp);
                    bib.Props = this.Props.Clone();
                    bib.Flat  = true;
                    SubDrawables.Add(bib);
                }
            }

            // Powerup slots, at most 3
            for (int i = 1; i <= 3; i++)
            {
                if (!Art.HasKey(String.Format("PowerUp{0}LocXX", i)))
                {
                    break;
                }
                _powerupSlots.Add(new PowerupSlot {
                    X     = Art.ReadInt(String.Format("PowerUp{0}LocXX", i)),
                    Y     = Art.ReadInt(String.Format("PowerUp{0}LocYY", i)),
                    Z     = Art.ReadInt(String.Format("PowerUp{0}LocZZ", i)),
                    YSort = Art.ReadInt(String.Format("PowerUp{0}LocYSort", i)),
                });
            }
        }
Exemplo n.º 6
0
		public override void LoadFromRules() {
			base.LoadFromRules();

			IsBuildingPart = true;
			InvisibleInGame = Rules.ReadBool("InvisibleInGame") || LampNames.Contains(Name.ToUpper());
			string foundation = Art.ReadString("Foundation", "1x1");
			if (!foundation.Equals("custom", StringComparison.InvariantCultureIgnoreCase)) {
				int fx = foundation[0] - '0';
				int fy = foundation[2] - '0';
				Foundation = new Size(fx, fy);
			}
			else {
				int fx = Art.ReadInt("Foundation.X", 1);
				int fy = Art.ReadInt("Foundation.Y", 1);
				Foundation = new Size(fx, fy);
			}
			Props.SortIndex = Art.ReadInt("NormalYSort") - Art.ReadInt("NormalZAdjust"); // "main" building image before anims
			Props.ZShapePointMove = Art.ReadPoint("ZShapePointMove");

			_baseShp = new ShpDrawable(Rules, Art);
			_baseShp.OwnerCollection = OwnerCollection;
			_baseShp.LoadFromArtEssential();
			_baseShp.Props = Props;
			_baseShp.Shp = VFS.Open<ShpFile>(_baseShp.GetFilename());

			var extraProps = Props.Clone();
			extraProps.SortIndex = 0;
			foreach (string extraImage in AnimImages) {

				var extra = LoadExtraImage(extraImage, extraProps);
				if (extra != null && extra.Shp != null) {
					_anims.Add(extra);

					var extraDmg = LoadExtraImage(extraImage + "Damaged", extra.Props);
					if (extraDmg != null && extraDmg.Shp != null)
						_animsDamaged.Add(extraDmg);
					else // no damaged anim --> use normal anim also in damaged state
						_animsDamaged.Add(extra);
				}
			}

			// Starkku: New code for adding fire animations to buildings, supports custom-paletted animations.
			if (OwnerCollection.Engine >= EngineType.RedAlert2)
				LoadFireAnimations();

			// Add turrets
			if (Rules.ReadBool("Turret") && Rules.HasKey("TurretAnim")) {
				string turretName = Rules.ReadString("TurretAnim");
                // Starkku: NewTheater/generic image fallback support for turrets.
                string turretNameShp = NewTheater ? OwnerCollection.ApplyNewTheaterIfNeeded(turretName, turretName) : turretName;
				turretNameShp += ".shp";
				Drawable turret = Rules.ReadBool("TurretAnimIsVoxel")
					? (Drawable)new VoxelDrawable(VFS.Open<VxlFile>(turretName + ".vxl"), VFS.Open<HvaFile>(turretName + ".hva"))
					: new ShpDrawable(VFS.Open<ShpFile>(turretNameShp));
				turret.Props.Offset = Props.Offset + new Size(Rules.ReadInt("TurretAnimX"), Rules.ReadInt("TurretAnimY"));
				turret.Props.HasShadow = Rules.ReadBool("UseTurretShadow");
				turret.Props.FrameDecider = FrameDeciders.TurretFrameDecider;
				turret.Props.ZAdjust = Rules.ReadInt("TurretAnimZAdjust");
				SubDrawables.Add(turret);

				if (turret is VoxelDrawable && turretName.ToUpper().Contains("TUR")) {
					string barrelName = turretName.Replace("TUR", "BARL");
					if (VFS.Exists(barrelName + ".vxl")) {
						var barrel = new VoxelDrawable(VFS.Open<VxlFile>(barrelName + ".vxl"), VFS.Open<HvaFile>(barrelName + ".hva"));
						SubDrawables.Add(barrel);
						barrel.Props = turret.Props;
					}
				}
			}

			// Bib
			if (Art.HasKey("BibShape")) {
				var bibImg = Art.ReadString("BibShape") + ".shp";
				if (NewTheater)
					bibImg = OwnerCollection.ApplyNewTheaterIfNeeded(bibImg, bibImg);
				var bibShp = VFS.Open<ShpFile>(bibImg);
				if (bibShp != null) {
					var bib = new ShpDrawable(bibShp);
					bib.Props = this.Props.Clone();
					bib.Flat = true;
					SubDrawables.Add(bib);
				}
			}

			// Powerup slots, at most 3
			for (int i = 1; i <= 3; i++) {
				if (!Art.HasKey(String.Format("PowerUp{0}LocXX", i))) break;
				_powerupSlots.Add(new PowerupSlot {
					X = Art.ReadInt(String.Format("PowerUp{0}LocXX", i)),
					Y = Art.ReadInt(String.Format("PowerUp{0}LocYY", i)),
					Z = Art.ReadInt(String.Format("PowerUp{0}LocZZ", i)),
					YSort = Art.ReadInt(String.Format("PowerUp{0}LocYSort", i)),
				});
			}
		}