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); }
public void Combine(WeightFactors savings) { ReservedSlots += savings.ReservedSlots; ArmorFactor += savings.ArmorFactor - 1; StructureFactor += savings.StructureFactor - 1; EngineFactor += savings.EngineFactor - 1; //EngineFactorFactor += savings.EngineFactorFactor - 1; GyroFactor += savings.GyroFactor - 1; ChassisFactor += savings.ChassisFactor - 1; }
internal static float CalculateWeightFactorsChange(MechDef mechDef, WeightFactors componentFactors) { var weights = new Weights(mechDef); var before = weights.TotalWeight; weights.Factors.Combine(componentFactors); var after = weights.TotalWeight; return(after - before); }
internal static WeightFactors GetWeightFactorsFromInventory(IList <MechComponentRef> componentRefs) { var weightFactors = new WeightFactors(); foreach (var componentRef in componentRefs) { var componentDef = componentRef.Def; if (componentDef.Is <WeightFactors>(out var weightSavings)) { weightFactors.Combine(weightSavings); } } return(weightFactors); }