Exemplo n.º 1
0
        public static float FailChance(this MechComponent component)
        {
            ActivatableComponent activatable = component.componentDef.GetComponent <ActivatableComponent>();

            if (activatable == null)
            {
                return(0f);
            }
            ;
            if (activatable.AlwaysFail)
            {
                return(1f);
            }
            ;
            return(ActivatableComponent.getEffectiveComponentFailChance(component));
        }
Exemplo n.º 2
0
 public static float FailChance(this MechComponent component)
 {
     return(ActivatableComponent.getEffectiveComponentFailChance(component));
 }
Exemplo n.º 3
0
        public string BuildText()
        {
            StringBuilder builder = new StringBuilder();

            for (int index = 0; index < components.Count; ++index)
            {
                if (index != 0)
                {
                    builder.Append("\n");
                }
                ;
                if (index == SelectedComponent)
                {
                    builder.Append("->");
                }
                MechComponent component = components[index];
                builder.Append(component.UIName);
                if (component.IsFunctional == false)
                {
                    builder.Append(" !__/CAE.NonFunctional/__!"); continue;
                }
                if (component.DamageLevel >= ComponentDamageLevel.Penalized)
                {
                    builder.Append(" !__/CAE.Damaged/__!");
                }
                if (ActivatableComponent.isOutOfCharges(components[index]))
                {
                    builder.Append(" !__/CAE.OutOfCharges/__!");
                    continue;
                }
                ActivatableComponent activatable = component.componentDef.GetComponent <ActivatableComponent>();
                if (activatable.ChargesCount != 0)
                {
                    if (activatable.ChargesCount > 0)
                    {
                        builder.Append(" __/CAE.CHARGES/__:" + ActivatableComponent.getChargesCount(component));
                    }
                }
                if (ActivatableComponent.isComponentActivated(component))
                {
                    builder.Append(" " + activatable.ActivationMessage + " ");
                    if (activatable.CanBeactivatedManualy == false)
                    {
                        if (component.parent is Mech)
                        {
                            float neededHeat = (activatable.AutoDeactivateOverheatLevel > CustomActivatableEquipment.Core.Epsilon) ? activatable.AutoDeactivateOverheatLevel * (float)(component.parent as Mech).OverheatLevel : activatable.AutoDeactivateOnHeat;
                            builder.Append("__/CAE.HEAT/__:" + (component.parent as Mech).CurrentHeat + "/" + neededHeat);
                        }
                    }
                }
                else
                {
                    builder.Append(" " + activatable.DeactivationMessage + " ");
                    if (activatable.AutoActivateOnHeat > CustomActivatableEquipment.Core.Epsilon)
                    {
                        if (component.parent is Mech)
                        {
                            float neededHeat = (activatable.AutoActivateOnOverheatLevel > CustomActivatableEquipment.Core.Epsilon) ? activatable.AutoActivateOnOverheatLevel * (float)(component.parent as Mech).OverheatLevel : activatable.AutoActivateOnHeat;
                            builder.Append("__/CAE.HEAT/__:" + (component.parent as Mech).CurrentHeat + "/" + neededHeat);
                        }
                    }
                }
                float failChance = ActivatableComponent.getEffectiveComponentFailChance(component);
                if (failChance > Core.Epsilon)
                {
                    builder.Append(" __/CAE.FAIL/__:" + Math.Round(failChance * 100f) + "%");
                }
            }
            return(builder.ToString());
        }