Esempio n. 1
0
        private IEnumerator CheckStatus()
        {
            yield return(new WaitForSeconds(_updateTime));

            while (true)
            {
                foreach (EPartType partType in Enum.GetValues(typeof(EPartType)))
                {
                    Part part = _equipment.GetEquippedPart(partType);
                    if (part != null)
                    {
                        IOverheatable oh = part.AsOverheatable();
                        if (oh != null)
                        {
                            if (_internalTemperature.Value > oh.MaximumOperatingTemperature)
                            {
                                if (!_overheatedParts.ContainsKey(partType))
                                {
                                    _overheatedParts.Add(partType, new OverheatedPart(oh, 0f));
                                    _changeAlarms.Raise(new ChangeAlarmsEA()
                                    {
                                        AddedAlarm = UI.AlarmDisplay.EAlarmType.TemperatureHigh
                                    });
                                }
                            }
                            else
                            {
                                if (_overheatedParts.ContainsKey(partType))
                                {
                                    _overheatedParts.Remove(partType);
                                }

                                if (_overheatedParts.Count == 0)
                                {
                                    _changeAlarms.Raise(new ChangeAlarmsEA()
                                    {
                                        RemovedAlarm = UI.AlarmDisplay.EAlarmType.TemperatureHigh
                                    });
                                }
                            }
                        }
                    }
                }

                foreach (var elem in _overheatedParts)
                {
                    elem.Value.TimeOfOverheating += _updateTime;
                    if (elem.Value.TimeOfOverheating >= elem.Value.Overheatable.ToleranceTime)
                    {
                        DamagePlayerEA dp = new DamagePlayerEA();
                        dp.DealPermaDamage(new Tuple <EPartType, float>(elem.Key, 0.01f));
                        _damagePlayer.Raise(dp);
                        elem.Value.TimeOfOverheating = 0f;
                    }
                }

                yield return(new WaitForSeconds(_updateTime));
            }
        }
Esempio n. 2
0
 public void OnPlayerEquipmentChanged()
 {
     _heatScale = 0f;
     foreach (EPartType partType in System.Enum.GetValues(typeof(EPartType)))
     {
         Part part = _playerEquipment.GetEquippedPart(partType);
         if (part != null)
         {
             IOverheatable oh = part.AsOverheatable();
             if (oh != null)
             {
                 if (oh.MaximumOperatingTemperature > _heatScale)
                 {
                     _heatScale = oh.MaximumOperatingTemperature;
                 }
             }
         }
     }
     if (_heatScale < 0.01f)
     {
         _heatScale = 100f;
     }
 }
Esempio n. 3
0
 public OverheatedPart(IOverheatable overheatable, float time)
 {
     TimeOfOverheating = time;
     Overheatable      = overheatable;
 }