コード例 #1
0
 static DescriptionDef GetObjectDescriptionByType(BattleTechResourceType type, object theObject)
 {
     return(type switch
     {
         BattleTechResourceType.AmmunitionBoxDef => ((AmmunitionBoxDef)theObject).Description,
         BattleTechResourceType.UpgradeDef => ((UpgradeDef)theObject).Description,
         BattleTechResourceType.HeatSinkDef => ((HeatSinkDef)theObject).Description,
         BattleTechResourceType.JumpJetDef => ((JumpJetDef)theObject).Description,
         BattleTechResourceType.WeaponDef => ((WeaponDef)theObject).Description,
         BattleTechResourceType.MechDef => ((MechDef)theObject).Description,
         _ => throw new InvalidProgramException($"BattleTechResourceType [{type.ToString()}] unhandled.")
     });
コード例 #2
0
        static TagSet GetTagsByType(BattleTechResourceType type, object theObject)
        {
            switch (type)
            {
            case BattleTechResourceType.AmmunitionBoxDef: return(((AmmunitionBoxDef)theObject).ComponentTags);

            case BattleTechResourceType.UpgradeDef: return(((UpgradeDef)theObject).ComponentTags);

            case BattleTechResourceType.HeatSinkDef: return(((HeatSinkDef)theObject).ComponentTags);

            case BattleTechResourceType.JumpJetDef: return(((JumpJetDef)theObject).ComponentTags);

            case BattleTechResourceType.WeaponDef: return(((WeaponDef)theObject).ComponentTags);

            case BattleTechResourceType.MechDef: return(((MechDef)theObject).MechTags);

            default:
                throw new InvalidProgramException($"BattleTechResourceType [{type.ToString()}] unhandled.");
            }
        }