Пример #1
0
    internal static Result SearchInventory(IList <MechComponentRef> componentRefs)
    {
        var result = new Result();

        foreach (var componentRef in componentRefs)
        {
            var componentDef = componentRef.Def;

            if (componentDef.Is <EngineHeatSinkDef>())
            {
                result.HeatSinks.Add(componentRef);
            }

            if (componentDef.Is <CoolingDef>(out var coolingDef))
            {
                result.CoolingDef = coolingDef;
            }

            if (componentDef.Is <EngineCoreDef>(out var coreDef))
            {
                result.CoreDef = coreDef;
            }

            if (componentDef.Is <EngineHeatBlockDef>(out var blockDef))
            {
                result.HeatBlockDef = blockDef;
            }
        }

        result.WeightFactors = WeightsUtils.GetWeightFactorsFromInventory(componentRefs);

        return(result);
    }
Пример #2
0
 internal Weights(MechDef mechDef)
 {
     StandardArmorWeight           = mechDef.StandardArmorTonnage();
     StandardStructureWeight       = mechDef.Chassis.Tonnage / 10f;
     StandardChassisWeightCapacity = mechDef.Chassis.Tonnage;
     Engine             = mechDef.GetEngine();
     Factors            = Engine?.WeightFactors ?? WeightsUtils.GetWeightFactorsFromInventory(mechDef.Inventory);
     ComponentSumWeight = mechDef.Inventory.Sum(mechComponentRef => mechComponentRef.Def.Tonnage) - (Engine?.CoreDef.Def.Tonnage ?? 0);
 }