public override void Draw(GameObject obj, DrawingSurface ds, bool shadows = true) { terrainShp = new ShpDrawable(_config, _vfs, Rules, Art); terrainShp.OwnerCollection = OwnerCollection; terrainShp.LoadFromArtEssential(); terrainShp.Props = Props; terrainShp.Shp = _vfs.Open <ShpFile>(terrainShp.GetFilename()); foreach (var sub in SubDrawables.OfType <AlphaDrawable>()) { sub.Draw(obj, ds, false); } if (shadows) { terrainShp.DrawShadow(obj, ds); } terrainShp.Draw(obj, ds, false); }
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); } }