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)), }); } }
// Token: 0x0600423A RID: 16954 RVA: 0x00170F7C File Offset: 0x0016F17C public override bool GetValue() { bool result; if (!Application.isPlaying) { result = false; } else { if (this.count < 1) { return(false); } string[] array = this.extraIds.Trim().Split(new char[] { ',' }); for (int i = 0; i < this.count; i++) { Props props = Game.Data.Get <Props>(sourceId) ?? Randomizer.GetOneFromData <Props>(sourceId); if (props == null) { return(false); } Props props2 = props.Clone <Props>(); props2.Id = "$fp_" + props.Id; props2.Name = string.Format("<color=#FFEEDD>{0}+</color>", props.Name); if (props2.PropsEffect == null) { props2.PropsEffect = new List <PropsEffect>(); } if (props2.BuffList == null) { props2.BuffList = new List <string>(); } if (props2.PropsEffectDescription == null) { props2.PropsEffectDescription = ""; } foreach (string id in array) { Props props3 = Game.Data.Get <Props>(id) ?? Randomizer.GetOneFromData <Props>(id); if (props3 == null) { continue; } if (props3.PropsEffect != null) { props2.PropsEffect.AddRange(props3.PropsEffect); } if (props3.BuffList != null) { props2.BuffList.AddRange(props3.BuffList); } if (!props3.PropsEffectDescription.IsNullOrEmpty()) { Props props4 = props2; props4.PropsEffectDescription += string.Format("\n附加:{0}", props3.PropsEffectDescription); } } ModExtensionSaveData.AddUniqueItem(props2); Game.GameData.Inventory.Add(props2.Id, 1, true); if (base.Graph != null && (bool)base.Graph.GetVariable("IsShowMessage")) { this.ShowMessage(props2.Name, 1); } } result = true; } return(result); }
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); } }
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"); _canBeOccupied = Rules.ReadBool("CanBeOccupied"); _techLevel = Rules.ReadInt("TechLevel"); _conditionYellowHealth = 128; _conditionRedHealth = 64; IniFile.IniSection audioVisual = OwnerCollection.Rules.GetOrCreateSection("AudioVisual"); if (audioVisual != null) { if (audioVisual.HasKey("ConditionYellow")) { int conditionYellow = audioVisual.ReadPercent("ConditionYellow"); _conditionYellowHealth = (int)(256 * (double)conditionYellow / 100); } if (audioVisual.HasKey("ConditionRed")) { int conditionRed = audioVisual.ReadPercent("ConditionRed"); _conditionRedHealth = (int)(256 * (double)conditionRed / 100); } } _baseShp = new ShpDrawable(_config, _vfs, 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); } } } // RA2 and later support adding fire animations to buildings, supports custom-paletted animations. if (_config.Engine >= EngineType.RedAlert2) { LoadFireAnimations(); } // Add turrets if (Rules.ReadBool("Turret") && Rules.HasKey("TurretAnim")) { string turretName = Rules.ReadString("TurretAnim"); IniFile.IniSection turretArt = OwnerCollection.Art.GetOrCreateSection(turretName); if (turretArt.HasKey("Image")) { turretName = turretArt.ReadString("Image"); } // NewTheater/generic image fallback support for turrets. string turretNameShp = NewTheater ? OwnerCollection.ApplyNewTheaterIfNeeded(turretName, turretName + ".shp") : turretName + ".shp"; Drawable turret = Rules.ReadBool("TurretAnimIsVoxel") ? (Drawable) new VoxelDrawable(_config, _vfs.Open <VxlFile>(turretName + ".vxl"), _vfs.Open <HvaFile>(turretName + ".hva")) : (Drawable) new ShpDrawable(new ShpRenderer(_config, _vfs), _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"); turret.Props.Cloakable = Props.Cloakable; SubDrawables.Add(turret); if (turret is VoxelDrawable && turretName.ToUpper().Contains("TUR")) { string barrelName = turretName.Replace("TUR", "BARL"); if (_vfs.FileExists(barrelName + ".vxl")) { var barrel = new VoxelDrawable(_config, _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(new ShpRenderer(_config, _vfs), bibShp); bib.Props = this.Props.Clone(); bib.Flat = true; SubDrawables.Add(bib); } } // Powerup slots, at most 3 for (int i = 1; i <= 3; i++) { _powerupSlots.Add(new PowerupSlot { X = Art.ReadInt(String.Format("PowerUp{0}LocXX", i), 0), Y = Art.ReadInt(String.Format("PowerUp{0}LocYY", i), 0), Z = Art.ReadInt(String.Format("PowerUp{0}LocZZ", i), 0), YSort = Art.ReadInt(String.Format("PowerUp{0}LocYSort", i), 0), }); } if (IsWall && _baseShp.Shp != null) { _baseShp.Shp.Initialize(); if (_baseShp.Shp.NumImages >= 32) { IsActualWall = true; } } }
public static Props CreateUniquePropsByValue(string sourceId, int value) { Props props = Game.Data.Get <Props>(sourceId) ?? Randomizer.GetOneFromData <Props>(sourceId); if (props == null) { return(null); } Props props2 = props.Clone <Props>(); if (props2.PropsEffect == null) { props2.PropsEffect = new List <PropsEffect>(); } if (props2.BuffList == null) { props2.BuffList = new List <string>(); } if (props2.PropsEffectDescription == null) { props2.PropsEffectDescription = ""; } List <CharacterProperty> list = ((CharacterProperty[])Enum.GetValues(typeof(CharacterProperty))).ToList(); list.Remove(CharacterProperty.Affiliation); list.Remove(CharacterProperty.Contribution); list.Remove(CharacterProperty.HP); list.Remove(CharacterProperty.MP); int num = value; List <string> list2 = new List <string>(); while (num > 0 && list.Count > 0) { CharacterProperty characterProperty = list.Random(); int num2; int num3; if (characterProperty < CharacterProperty.Attack) { num2 = UnityEngine.Random.Range(0, num + value / 2); num3 = num2 * 3 / 20 * 20; num2 = num3 / 3; } else if (characterProperty < CharacterProperty.Hit) { num2 = UnityEngine.Random.Range(-value / 2, num + value); num3 = num2 / 5 * 5; num2 = num3; } else if (characterProperty < CharacterProperty.Move) { num2 = UnityEngine.Random.Range(-value / 2, num + value); num3 = num2 / 5; num2 = num3 * 5; } else { num2 = UnityEngine.Random.Range(0, num + value / 2); num3 = (num2 + 40) / 100; num2 = Math.Max(0, num3 * 100 - 40); } if (num3 != 0) { list.Remove(characterProperty); PropsBattleProperty propsBattleProperty = new PropsBattleProperty { Type = PropsEffectType.BattleProperty, Property = characterProperty, isForever = false, Value = num3 }; props2.PropsEffect.Add(propsBattleProperty); list2.Add(string.Format("{0}{1}{2}", Game.Data.Get <StringTable>("Property_" + Enum.GetName(typeof(CharacterProperty), characterProperty)).Text, (num3 > 0) ? "+" : "", num3)); num -= num2; } } Props props3 = props2; props3.PropsEffectDescription = string.Concat(new object[] { props3.PropsEffectDescription, "\n附加:", string.Join(",", list2) }); ModExtensionSaveData.AddUniqueItem(props2); return(props2); }