// When tube is ejecting and looking for voxels void StartFindingVoxel() { // Else we normally start ejecting CurrentState = MyHarvestingDeviceEnum.FindingVoxel; m_headPositionLocal = Vector3.Zero; StartTubeMovingCue(); StopGrindingCue(); if (m_light != null) { MyLights.RemoveLight(m_light); } m_light = null; //m_light = MyLights.AddLight(); if (m_light != null) { var color = 5 * new Vector4(1, 0.3f, 0.3f, 1); m_light.Start(MyLight.LightTypeEnum.PointLight, color, 3, 10); } MyScriptWrapper.HarvesterUse(); UpdateAfterSimulation(); }
// When tube didn't find voxels so it's pulling back void StartReturningBack() { // Head was in voxels, so we return it back to the ship CurrentState = MyHarvestingDeviceEnum.ReturningBack; m_parentMinerShip.Physics.Immovable = false; StopGrindingCue(); StartTubeMovingCue(); CloseEffect(); }
// When tube collided with something so we must pull it back quickly, so player won't notice intersection void StartFastReturningBack() { CurrentState = MyHarvestingDeviceEnum.FastReturningBack; m_parentMinerShip.Physics.Immovable = false; MyAudio.AddCue2dOr3d(Parent, MySoundCuesEnum.VehHarvesterTubeCollision2d, Parent.GetPosition(), Parent.WorldMatrix.Forward, Parent.WorldMatrix.Up, Parent.Physics.LinearVelocity); StopGrindingCue(); StopTubeMovingCue(); CloseEffect(); }
// When tube is inside miner ship, default status void StartInsideShip() { CurrentState = MyHarvestingDeviceEnum.InsideShip; StopTubeMovingCue(); if (m_light != null) { MyLights.RemoveLight(m_light); } m_light = null; }
// When tube/head mounted into voxels and is harvesting void StartInVoxel(MyVoxelMap voxelMap) { // We found voxel so we stop here m_inVoxelMap = voxelMap; CurrentState = MyHarvestingDeviceEnum.InVoxel; StopTubeMovingCue(); StartGrindingCue(); m_lastTimeParticleAdded = null; m_parentMinerShip.Physics.Clear(); m_parentMinerShip.Physics.Immovable = true; MyMwcVector3Int tempVoxelCoord = voxelMap.GetVoxelCenterCoordinateFromMeters(ref m_headPositionTransformed); m_originalVoxelContent = voxelMap.GetVoxelContent(ref tempVoxelCoord); m_voxelMaterial = voxelMap.GetVoxelMaterial(ref tempVoxelCoord); m_harvestingParticleEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Harvester_Harvesting); m_harvestingParticleEffect.UserBirthMultiplier = 0.25f; m_harvestingParticleEffect.UserRadiusMultiplier = 1; m_harvestingParticleEffect.UserColorMultiplier = new Vector4(3, 3, 3, 3); Matrix dirMatrix = MyMath.MatrixFromDir(WorldMatrix.Forward); m_harvestingParticleEffect.WorldMatrix = Matrix.CreateWorld(m_headPositionTransformed, dirMatrix.Forward, dirMatrix.Up); // Empty voxels are problematic and can lead to "extremely fast harvesting". So here we do this // trick and its effect will be that even empty voxels will take few seconds to harvest. if (m_originalVoxelContent == 0) { m_originalVoxelContent = 1; } m_actualVoxelContent = (float)m_originalVoxelContent; m_harvestingSpeed = m_actualVoxelContent / TIME_TO_HARVEST_WHOLE_VOXEL_IN_UPDATE_TIMES; if (!MyVoxelMapOreMaterials.CanBeHarvested(m_voxelMaterial)) { HUD.MyHud.ShowIndestructableAsteroidNotification(); StartReturningBack(); } }
// When tube is inside miner ship, default status void StartInsideShip() { CurrentState = MyHarvestingDeviceEnum.InsideShip; StopTubeMovingCue(); if (m_light != null) MyLights.RemoveLight(m_light); m_light = null; }
// When tube collided with something so we must pull it back quickly, so player won't notice intersection void StartFastReturningBack() { CurrentState = MyHarvestingDeviceEnum.FastReturningBack; m_parentMinerShip.Physics.Immovable = false; MyAudio.AddCue2dOr3d(Parent, MySoundCuesEnum.VehHarvesterTubeCollision2d, Parent.GetPosition(), Parent.WorldMatrix.Forward, Parent.WorldMatrix.Up, Parent.Physics.LinearVelocity); StopGrindingCue(); StopTubeMovingCue(); CloseEffect(); }
// When tube didn't find voxels so it's pulling back void StartReturningBack() { // Head was in voxels, so we return it back to the ship CurrentState = MyHarvestingDeviceEnum.ReturningBack; m_parentMinerShip.Physics.Immovable = false; StopGrindingCue(); StartTubeMovingCue(); CloseEffect(); }
// When tube/head mounted into voxels and is harvesting void StartInVoxel(MyVoxelMap voxelMap) { // We found voxel so we stop here m_inVoxelMap = voxelMap; CurrentState = MyHarvestingDeviceEnum.InVoxel; StopTubeMovingCue(); StartGrindingCue(); m_lastTimeParticleAdded = null; m_parentMinerShip.Physics.Clear(); m_parentMinerShip.Physics.Immovable = true; MyMwcVector3Int tempVoxelCoord = voxelMap.GetVoxelCenterCoordinateFromMeters(ref m_headPositionTransformed); m_originalVoxelContent = voxelMap.GetVoxelContent(ref tempVoxelCoord); m_voxelMaterial = voxelMap.GetVoxelMaterial(ref tempVoxelCoord); m_harvestingParticleEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Harvester_Harvesting); m_harvestingParticleEffect.UserBirthMultiplier = 0.25f; m_harvestingParticleEffect.UserRadiusMultiplier = 1; m_harvestingParticleEffect.UserColorMultiplier = new Vector4(3, 3, 3, 3); Matrix dirMatrix = MyMath.MatrixFromDir(WorldMatrix.Forward); m_harvestingParticleEffect.WorldMatrix = Matrix.CreateWorld(m_headPositionTransformed, dirMatrix.Forward, dirMatrix.Up); // Empty voxels are problematic and can lead to "extremely fast harvesting". So here we do this // trick and its effect will be that even empty voxels will take few seconds to harvest. if (m_originalVoxelContent == 0) m_originalVoxelContent = 1; m_actualVoxelContent = (float)m_originalVoxelContent; m_harvestingSpeed = m_actualVoxelContent / TIME_TO_HARVEST_WHOLE_VOXEL_IN_UPDATE_TIMES; if (!MyVoxelMapOreMaterials.CanBeHarvested(m_voxelMaterial)) { HUD.MyHud.ShowIndestructableAsteroidNotification(); StartReturningBack(); } }
// When tube is ejecting and looking for voxels void StartFindingVoxel() { // Else we normally start ejecting CurrentState = MyHarvestingDeviceEnum.FindingVoxel; m_headPositionLocal = Vector3.Zero; StartTubeMovingCue(); StopGrindingCue(); if (m_light != null) MyLights.RemoveLight(m_light); m_light = null; //m_light = MyLights.AddLight(); if (m_light != null) { var color = 5 * new Vector4(1, 0.3f, 0.3f, 1); m_light.Start(MyLight.LightTypeEnum.PointLight, color, 3, 10); } MyScriptWrapper.HarvesterUse(); UpdateAfterSimulation(); }