Ejemplo n.º 1
0
        public override void Draw(GameObject obj, DrawingSurface ds, bool shadow = true)
        {
            if (InvisibleInGame || Shp == null)
            {
                return;
            }
            Size onBridgeOffset = Size.Empty;

            if (OwnerCollection != null && OwnerCollection.Type == CollectionType.Infantry)
            {
                int randomDir = -1;
                if (_config.ExtraOptions.FirstOrDefault() != null && _config.ExtraOptions.FirstOrDefault().EnableRandomInfantryFacing)
                {
                    randomDir = Rand.Next(256);
                }
                Props.FrameDecider = FrameDeciders.InfantryFrameDecider(Ready_Start, Ready_Count, Ready_CountNext, randomDir);
                if (obj is OwnableObject && (obj as OwnableObject).OnBridge)
                {
                    onBridgeOffset = new Size(0, -4 * _config.TileHeight / 2);
                }
            }

            Props.Offset += onBridgeOffset;
            if (Props.HasShadow && shadow && !Props.Cloakable)
            {
                _renderer.DrawShadow(obj, Shp, Props, ds);
            }
            _renderer.Draw(Shp, obj, this, Props, ds, Props.Cloakable ? 50 : 0);
            Props.Offset -= onBridgeOffset;
        }
Ejemplo n.º 2
0
 public override void Draw(GameObject obj, DrawingSurface ds, bool shadow = true)
 {
     if (InvisibleInGame || Shp == null)
     {
         return;
     }
     if (OwnerCollection != null && OwnerCollection.Type == CollectionType.Infantry)
     {
         int randomDir = -1;
         if (_config.ExtraOptions.FirstOrDefault() != null && _config.ExtraOptions.FirstOrDefault().EnableRandomInfantryFacing)
         {
             randomDir = Rand.Next(256);
         }
         Props.FrameDecider = FrameDeciders.InfantryFrameDecider(Ready_Start, Ready_Count, Ready_CountNext, randomDir);
     }
     if (Props.HasShadow && shadow && !Props.Cloakable)
     {
         _renderer.DrawShadow(obj, Shp, Props, ds);
     }
     _renderer.Draw(Shp, obj, this, Props, ds, Props.Cloakable ? 50 : 0);
 }
Ejemplo n.º 3
0
        public override void LoadFromRules()
        {
            base.LoadFromArtEssential();

            _animProps = new Animation(Name);
            _animProps.LoadArt(Art);

            _translucency = Art.ReadBool("Translucent") ? 50 : Art.ReadInt("Translucency", 0);

            Props.HasShadow = Art.ReadBool("Shadow", Defaults.GetShadowAssumption(CollectionType.Animation));

            Props.FrameDecider = FrameDeciders.LoopFrameDecider(
                Art.ReadInt("LoopStart"),
                Art.ReadInt("LoopEnd", 1));

            Flat = Art.ReadBool("DrawFlat", Defaults.GetFlatnessAssumption(OwnerCollection.Type)) ||
                   Art.ReadBool("Flat");

            if (!_animProps.ShouldUseCellDrawer)
            {
                Props.PaletteType = PaletteType.Anim;
            }
        }
