Ejemplo n.º 1
0
        internal EngineCoreRef(MechComponentRef componentRef, EngineCoreDef coreDef, EngineType engineType)
        {
            ComponentRef = componentRef;
            CoreDef      = coreDef;
            Type         = engineType;

            var text = componentRef.SimGameUID;

            if (string.IsNullOrEmpty(text))
            {
                if (text != null)
                {
                    componentRef.SetSimGameUID(null);
                }
                return;
            }

            var match = Regex.Match(text);

            if (!match.Success)
            {
                return;
            }

            UUID       = string.IsNullOrEmpty(match.Groups[1].Value) ? null : match.Groups[1].Value;
            Properties = match.Groups[2].Value;
        }
Ejemplo n.º 2
0
        internal void CalcSpeeds(EngineCoreDef engineCoreDef, float tonnage, out float walkSpeed, out float runSpeed)
        {
            var mp = CalcMovementPoints(engineCoreDef, tonnage);

            walkSpeed = CalcWalkDistance(mp);
            runSpeed  = CalcSprintDistance(mp);
        }
        private static void AutoFixChassisDef(ChassisDef chassisDef)
        {
            if (Control.settings.AutoFixChassisDefInitialTonnage)
            {
                SetOriginalTonnage(chassisDef);
                var tonnage = chassisDef.Tonnage * Control.settings.AutoFixChassisDefInitialToTotalTonnageFactor;
                var info    = typeof(ChassisDef).GetProperty("InitialTonnage");
                var value   = Convert.ChangeType(tonnage, info.PropertyType);
                info.SetValue(chassisDef, value, null);
            }

            if (Control.settings.AutoFixChassisDefMaxJumpjets)
            {
                var coreDef = new EngineCoreDef {
                    Rating = Control.settings.AutoFixChassisDefMaxJumpjetsRating
                };
                var maxCount = Mathf.Min(
                    Control.settings.AutoFixChassisDefMaxJumpjetsCount,
                    coreDef.GetMovement(chassisDef.Tonnage).JumpJetCount
                    );
                var info  = typeof(ChassisDef).GetProperty("MaxJumpjets");
                var value = Convert.ChangeType(maxCount, info.PropertyType);
                info.SetValue(chassisDef, value, null);
            }
        }
Ejemplo n.º 4
0
        internal EngineCoreRef(MechComponentRef componentRef, EngineCoreDef coreDef)
        {
            CoreDef      = coreDef;
            ComponentRef = componentRef;

            var text = componentRef.SimGameUID;

            if (string.IsNullOrEmpty(text))
            {
                if (text != null)
                {
                    componentRef.SetSimGameUID(null);
                }
            }
            else
            {
                var match = Regex.Match(text);
                if (match.Success)
                {
                    UUID       = string.IsNullOrEmpty(match.Groups[1].Value) ? null : match.Groups[1].Value;
                    Properties = match.Groups[2].Value;
                }
            }

            if (HeatSinkDef == null)
            {
                HeatSinkDef = DataManager.GetDefaultEngineHeatSinkDef();
            }
        }
Ejemplo n.º 5
0
        internal bool CalcAvailability(EngineCoreDef engineCoreDef, float tonnage)
        {
            var mp     = CalcMovementPoints(engineCoreDef, tonnage);
            var sprint = CalcSprintDistance(mp);

            if (sprint < UnityGameInstance.BattleTechGame.MechStatisticsConstants.MinSprintFactor)
            {
                return(false);
            }

            if (sprint > UnityGameInstance.BattleTechGame.MechStatisticsConstants.MaxSprintFactor)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 6
0
        internal static EngineCoreRef GetEngineCoreRef(this IEnumerable <MechComponentRef> componentRefs)
        {
            EngineCoreDef    engineDef         = null;
            MechComponentRef enginComponentRef = null;
            EngineType       engineType        = null;

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

                if (!componentDef.IsEnginePart())
                {
                    continue;
                }

                if (engineDef == null)
                {
                    engineDef = componentDef.GetEngineCoreDef();
                    if (engineDef != null)
                    {
                        enginComponentRef = componentRef;
                    }
                }

                if (engineType == null)
                {
                    engineType = Control.settings.EngineTypes.FirstOrDefault(c => componentDef.Description.Id == c.ComponentTypeID);
                }

                if (engineDef != null && engineType != null)
                {
                    break;
                }
            }

            if (engineDef == null)
            {
                return(null);
            }

            return(new EngineCoreRef(enginComponentRef, engineDef, engineType));
        }
Ejemplo n.º 7
0
 internal EngineCoreRef(EngineHeatSink heatSinkDef, EngineCoreDef coreDef) // only used for autofix, not fully supported
 {
     CoreDef     = coreDef;
     HeatSinkDef = heatSinkDef;
 }
Ejemplo n.º 8
0
 internal float CalcMovementPoints(EngineCoreDef engineCoreDef, float tonnage)
 {
     return(engineCoreDef.Rating / tonnage);
 }
Ejemplo n.º 9
0
        internal int CalcJumpJetCount(EngineCoreDef engineCoreDef, float tonnage)
        {
            var mp = CalcMovementPoints(engineCoreDef, tonnage);

            return(Control.settings.JJRoundUp ? Mathf.CeilToInt(mp) : Mathf.FloorToInt(mp));
        }
Ejemplo n.º 10
0
 internal float CalcGyroWeight(EngineCoreDef engineCoreDef)
 {
     // for now only used for engine details text, not for any actual tonnage calculations
     return((int)(engineCoreDef.Rating / 100));
 }
Ejemplo n.º 11
0
 internal void CalcHeatSinks(EngineCoreDef engineCoreDef, out int minHeatSinks, out int maxHeatSinks)
 {
     maxHeatSinks = engineCoreDef.Rating / 25;
     minHeatSinks = Math.Min(maxHeatSinks, 10);
 }
Ejemplo n.º 12
0
 internal void CalcInstallCosts(EngineCoreDef engineCoreDef, ref int cbillCost, ref int techCost)
 {
     cbillCost += Mathf.CeilToInt(engineCoreDef.Def.Tonnage * 10000);
     techCost  += Mathf.CeilToInt(engineCoreDef.Def.Tonnage);
 }