Beispiel #1
0
 private void RefillSuitGassesFromBottles()
 {
     foreach (GasData data in this.m_storedGases)
     {
         if (data.FillLevel >= GAS_REFILL_RATION)
         {
             data.NextGasRefill = -1;
         }
         else
         {
             if (data.NextGasRefill == -1)
             {
                 data.NextGasRefill = MySandboxGame.TotalGamePlayTimeInMilliseconds + 0x1388;
             }
             if (MySandboxGame.TotalGamePlayTimeInMilliseconds >= data.NextGasRefill)
             {
                 data.NextGasRefill = -1;
                 bool flag = false;
                 using (List <MyPhysicalInventoryItem> .Enumerator enumerator = base.Character.GetInventory(0).GetItems().GetEnumerator())
                 {
                     while (enumerator.MoveNext())
                     {
                         MyObjectBuilder_GasContainerObject content = enumerator.Current.Content as MyObjectBuilder_GasContainerObject;
                         if ((content != null) && (content.GasLevel != 0f))
                         {
                             MyOxygenContainerDefinition physicalItemDefinition = MyDefinitionManager.Static.GetPhysicalItemDefinition(content) as MyOxygenContainerDefinition;
                             if (physicalItemDefinition.StoredGasId == data.Id)
                             {
                                 float num2     = content.GasLevel * physicalItemDefinition.Capacity;
                                 float gasInput = Math.Min(num2, (1f - data.FillLevel) * data.MaxCapacity);
                                 content.GasLevel = Math.Max((float)((num2 - gasInput) / physicalItemDefinition.Capacity), (float)0f);
                                 float gasLevel = content.GasLevel;
                                 base.Character.GetInventory(0).UpdateGasAmount();
                                 flag = true;
                                 this.TransferSuitGas(ref data.Id, gasInput, 0f);
                                 if (data.FillLevel == 1f)
                                 {
                                     break;
                                 }
                             }
                         }
                     }
                 }
                 if (flag && !ReferenceEquals(MySession.Static.LocalCharacter, base.Character))
                 {
                     base.Character.SendRefillFromBottle(data.Id);
                 }
                 MyCharacterJetpackComponent jetpackComp = base.Character.JetpackComp;
                 if (((jetpackComp != null) && (jetpackComp.TurnedOn && ((jetpackComp.FuelDefinition != null) && ((jetpackComp.FuelDefinition.Id == data.Id) && (data.FillLevel <= 0f))))) && (((base.Character.ControllerInfo.Controller != null) && !MySession.Static.CreativeToolsEnabled(base.Character.ControllerInfo.Controller.Player.Id.SteamId)) || (!ReferenceEquals(MySession.Static.LocalCharacter, base.Character) && !Sync.IsServer)))
                 {
                     if (Sync.IsServer && !ReferenceEquals(MySession.Static.LocalCharacter, base.Character))
                     {
                         MyMultiplayer.RaiseEvent <MyCharacter>(base.Character, x => new Action(x.SwitchJetpack), new EndpointId(base.Character.ControllerInfo.Controller.Player.Id.SteamId));
                     }
                     jetpackComp.SwitchThrusts();
                 }
             }
         }
     }
 }
Beispiel #2
0
        public void RefillBottles()
        {
            bool   flag        = false;
            double filledRatio = this.FilledRatio;

            foreach (MyPhysicalInventoryItem item in this.GetInventory(0).GetItems())
            {
                if (filledRatio <= 0.0)
                {
                    break;
                }
                MyObjectBuilder_GasContainerObject content = item.Content as MyObjectBuilder_GasContainerObject;
                if ((content != null) && (content.GasLevel < 1f))
                {
                    MyOxygenContainerDefinition physicalItemDefinition = MyDefinitionManager.Static.GetPhysicalItemDefinition(content) as MyOxygenContainerDefinition;
                    float num2 = content.GasLevel * physicalItemDefinition.Capacity;
                    float num3 = (float)(filledRatio * this.Capacity);
                    float num4 = Math.Min(physicalItemDefinition.Capacity - num2, num3);
                    content.GasLevel = Math.Min((float)((num2 + num4) / physicalItemDefinition.Capacity), (float)1f);
                    filledRatio      = Math.Max((double)(filledRatio - (num4 / this.Capacity)), (double)0.0);
                    flag             = true;
                }
            }
            if (flag)
            {
                this.ChangeFilledRatio(filledRatio, true);
                this.GetInventory(0).UpdateGasAmount();
            }
        }
Beispiel #3
0
        public void RefillBottles()
        {
            List <MyPhysicalInventoryItem> items = this.GetInventory(0).GetItems();

            using (List <MyDefinitionId> .Enumerator enumerator = this.SourceComp.ResourceTypes.GetEnumerator())
            {
                MyDefinitionId id2;
                double         num2;
                goto TR_001D;
TR_0003:
                if (num2 > 0.0)
                {
                    this.ProduceGas(ref id2, num2);
                    this.GetInventory(0).UpdateGasAmount();
                }
TR_001D:
                while (true)
                {
                    if (!enumerator.MoveNext())
                    {
                        break;
                    }
                    MyDefinitionId current = enumerator.Current;
                    id2 = current;
                    double num = 0.0;
                    if (MySession.Static.CreativeMode)
                    {
                        num = 3.4028234663852886E+38;
                    }
                    else
                    {
                        foreach (MyPhysicalInventoryItem item in items)
                        {
                            if (!(item.Content is MyObjectBuilder_GasContainerObject))
                            {
                                num += this.IceToGas(ref id2, (double)((float)item.Amount)) * ((Sandbox.ModAPI.IMyGasGenerator) this).ProductionCapacityMultiplier;
                            }
                        }
                    }
                    num2 = 0.0;
                    using (List <MyPhysicalInventoryItem> .Enumerator enumerator2 = items.GetEnumerator())
                    {
                        while (true)
                        {
                            if (enumerator2.MoveNext())
                            {
                                MyPhysicalInventoryItem item2 = enumerator2.Current;
                                if (num > 0.0)
                                {
                                    MyObjectBuilder_GasContainerObject content = item2.Content as MyObjectBuilder_GasContainerObject;
                                    if (content == null)
                                    {
                                        continue;
                                    }
                                    if (content.GasLevel >= 1f)
                                    {
                                        continue;
                                    }
                                    MyOxygenContainerDefinition physicalItemDefinition = MyDefinitionManager.Static.GetPhysicalItemDefinition(content) as MyOxygenContainerDefinition;
                                    if (physicalItemDefinition.StoredGasId != current)
                                    {
                                        continue;
                                    }
                                    float  num3 = content.GasLevel * physicalItemDefinition.Capacity;
                                    double num4 = Math.Min((double)(physicalItemDefinition.Capacity - num3), num);
                                    content.GasLevel = (float)Math.Min((double)((num3 + num4) / ((double)physicalItemDefinition.Capacity)), (double)1.0);
                                    num2            += num4;
                                    num -= num4;
                                    continue;
                                }
                            }
                            else
                            {
                                goto TR_0003;
                            }
                            break;
                        }
                        break;
                    }
                    goto TR_0003;
                }
            }
        }