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); } } }
public override void LoadFromRules() { base.LoadFromArtEssential(); 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"); }
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 (ModConfig.ActiveConfig.ExtraOptions.FirstOrDefault() != null && ModConfig.ActiveConfig.ExtraOptions.FirstOrDefault().EnableRandomInfantryFacing) { randomDir = random.Next(256); } Props.FrameDecider = FrameDeciders.InfantryFrameDecider(Ready_Start, Ready_Count, Ready_CountNext, randomDir); } if (Props.HasShadow && shadow && !Props.Cloakable) { ShpRenderer.DrawShadow(obj, Shp, Props, ds); } ShpRenderer.Draw(Shp, obj, this, Props, ds, Props.Cloakable ? 50 : 0); }
protected override void LoadDrawable(Drawable drawable) { switch (Type) { case CollectionType.Aircraft: case CollectionType.Vehicle: LoadUnitDrawable((UnitDrawable)drawable); break; case CollectionType.Building: LoadBuildingDrawable((BuildingDrawable)drawable); break; case CollectionType.Infantry: case CollectionType.Overlay: case CollectionType.Smudge: case CollectionType.Terrain: LoadSimpleDrawable((ShpDrawable)drawable); break; case CollectionType.Animation: LoadAnimDrawable((AnimDrawable)drawable); break; default: throw new InvalidEnumArgumentException(); } // overrides from the modconfig var cfgOverrides = ModConfig.ActiveConfig.ObjectOverrides.Where(ovr => // matches collection (ovr.CollectionTypes & Type) == Type && // matches collection (ovr.TheaterTypes & Theater) == Theater && // matches object regex Regex.IsMatch(drawable.Name, ovr.ObjRegex, RegexOptions.IgnoreCase)) .OrderByDescending(o => o.Priority); foreach (var cfgOverride in cfgOverrides) { Logger.Debug("Object {0} receives overrides from regex {1}", drawable.Name, cfgOverride.ObjRegex); if (cfgOverride.Lighting != LightingType.Default) { drawable.Props.LightingType = cfgOverride.Lighting; } if (cfgOverride.Palette != PaletteType.Default) { drawable.Props.PaletteType = cfgOverride.Palette; drawable.Props.CustomPaletteName = cfgOverride.CustomPaletteFile; } if (!string.IsNullOrWhiteSpace(cfgOverride.FrameDeciderCode) && !_cannotCompile) { try { var fdc = FrameDeciders.GetOverrideFrameDecider(cfgOverride); if (fdc != null) { drawable.Props.FrameDecider = fdc; } } catch (TypeLoadException exc) { _cannotCompile = true; Logger.Error("Custom framedecider could not be compiled. You need .NET 4.5 for this." + " Functionality will be unavailable.\r\n{0}", exc); } } } }
public AlphaDrawable(ShpFile alphaShpFile) : base(alphaShpFile) { Props.Offset = new Point(0, 15); Props.FrameDecider = FrameDeciders.AlphaImageFrameDecider(Shp); }
public AlphaDrawable(IniFile.IniSection rules, IniFile.IniSection art, ShpFile alphaShpFile) : base(rules, art, alphaShpFile) { Props.Offset = new Point(0, 15); Props.FrameDecider = FrameDeciders.AlphaImageFrameDecider(Shp); }
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); } } } }