Ejemplo n.º 4
0
        public override void LoadFromRules()
        {
            base.LoadFromArtEssential();

            ShpDrawable   shp = null;
            VoxelDrawable vxl = null;

            if (IsVoxel)
            {
                vxl = new VoxelDrawable(_config, _vfs, 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(_config, _vfs, 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, _config.Engine);
                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(_config, 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(_config, _vfs, 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(_config, 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);
                    }
                }
            }
        }
Ejemplo n.º 5
0
 public AlphaDrawable(ModConfig config, VirtualFileSystem vfs, IniFile.IniSection rules, IniFile.IniSection art, ShpFile alphaShpFile)
     : base(config, vfs, rules, art, alphaShpFile)
 {
     Props.Offset       = new Point(0, 15);
     Props.FrameDecider = FrameDeciders.AlphaImageFrameDecider(Shp);
 }
Ejemplo n.º 6
0
 public AlphaDrawable(ShpRenderer renderer, ShpFile alphaShpFile) : base(renderer, alphaShpFile)
 {
     Props.Offset       = new Point(0, 15);
     Props.FrameDecider = FrameDeciders.AlphaImageFrameDecider(Shp);
 }
Ejemplo n.º 7
0
        public override void Draw(GameObject obj, DrawingSurface ds, bool shadows = true)
        {
            if (InvisibleInGame)
            {
                return;
            }

            // RA2/YR building rubble
            if (obj is StructureObject && (obj as StructureObject).Health == 0 && _config.Engine >= EngineType.RedAlert2 && _baseShp.Shp != null)
            {
                ShpDrawable rubble = (ShpDrawable)_baseShp.Clone();
                rubble.Props = _baseShp.Props.Clone();
                rubble.Shp.Initialize();
                if (rubble.Shp.NumImages >= 8)
                {
                    rubble.Props.PaletteOverride = OwnerCollection.Palettes.IsoPalette;
                    rubble.Props.FrameDecider    = FrameDeciders.BuildingRubbleFrameDecider(rubble.Shp.NumImages);
                    if (shadows)
                    {
                        rubble.DrawShadow(obj, ds);
                    }
                    rubble.Draw(obj, ds, false);
                    return;
                }
            }

            bool isDamaged = false;
            bool isOnFire  = false;

            if (obj is StructureObject)
            {
                int health = (obj as StructureObject).Health;
                if (health <= _conditionYellowHealth)
                {
                    isDamaged = true;
                    if (health > _conditionRedHealth && _canBeOccupied && _techLevel < 1)
                    {
                        isDamaged = false;
                    }
                }
                _baseShp.Props.FrameDecider = FrameDeciders.BaseBuildingFrameDecider(isDamaged);

                if (_config.Engine >= EngineType.RedAlert2)
                {
                    if (isDamaged)
                    {
                        isOnFire = true;
                    }
                    if (health > _conditionRedHealth && _canBeOccupied)
                    {
                        isOnFire = false;
                    }
                }
            }

            var drawList = new List <Drawable>();

            drawList.Add(_baseShp);

            if (obj is StructureObject && isDamaged)
            {
                drawList.AddRange(_animsDamaged);
                if (isOnFire)
                {
                    drawList.AddRange(_fires);
                }
            }
            else
            {
                drawList.AddRange(_anims);
            }

            drawList.AddRange(SubDrawables);             // bib

            /* order:
             * ActiveAnims+Flat=yes
             * BibShape
             * ActiveAnims (+ZAdjust=0)
             * Building
             * ActiveAnims+ZAdjust=-32 */
            drawList = drawList.OrderBy(d => d.Flat ? -1 : 1).ThenBy(d => d.Props.SortIndex).ToList();

            foreach (var d in drawList)
            {
                if (shadows)
                {
                    d.DrawShadow(obj, ds);
                }
                d.Draw(obj, ds, false);
            }

            var strObj = obj as StructureObject;

            if (!strObj.Upgrade1.Equals("None", StringComparison.InvariantCultureIgnoreCase))
            {
                AnimDrawable up1 = LoadUpgrade(strObj, 0, Props.Clone());
                up1.Draw(obj, ds, false);
            }

            if (!strObj.Upgrade2.Equals("None", StringComparison.InvariantCultureIgnoreCase))
            {
                AnimDrawable up2 = LoadUpgrade(strObj, 1, Props.Clone());
                up2.Draw(obj, ds, false);
            }

            if (!strObj.Upgrade3.Equals("None", StringComparison.InvariantCultureIgnoreCase))
            {
                AnimDrawable up3 = LoadUpgrade(strObj, 2, Props.Clone());
                up3.Draw(obj, ds, false);
            }
        }