private bool TryGetGasData(MyDefinitionId gasId, out GasData data) { int index = -1; data = null; if (TryGetTypeIndex(ref gasId, out index)) { data = m_storedGases[index]; return true; } return false; }
private float Sink_ComputeRequiredGas(GasData gas) { float inputToFillInUpdateInterval = ((1 - gas.FillLevel) * gas.MaxCapacity + (gas.Id == OxygenId ? Definition.OxygenConsumption * Definition.OxygenConsumptionMultiplier : 0f)) / VRage.Game.MyEngineConstants.UPDATE_STEPS_PER_SECOND * m_updateInterval; return Math.Min(inputToFillInUpdateInterval, gas.Throughput); }
public virtual void Init(MyObjectBuilder_Character characterOb) { if (MySession.Static.SurvivalMode) { m_suitOxygenAmount = characterOb.OxygenLevel * Definition.OxygenCapacity; } else { m_suitOxygenAmount = Definition.OxygenCapacity; } m_oldSuitOxygenLevel = SuitOxygenLevel; m_gasIdToIndex = new Dictionary<MyDefinitionId, int>(); if (MyFakes.ENABLE_HYDROGEN_FUEL && Definition.SuitResourceStorage != null) { m_storedGases = new GasData[Definition.SuitResourceStorage.Count]; for(int gasIndex = 0; gasIndex < m_storedGases.Length; ++gasIndex) { var gasInfo = Definition.SuitResourceStorage[gasIndex]; m_storedGases[gasIndex] = new GasData { Id = gasInfo.Id, FillLevel = 1f, MaxCapacity = gasInfo.MaxCapacity, Throughput = gasInfo.Throughput }; m_gasIdToIndex.Add(gasInfo.Id, gasIndex); } if (characterOb.StoredGases != null) { foreach (var gasInfo in characterOb.StoredGases) { int gasIndex; if (!m_gasIdToIndex.TryGetValue(gasInfo.Id, out gasIndex)) continue; m_storedGases[gasIndex].FillLevel = gasInfo.FillLevel; } } } if(m_storedGases == null) m_storedGases = new GasData[0]; m_oxygenBottleRefillNotification = new MyHudNotification(text: MySpaceTexts.NotificationBottleRefill, level: MyNotificationLevel.Important); m_lowOxygenNotification = new MyHudNotification(text: MySpaceTexts.NotificationOxygenLow, font: MyFontEnum.Red, level: MyNotificationLevel.Important); m_criticalOxygenNotification = new MyHudNotification(text: MySpaceTexts.NotificationOxygenCritical, font: MyFontEnum.Red, level: MyNotificationLevel.Important); m_helmetToggleNotification = m_helmetToggleNotification ?? new MyHudNotification(); // Init() is called when toggling helmet so this check is required m_needsOxygen = Definition.NeedsOxygen; NeedsUpdateBeforeSimulation100 = true; }
public virtual void Init(MyObjectBuilder_Character characterOb) { m_lastOxygenUpdateTime = MySession.Static.GameplayFrameCounter; m_gasIdToIndex = new Dictionary<MyDefinitionId, int>(); if (MyFakes.ENABLE_HYDROGEN_FUEL && Definition.SuitResourceStorage != null) { m_storedGases = new GasData[Definition.SuitResourceStorage.Count]; for(int gasIndex = 0; gasIndex < m_storedGases.Length; ++gasIndex) { var gasInfo = Definition.SuitResourceStorage[gasIndex]; m_storedGases[gasIndex] = new GasData { Id = gasInfo.Id, FillLevel = 1f, MaxCapacity = gasInfo.MaxCapacity, Throughput = gasInfo.Throughput, LastOutputTime = MySession.Static.GameplayFrameCounter, LastInputTime = MySession.Static.GameplayFrameCounter }; m_gasIdToIndex.Add(gasInfo.Id, gasIndex); } if (characterOb.StoredGases != null) { if (!MySession.Static.CreativeMode) { foreach (var gasInfo in characterOb.StoredGases) { int gasIndex; if (!m_gasIdToIndex.TryGetValue(gasInfo.Id, out gasIndex)) continue; m_storedGases[gasIndex].FillLevel = gasInfo.FillLevel; } } } } if(m_storedGases == null) m_storedGases = new GasData[0]; Debug.Assert(ContainsGasStorage(OxygenId), characterOb.SubtypeName + " is missing Oxygen resource."); Debug.Assert(ContainsGasStorage(HydrogenId), characterOb.SubtypeName + " is missing Hydrogen resource."); if (MySession.Static.Settings.EnableOxygen) { float oxygenFillLevel = GetGasFillLevel(OxygenId); m_oldSuitOxygenLevel = oxygenFillLevel == 0f ? OxygenCapacity : oxygenFillLevel; } EnvironmentOxygenLevel = characterOb.EnvironmentOxygenLevel; OxygenLevelAtCharacterLocation = 0f; m_oxygenBottleRefillNotification = new MyHudNotification(text: MySpaceTexts.NotificationBottleRefill, level: MyNotificationLevel.Important); m_gasBottleRefillNotification = new MyHudNotification(text: MySpaceTexts.NotificationGasBottleRefill, level: MyNotificationLevel.Important); m_lowOxygenNotification = new MyHudNotification(text: MySpaceTexts.NotificationOxygenLow, font: MyFontEnum.Red, level: MyNotificationLevel.Important); m_criticalOxygenNotification = new MyHudNotification(text: MySpaceTexts.NotificationOxygenCritical, font: MyFontEnum.Red, level: MyNotificationLevel.Important); m_helmetToggleNotification = m_helmetToggleNotification ?? new MyHudNotification(); // Init() is called when toggling helmet so this check is required // todo: this should be independent on animation/layer names string animationOpenHelmet; string animationCloseHelmet; Character.Definition.AnimationNameToSubtypeName.TryGetValue("HelmetOpen", out animationOpenHelmet); Character.Definition.AnimationNameToSubtypeName.TryGetValue("HelmetClose", out animationCloseHelmet); if ((animationOpenHelmet != null && animationCloseHelmet != null) || (Character.UseNewAnimationSystem && Character.AnimationController.Controller.GetLayerByName("Helmet") != null)) { NeedsOxygenFromSuit = characterOb.NeedsOxygenFromSuit; } else { NeedsOxygenFromSuit = Definition.NeedsOxygen; // compatibility } NeedsUpdateBeforeSimulation = true; NeedsUpdateBeforeSimulation100 = true; if (m_soundEmitter == null) m_soundEmitter = new MyEntity3DSoundEmitter(Character); if (!HelmetEnabled) // default state == helmet is enabled AnimateHelmet(); }
public virtual void Init(MyObjectBuilder_Character characterOb) { m_lastOxygenUpdateTime = MySession.Static.GameplayFrameCounter; m_gasIdToIndex = new Dictionary<MyDefinitionId, int>(); if (MyFakes.ENABLE_HYDROGEN_FUEL && Definition.SuitResourceStorage != null) { m_storedGases = new GasData[Definition.SuitResourceStorage.Count]; for(int gasIndex = 0; gasIndex < m_storedGases.Length; ++gasIndex) { var gasInfo = Definition.SuitResourceStorage[gasIndex]; m_storedGases[gasIndex] = new GasData { Id = gasInfo.Id, FillLevel = 1f, MaxCapacity = gasInfo.MaxCapacity, Throughput = gasInfo.Throughput, LastOutputTime = MySession.Static.GameplayFrameCounter, LastInputTime = MySession.Static.GameplayFrameCounter }; m_gasIdToIndex.Add(gasInfo.Id, gasIndex); } if (characterOb.StoredGases != null) { if (!MySession.Static.CreativeMode) { foreach (var gasInfo in characterOb.StoredGases) { int gasIndex; if (!m_gasIdToIndex.TryGetValue(gasInfo.Id, out gasIndex)) continue; m_storedGases[gasIndex].FillLevel = gasInfo.FillLevel; } } } } if(m_storedGases == null) m_storedGases = new GasData[0]; Debug.Assert(ContainsGasStorage(OxygenId), characterOb.SubtypeName + " is missing Oxygen resource."); Debug.Assert(ContainsGasStorage(HydrogenId), characterOb.SubtypeName + " is missing Hydrogen resource."); if (MySession.Static.Settings.EnableOxygen) { float oxygenFillLevel = GetGasFillLevel(OxygenId); m_oldSuitOxygenLevel = oxygenFillLevel == 0f ? OxygenCapacity : oxygenFillLevel; } EnvironmentOxygenLevel = characterOb.EnvironmentOxygenLevel; m_oxygenBottleRefillNotification = new MyHudNotification(text: MySpaceTexts.NotificationBottleRefill, level: MyNotificationLevel.Important); m_gasBottleRefillNotification = new MyHudNotification(text: MySpaceTexts.NotificationGasBottleRefill, level: MyNotificationLevel.Important); m_lowOxygenNotification = new MyHudNotification(text: MySpaceTexts.NotificationOxygenLow, font: MyFontEnum.Red, level: MyNotificationLevel.Important); m_criticalOxygenNotification = new MyHudNotification(text: MySpaceTexts.NotificationOxygenCritical, font: MyFontEnum.Red, level: MyNotificationLevel.Important); m_helmetToggleNotification = m_helmetToggleNotification ?? new MyHudNotification(); // Init() is called when toggling helmet so this check is required m_needsOxygen = Definition.NeedsOxygen; NeedsUpdateBeforeSimulation = true; NeedsUpdateBeforeSimulation100 = true; }
private float Sink_ComputeRequiredGas(GasData gas) { float inputToFillInUpdateInterval = ((1 - gas.FillLevel) * gas.MaxCapacity + (gas.Id == OxygenId ? Definition.OxygenConsumption * Definition.OxygenConsumptionMultiplier : 0f)) / VRage.Game.MyEngineConstants.UPDATE_STEPS_PER_SECOND * m_updateInterval; return(Math.Min(inputToFillInUpdateInterval, gas.Throughput)); }
public virtual void Init(MyObjectBuilder_Character characterOb) { m_lastOxygenUpdateTime = MySession.Static.GameplayFrameCounter; m_gasIdToIndex = new Dictionary <MyDefinitionId, int>(); if (MyFakes.ENABLE_HYDROGEN_FUEL && Definition.SuitResourceStorage != null) { m_storedGases = new GasData[Definition.SuitResourceStorage.Count]; for (int gasIndex = 0; gasIndex < m_storedGases.Length; ++gasIndex) { var gasInfo = Definition.SuitResourceStorage[gasIndex]; m_storedGases[gasIndex] = new GasData { Id = gasInfo.Id, FillLevel = 1f, MaxCapacity = gasInfo.MaxCapacity, Throughput = gasInfo.Throughput, LastOutputTime = MySession.Static.GameplayFrameCounter, LastInputTime = MySession.Static.GameplayFrameCounter }; m_gasIdToIndex.Add(gasInfo.Id, gasIndex); } if (characterOb.StoredGases != null) { if (!MySession.Static.CreativeMode) { foreach (var gasInfo in characterOb.StoredGases) { int gasIndex; if (!m_gasIdToIndex.TryGetValue(gasInfo.Id, out gasIndex)) { continue; } m_storedGases[gasIndex].FillLevel = gasInfo.FillLevel; } } } } if (m_storedGases == null) { m_storedGases = new GasData[0]; } Debug.Assert(ContainsGasStorage(OxygenId), characterOb.SubtypeName + " is missing Oxygen resource."); Debug.Assert(ContainsGasStorage(HydrogenId), characterOb.SubtypeName + " is missing Hydrogen resource."); if (MySession.Static.Settings.EnableOxygen) { float oxygenFillLevel = GetGasFillLevel(OxygenId); m_oldSuitOxygenLevel = oxygenFillLevel == 0f ? OxygenCapacity : oxygenFillLevel; } EnvironmentOxygenLevel = characterOb.EnvironmentOxygenLevel; m_oxygenBottleRefillNotification = new MyHudNotification(text: MySpaceTexts.NotificationBottleRefill, level: MyNotificationLevel.Important); m_gasBottleRefillNotification = new MyHudNotification(text: MySpaceTexts.NotificationGasBottleRefill, level: MyNotificationLevel.Important); m_lowOxygenNotification = new MyHudNotification(text: MySpaceTexts.NotificationOxygenLow, font: MyFontEnum.Red, level: MyNotificationLevel.Important); m_criticalOxygenNotification = new MyHudNotification(text: MySpaceTexts.NotificationOxygenCritical, font: MyFontEnum.Red, level: MyNotificationLevel.Important); m_helmetToggleNotification = m_helmetToggleNotification ?? new MyHudNotification(); // Init() is called when toggling helmet so this check is required m_needsOxygen = Definition.NeedsOxygen; NeedsUpdateBeforeSimulation = true; NeedsUpdateBeforeSimulation100 = true; }
public virtual void Init(MyObjectBuilder_Character characterOb) { m_lastOxygenUpdateTime = MySession.Static.GameplayFrameCounter; m_gasIdToIndex = new Dictionary <MyDefinitionId, int>(); if (MyFakes.ENABLE_HYDROGEN_FUEL && Definition.SuitResourceStorage != null) { m_storedGases = new GasData[Definition.SuitResourceStorage.Count]; for (int gasIndex = 0; gasIndex < m_storedGases.Length; ++gasIndex) { var gasInfo = Definition.SuitResourceStorage[gasIndex]; m_storedGases[gasIndex] = new GasData { Id = gasInfo.Id, FillLevel = 1f, MaxCapacity = gasInfo.MaxCapacity, Throughput = gasInfo.Throughput, LastOutputTime = MySession.Static.GameplayFrameCounter, LastInputTime = MySession.Static.GameplayFrameCounter }; m_gasIdToIndex.Add(gasInfo.Id, gasIndex); } if (characterOb.StoredGases != null) { if (!MySession.Static.CreativeMode) { foreach (var gasInfo in characterOb.StoredGases) { int gasIndex; if (!m_gasIdToIndex.TryGetValue(gasInfo.Id, out gasIndex)) { continue; } m_storedGases[gasIndex].FillLevel = gasInfo.FillLevel; } } } } if (m_storedGases == null) { m_storedGases = new GasData[0]; } Debug.Assert(ContainsGasStorage(OxygenId), characterOb.SubtypeName + " is missing Oxygen resource."); Debug.Assert(ContainsGasStorage(HydrogenId), characterOb.SubtypeName + " is missing Hydrogen resource."); if (MySession.Static.Settings.EnableOxygen) { float oxygenFillLevel = GetGasFillLevel(OxygenId); m_oldSuitOxygenLevel = oxygenFillLevel == 0f ? OxygenCapacity : oxygenFillLevel; } EnvironmentOxygenLevel = characterOb.EnvironmentOxygenLevel; OxygenLevelAtCharacterLocation = 0f; m_oxygenBottleRefillNotification = new MyHudNotification(text: MySpaceTexts.NotificationBottleRefill, level: MyNotificationLevel.Important); m_gasBottleRefillNotification = new MyHudNotification(text: MySpaceTexts.NotificationGasBottleRefill, level: MyNotificationLevel.Important); m_lowOxygenNotification = new MyHudNotification(text: MySpaceTexts.NotificationOxygenLow, font: MyFontEnum.Red, level: MyNotificationLevel.Important); m_criticalOxygenNotification = new MyHudNotification(text: MySpaceTexts.NotificationOxygenCritical, font: MyFontEnum.Red, level: MyNotificationLevel.Important); m_helmetToggleNotification = m_helmetToggleNotification ?? new MyHudNotification(); // Init() is called when toggling helmet so this check is required // todo: this should be independent on animation/layer names string animationOpenHelmet; string animationCloseHelmet; Character.Definition.AnimationNameToSubtypeName.TryGetValue("HelmetOpen", out animationOpenHelmet); Character.Definition.AnimationNameToSubtypeName.TryGetValue("HelmetClose", out animationCloseHelmet); if ((animationOpenHelmet != null && animationCloseHelmet != null) || (Character.UseNewAnimationSystem && Character.AnimationController.Controller.GetLayerByName("Helmet") != null)) { NeedsOxygenFromSuit = characterOb.NeedsOxygenFromSuit; } else { NeedsOxygenFromSuit = Definition.NeedsOxygen; // compatibility } NeedsUpdateBeforeSimulation = true; NeedsUpdateBeforeSimulation100 = true; if (m_soundEmitter == null) { m_soundEmitter = new MyEntity3DSoundEmitter(Character); } if (!HelmetEnabled) // default state == helmet is enabled { AnimateHelmet(); } }
private void MineDataSimple_Load(object sender, EventArgs e) { DataBindUtil.LoadTeam(cboTeamName); DataBindUtil.LoadTeamMemberByTeamName(cboSubmitter, cboTeamName.Text); DataBindUtil.LoadWorkTime(cboWorkTime, rbtn38.Checked ? Const_MS.WORK_GROUP_ID_38 : Const_MS.WORK_GROUP_ID_46); if (WorkingTimeDefault.FindFirst().DefaultWorkTimeGroupId == Const_MS.WORK_GROUP_ID_38) { rbtn38.Checked = true; } else { rbtn46.Checked = true; } // 设置班次名称 SetWorkTimeName(); //窗体绑定到Panel中 _ventilationInfo.MdiParent = this; _ventilationInfo.Parent = panel2; _coalExistenceInfo.MdiParent = this; _coalExistenceInfo.Parent = panel2; _gasData.MdiParent = this; _gasData.Parent = panel2; _management.MdiParent = this; _management.Parent = panel2; _geologicStructure.MdiParent = this; _geologicStructure.Parent = panel2; //panel2绑定窗体 panel2.Controls.Add(_coalExistenceInfo); panel2.Controls.Add(_ventilationInfo); panel2.Controls.Add(_gasData); panel2.Controls.Add(_management); panel2.Controls.Add(_geologicStructure); if (Tunnel != null) { selectTunnelSimple1.SetTunnel(Tunnel); } if (Team != null) { cboTeamName.SelectedText = Team.TeamName; } if (MineData != null) { selectTunnelSimple1.SetTunnel(MineData.Tunnel); txtCoordinateX.Text = MineData.Tunnel.WorkingFace.CoordinateX.ToString(CultureInfo.InvariantCulture); txtCoordinateY.Text = MineData.Tunnel.WorkingFace.CoordinateY.ToString(CultureInfo.InvariantCulture); txtCoordinateZ.Text = MineData.Tunnel.WorkingFace.CoordinateZ.ToString(CultureInfo.InvariantCulture); if (MineData.WorkStyle == "三八制") { rbtn38.Checked = true; rbtn46.Checked = false; } else { rbtn46.Checked = true; rbtn38.Checked = false; } cboWorkTime.SelectedValue = MineData.WorkTime; cboTeamName.SelectedText = MineData.TeamName; cboSubmitter.SelectedText = MineData.Submitter; if (MineData is CoalExistence) { var coalexistence = (CoalExistence)MineData; _coalExistenceInfo.bindDefaultValue(coalexistence); Height = FormHeight + _coalExistenceInfo.Height; _coalExistenceInfo.WindowState = FormWindowState.Maximized; _coalExistenceInfo.Show(); _coalExistenceInfo.Activate(); } else if (MineData is GasData) { var gasData = (GasData)MineData; _gasData.bindDefaultValue(gasData); Height = FormHeight + _gasData.Height; _gasData.WindowState = FormWindowState.Maximized; _gasData.Show(); _gasData.Activate(); } else if (MineData is GeologicStructure) { var geologicStructure = (GeologicStructure)MineData; _geologicStructure.bindDefaultValue(geologicStructure); Height = FormHeight + _geologicStructure.Height; _geologicStructure.WindowState = FormWindowState.Maximized; _geologicStructure.Show(); _geologicStructure.Activate(); } else if (MineData is Ventilation) { var ventilation = (Ventilation)MineData; _ventilationInfo.bindDefaultValue(ventilation); Height = FormHeight + _ventilationInfo.Height; _ventilationInfo.WindowState = FormWindowState.Maximized; _ventilationInfo.Show(); _ventilationInfo.Activate(); } else if (MineData is Management) { var management = (Management)MineData; _management.bindDefaultValue(management); Height = FormHeight + _management.Height; _management.WindowState = FormWindowState.Maximized; _management.Show(); _management.Activate(); } } else { if (!String.IsNullOrWhiteSpace(Submitter)) { cboSubmitter.Text = Submitter; } if (Text == new LibPanels(MineDataPanelName.Ventilation_Change).panelFormName) { _viEntity = (Ventilation)_obj; } if (Text == new LibPanels(MineDataPanelName.CoalExistence_Change).panelFormName) { _ceEntity = (CoalExistence)_obj; } if (Text == new LibPanels(MineDataPanelName.GasData_Change).panelFormName) { _gdEntity = (GasData)_obj; } if (Text == new LibPanels(MineDataPanelName.Management_Change).panelFormName) { _mEntity = (Management)_obj; } if (Text == new LibPanels(MineDataPanelName.GeologicStructure_Change).panelFormName) { _geologicStructureEntity = (GeologicStructure)_obj; } //所有小窗体最小化 //AllMin(); //通风 if (Text == new LibPanels(MineDataPanelName.Ventilation).panelFormName) { Height = FormHeight + _ventilationInfo.Height; _ventilationInfo.WindowState = FormWindowState.Maximized; _ventilationInfo.Show(); _ventilationInfo.Activate(); } //煤层赋存 if (Text == new LibPanels(MineDataPanelName.CoalExistence).panelFormName) { Height = FormHeight + _coalExistenceInfo.Height; _coalExistenceInfo.WindowState = FormWindowState.Maximized; _coalExistenceInfo.Show(); _coalExistenceInfo.Activate(); } //瓦斯 if (Text == new LibPanels(MineDataPanelName.GasData).panelFormName) { Height = FormHeight + _gasData.Height; _gasData.WindowState = FormWindowState.Maximized; _gasData.Show(); _gasData.Activate(); } //管理 if (Text == new LibPanels(MineDataPanelName.Management).panelFormName) { Height = FormHeight + _management.Height; _management.WindowState = FormWindowState.Maximized; _management.Show(); _management.Activate(); } //地质构造 if (Text == new LibPanels(MineDataPanelName.GeologicStructure).panelFormName) { Height = FormHeight + _geologicStructure.Height; _geologicStructure.WindowState = FormWindowState.Maximized; _geologicStructure.Show(); _geologicStructure.Activate(); } //绑定通风修改初始信息 if (Text == new LibPanels(MineDataPanelName.Ventilation_Change).panelFormName) { Height = FormHeight + _ventilationInfo.Height; ChangeMineCommonValue(_viEntity); _ventilationInfo.VentilationEntity = _viEntity; _ventilationInfo.bindDefaultValue(_viEntity); _ventilationInfo.WindowState = FormWindowState.Maximized; _ventilationInfo.Show(); _ventilationInfo.Activate(); } //绑定煤层赋存修改初始信息 if (Text == new LibPanels(MineDataPanelName.CoalExistence_Change).panelFormName) { Height = FormHeight + _coalExistenceInfo.Height; ChangeMineCommonValue(_ceEntity); _coalExistenceInfo.coalExistenceEntity = _ceEntity; _coalExistenceInfo.bindDefaultValue(_ceEntity); _coalExistenceInfo.WindowState = FormWindowState.Maximized; _coalExistenceInfo.Show(); _coalExistenceInfo.Activate(); } //绑定瓦斯修改初始信息 if (Text == new LibPanels(MineDataPanelName.GasData_Change).panelFormName) { Height = FormHeight + _gasData.Height; ChangeMineCommonValue(_gdEntity); _gasData.GasDataEntity = _gdEntity; _gasData.bindDefaultValue(_gdEntity); _gasData.WindowState = FormWindowState.Maximized; _gasData.Show(); _gasData.Activate(); } //绑定管理修改初始信息 if (Text == new LibPanels(MineDataPanelName.Management_Change).panelFormName) { Height = FormHeight + _management.Height; ChangeMineCommonValue(_mEntity); _management.managementEntity = _mEntity; _management.bindDefaultValue(_mEntity); _management.WindowState = FormWindowState.Maximized; _management.Show(); _management.Activate(); } //绑定地质构造修改初始数据 if (Text == new LibPanels(MineDataPanelName.GeologicStructure_Change).panelFormName) { Height = FormHeight + _management.Height; ChangeMineCommonValue(_geologicStructureEntity); _geologicStructure.geoligicStructureEntity = _geologicStructureEntity; _geologicStructure.bindDefaultValue(_geologicStructureEntity); _geologicStructure.WindowState = FormWindowState.Maximized; _geologicStructure.Show(); _geologicStructure.Activate(); } } }