Ejemplo n.º 1
0
        private bool IsPointInAirtightSpace(Vector3D worldPosition)
        {
            if (!MySession.Static.Settings.EnableOxygen)
            {
                return(true);
            }
            bool            flag           = false;
            BoundingSphereD boundingSphere = new BoundingSphereD(worldPosition, 0.1);
            List <MyEntity> list           = null;

            try
            {
                foreach (MyCubeGrid grid in MyEntities.GetEntitiesInSphere(ref boundingSphere))
                {
                    if (grid == null)
                    {
                        continue;
                    }
                    if (grid.GridSystems.GasSystem != null)
                    {
                        MyOxygenBlock safeOxygenBlock = grid.GridSystems.GasSystem.GetSafeOxygenBlock(worldPosition);
                        if ((safeOxygenBlock != null) && ((safeOxygenBlock.Room != null) && safeOxygenBlock.Room.IsAirtight))
                        {
                            flag = true;
                            break;
                        }
                    }
                }
            }
            finally
            {
                if (list != null)
                {
                    list.Clear();
                }
            }
            return(flag);
        }
Ejemplo n.º 2
0
        private void UpdateOxygen()
        {
            MyOxygenRoom    room;
            List <MyEntity> result          = new List <MyEntity>();
            BoundingBoxD    worldAABB       = base.Character.PositionComp.WorldAABB;
            bool            enableOxygen    = MySession.Static.Settings.EnableOxygen;
            bool            noOxygenDamage  = MySession.Static.Settings.EnableOxygen;
            bool            isInEnvironment = true;
            bool            flag4           = false;

            if (!Sync.IsServer)
            {
                goto TR_000A;
            }
            else
            {
                base.Character.EnvironmentOxygenLevelSync.Value     = MyOxygenProviderSystem.GetOxygenInPoint(base.Character.PositionComp.GetPosition());
                base.Character.OxygenLevelAtCharacterLocation.Value = base.Character.EnvironmentOxygenLevel;
                room = null;
                if (!MySession.Static.Settings.EnableOxygen)
                {
                    goto TR_000C;
                }
                else
                {
                    GasData data;
                    if (this.TryGetGasData(OxygenId, out data))
                    {
                        float num = (MySession.Static.GameplayFrameCounter - data.LastOutputTime) * 0.01666667f;
                        flag4 = (this.CharacterGasSink.CurrentInputByType(OxygenId) * num) > this.Definition.OxygenConsumption;
                        if (flag4)
                        {
                            noOxygenDamage = false;
                            enableOxygen   = false;
                        }
                    }
                    MyCockpit parent = base.Character.Parent as MyCockpit;
                    bool      flag5  = false;
                    if ((parent != null) && parent.BlockDefinition.IsPressurized)
                    {
                        if ((!this.HelmetEnabled && (MySession.Static.SurvivalMode && !flag4)) && (parent.OxygenAmount >= (this.Definition.OxygenConsumption * this.Definition.OxygenConsumptionMultiplier)))
                        {
                            parent.OxygenAmount -= this.Definition.OxygenConsumption * this.Definition.OxygenConsumptionMultiplier;
                            noOxygenDamage       = false;
                            enableOxygen         = false;
                        }
                        base.Character.EnvironmentOxygenLevelSync.Value = parent.OxygenFillLevel;
                        isInEnvironment = false;
                        flag5           = true;
                    }
                    if (!flag5 || (MyFakes.ENABLE_NEW_SOUNDS && MySession.Static.Settings.RealisticSound))
                    {
                        base.Character.OxygenSourceGridEntityId.Value = 0L;
                        Vector3D center = base.Character.PositionComp.WorldAABB.Center;
                        MyGamePruningStructure.GetTopMostEntitiesInBox(ref worldAABB, result, MyEntityQueryType.Both);
                        using (List <MyEntity> .Enumerator enumerator = result.GetEnumerator())
                        {
                            while (true)
                            {
                                while (true)
                                {
                                    if (enumerator.MoveNext())
                                    {
                                        MyCubeGrid current = enumerator.Current as MyCubeGrid;
                                        if (current == null)
                                        {
                                            continue;
                                        }
                                        if (current.GridSystems.GasSystem == null)
                                        {
                                            continue;
                                        }
                                        MyOxygenBlock safeOxygenBlock = current.GridSystems.GasSystem.GetSafeOxygenBlock(center);
                                        if (safeOxygenBlock == null)
                                        {
                                            continue;
                                        }
                                        if (safeOxygenBlock.Room == null)
                                        {
                                            continue;
                                        }
                                        room = safeOxygenBlock.Room;
                                        if ((room.OxygenLevel(current.GridSize) > this.Definition.PressureLevelForLowDamage) && !this.HelmetEnabled)
                                        {
                                            enableOxygen = false;
                                        }
                                        if (!room.IsAirtight)
                                        {
                                            float environmentOxygen = room.EnvironmentOxygen;
                                            base.Character.OxygenLevelAtCharacterLocation.Value = environmentOxygen;
                                            if (flag5)
                                            {
                                                break;
                                            }
                                            base.Character.EnvironmentOxygenLevelSync.Value = environmentOxygen;
                                            if (this.HelmetEnabled)
                                            {
                                                break;
                                            }
                                            if (base.Character.EnvironmentOxygenLevelSync.Value <= (this.Definition.OxygenConsumption * this.Definition.OxygenConsumptionMultiplier))
                                            {
                                                break;
                                            }
                                            noOxygenDamage = false;
                                        }
                                        else
                                        {
                                            float num2 = room.OxygenLevel(current.GridSize);
                                            if (!flag5)
                                            {
                                                base.Character.EnvironmentOxygenLevelSync.Value = num2;
                                            }
                                            base.Character.OxygenLevelAtCharacterLocation.Value = num2;
                                            base.Character.OxygenSourceGridEntityId.Value       = current.EntityId;
                                            if (room.OxygenAmount <= (this.Definition.OxygenConsumption * this.Definition.OxygenConsumptionMultiplier))
                                            {
                                                break;
                                            }
                                            if (!this.HelmetEnabled)
                                            {
                                                noOxygenDamage = false;
                                                safeOxygenBlock.PreviousOxygenAmount = safeOxygenBlock.OxygenAmount() - (this.Definition.OxygenConsumption * this.Definition.OxygenConsumptionMultiplier);
                                                safeOxygenBlock.OxygenChangeTime     = MySandboxGame.TotalGamePlayTimeInMilliseconds;
                                                if (!flag4)
                                                {
                                                    room.OxygenAmount -= this.Definition.OxygenConsumption * this.Definition.OxygenConsumptionMultiplier;
                                                }
                                            }
                                        }
                                        goto TR_000D;
                                    }
                                    else
                                    {
                                        goto TR_000D;
                                    }
                                    break;
                                }
                                isInEnvironment = false;
                            }
                        }
                    }
                }
            }
            goto TR_000D;
TR_000A:
            this.CharacterGasSink.Update();
            if (Sync.IsServer && !MySession.Static.CreativeMode)
            {
                this.RefillSuitGassesFromBottles();
                if (MySession.Static.Settings.EnableOxygen)
                {
                    this.UpdateSuitOxygen(enableOxygen, noOxygenDamage, isInEnvironment);
                }
                foreach (GasData data2 in this.m_storedGases)
                {
                    base.Character.UpdateStoredGas(data2.Id, data2.FillLevel);
                }
            }
            return;

TR_000C:
            this.UpdateGassesFillLevelsAndAmounts(room);
            goto TR_000A;
TR_000D:
            this.m_oldSuitOxygenLevel = this.SuitOxygenLevel;
            goto TR_000C;
        }