public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { SyncFlag = true; base.Init(objectBuilder, cubeGrid); //MyDebug.AssertDebug(objectBuilder.TypeId == typeof(MyObjectBuilder_ShipController)); var def = MyDefinitionManager.Static.GetCubeBlockDefinition(objectBuilder.GetId()); m_enableFirstPerson = BlockDefinition.EnableFirstPerson || MySession.Static.Settings.Enable3rdPersonView == false; m_enableShipControl = BlockDefinition.EnableShipControl; m_rechargeSocket = new MyRechargeSocket(); MyObjectBuilder_ShipController shipControllerOb = (MyObjectBuilder_ShipController)objectBuilder; // No need for backward compatibility of selected weapon, we just leave it alone // m_selectedGunType = shipControllerOb.SelectedGunType; m_selectedGunId = shipControllerOb.SelectedGunId; m_controlThrusters = shipControllerOb.ControlThrusters; m_controlWheels = shipControllerOb.ControlWheels; if (shipControllerOb.IsMainCockpit) { IsMainCockpit = true; } Toolbar = new MyToolbar(ToolbarType); Toolbar.Init(shipControllerOb.Toolbar, this); SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged; // TODO: Seems like overkill if (Sync.IsServer && false) { //Because of simulating thrusts NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME; } CubeGrid.OnGridSplit += CubeGrid_OnGridSplit; }
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { var medicalRoomDefinition = BlockDefinition as MyMedicalRoomDefinition; MyStringHash resourceSinkGroup; if (medicalRoomDefinition != null) { m_idleSound = new MySoundPair(medicalRoomDefinition.IdleSound); m_progressSound = new MySoundPair(medicalRoomDefinition.ProgressSound); resourceSinkGroup = MyStringHash.GetOrCompute(medicalRoomDefinition.ResourceSinkGroup); } else { m_idleSound = new MySoundPair("BlockMedical"); m_progressSound = new MySoundPair("BlockMedicalProgress"); resourceSinkGroup = MyStringHash.GetOrCompute("Utility"); } SinkComp = new MyResourceSinkComponent(); SinkComp.Init( resourceSinkGroup, MyEnergyConstants.MAX_REQUIRED_POWER_MEDICAL_ROOM, () => (Enabled && IsFunctional) ? SinkComp.MaxRequiredInput : 0f); SinkComp.IsPoweredChanged += Receiver_IsPoweredChanged; base.Init(objectBuilder, cubeGrid); m_rechargeSocket = new MyRechargeSocket(); NeedsUpdate |= MyEntityUpdateEnum.EACH_10TH_FRAME; SteamUserId = (objectBuilder as MyObjectBuilder_MedicalRoom).SteamUserId; if (SteamUserId != 0) //backward compatibility { MyPlayer controller = Sync.Players.GetPlayerById(new MyPlayer.PlayerId(SteamUserId)); if (controller != null) { IDModule.Owner = controller.Identity.IdentityId; IDModule.ShareMode = MyOwnershipShareModeEnum.Faction; } } SteamUserId = 0; m_takeSpawneeOwnership = (objectBuilder as MyObjectBuilder_MedicalRoom).TakeOwnership; m_setFactionToSpawnee = (objectBuilder as MyObjectBuilder_MedicalRoom).SetFaction; SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged; InitializeConveyorEndpoint(); SinkComp.Update(); AddDebugRenderComponent(new MyDebugRenderComponentDrawPowerReciever(SinkComp, this)); if (this.CubeGrid.CreatePhysics) Components.Add<MyRespawnComponent>(new MyRespawnComponent()); m_healingAllowed = medicalRoomDefinition.HealingAllowed; m_refuelAllowed = medicalRoomDefinition.RefuelAllowed; m_suitChangeAllowed = medicalRoomDefinition.SuitChangeAllowed; m_customWardrobesEnabled = medicalRoomDefinition.CustomWardrobesEnabled; m_forceSuitChangeOnRespawn = medicalRoomDefinition.ForceSuitChangeOnRespawn; m_customWardrobeNames = medicalRoomDefinition.CustomWardrobeNames; m_respawnSuitName = medicalRoomDefinition.RespawnSuitName; m_spawnWithoutOxygenEnabled = medicalRoomDefinition.SpawnWithoutOxygenEnabled; RespawnAllowed = medicalRoomDefinition.RespawnAllowed; }
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { base.Init(objectBuilder, cubeGrid); if (BlockDefinition is MyMedicalRoomDefinition) { var def = (MyMedicalRoomDefinition)BlockDefinition; m_idleSound = new MySoundPair(def.IdleSound); m_progressSound = new MySoundPair(def.ProgressSound); } else { m_idleSound = new MySoundPair("BlockMedical"); m_progressSound = new MySoundPair("BlockMedicalProgress"); } m_rechargeSocket = new MyRechargeSocket(); NeedsUpdate = MyEntityUpdateEnum.EACH_10TH_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME; SteamUserId = (objectBuilder as MyObjectBuilder_MedicalRoom).SteamUserId; if (SteamUserId != 0) //backward compatibility { MyPlayer controller = Sync.Players.TryGetPlayerById(new MyPlayer.PlayerId(SteamUserId)); if (controller != null) { IDModule.Owner = controller.Identity.IdentityId; IDModule.ShareMode = MyOwnershipShareModeEnum.Faction; } } SteamUserId = 0; m_takeSpawneeOwnership = (objectBuilder as MyObjectBuilder_MedicalRoom).TakeOwnership; m_setFactionToSpawnee = (objectBuilder as MyObjectBuilder_MedicalRoom).SetFaction; SyncObject = new SyncClass(this); SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged; InitializeConveyorEndpoint(); PowerReceiver = new MyPowerReceiver( group: MyConsumerGroupEnum.Utility, isAdaptible: false, maxRequiredInput: MyEnergyConstants.MAX_REQUIRED_POWER_MEDICAL_ROOM, requiredInputFunc: () => (Enabled && IsFunctional) ? PowerReceiver.MaxRequiredInput : 0f); PowerReceiver.IsPoweredChanged += Receiver_IsPoweredChanged; PowerReceiver.Update(); AddDebugRenderComponent(new MyDebugRenderComponentDrawPowerReciever(PowerReceiver, this)); if (this.CubeGrid.CreatePhysics) Components.Add<MyRespawnComponent>(new MyRespawnComponent()); }
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { SyncFlag = true; base.Init(objectBuilder, cubeGrid); //MyDebug.AssertDebug(objectBuilder.TypeId == typeof(MyObjectBuilder_ShipController)); var def = MyDefinitionManager.Static.GetCubeBlockDefinition(objectBuilder.GetId()); m_enableFirstPerson = BlockDefinition.EnableFirstPerson || MySession.Static.Settings.Enable3rdPersonView == false; m_enableShipControl = BlockDefinition.EnableShipControl; m_enableBuilderCockpit = BlockDefinition.EnableBuilderCockpit; m_rechargeSocket = new MyRechargeSocket(); MyObjectBuilder_ShipController shipControllerOb = (MyObjectBuilder_ShipController)objectBuilder; // No need for backward compatibility of selected weapon, we just leave it alone // m_selectedGunType = shipControllerOb.SelectedGunType; m_selectedGunId = shipControllerOb.SelectedGunId; ControlThrusters = shipControllerOb.ControlThrusters; ControlWheels = shipControllerOb.ControlWheels; if (shipControllerOb.IsMainCockpit) { IsMainCockpit = true; } HorizonIndicatorEnabled = shipControllerOb.HorizonIndicatorEnabled; m_toolbar = new MyToolbar(ToolbarType); m_toolbar.Init(shipControllerOb.Toolbar, this); m_toolbar.ItemChanged += Toolbar_ItemChanged; m_buildToolbar = new MyToolbar(MyToolbarType.BuildCockpit); m_buildToolbar.Init(shipControllerOb.BuildToolbar, this); SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged; // TODO: Seems like overkill if (Sync.IsServer && false) { //Because of simulating thrusts NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME; } NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME; m_baseIdleSound = BlockDefinition.PrimarySound; CubeGrid.OnGridSplit += CubeGrid_OnGridSplit; Components.ComponentAdded += OnComponentAdded; Components.ComponentRemoved += OnComponentRemoved; if(EntityThrustComponent != null) { m_dampenersEnabled.Value = EntityThrustComponent.Enabled; } UpdateShipInfo(); if (BlockDefinition.GetInSound != null && BlockDefinition.GetInSound.Length > 0) GetInCockpitSound = new MySoundPair(BlockDefinition.GetInSound); if (BlockDefinition.GetOutSound != null && BlockDefinition.GetOutSound.Length > 0) GetOutOfCockpitSound = new MySoundPair(BlockDefinition.GetOutSound); }