Пример #1
0
        public static void LoadInDraw()
        {
            MyMwcLog.WriteLine("MyMeteorWind.LoadInDraw() - START");
            MyMwcLog.IncreaseIndent();
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyMeteorWind::LoadInDraw");

            List <MyMwcObjectBuilder_StaticAsteroid_TypesEnum> asteroids = new List <MyMwcObjectBuilder_StaticAsteroid_TypesEnum>();

            List <int> sizes = new List <int>();

            foreach (int size in MyMwcObjectBuilder_StaticAsteroid.AsteroidSizes)
            {
                if (size >= minSize && size <= maxSize)
                {
                    sizes.Add(size);
                }
            }
            foreach (int size in sizes)
            {
                MyMwcObjectBuilder_Meteor.GetAsteroids(size, MyStaticAsteroidTypeSetEnum.A, asteroids);
            }

            foreach (var asteroid in asteroids)
            {
                MyStaticAsteroid.MyStaticAsteroidModels models = MyMeteor.GetModelsFromType(asteroid);
                PreloadModels(models);
            }


            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
            MyMwcLog.DecreaseIndent();
            MyMwcLog.WriteLine("MyMeteorWind.LoadInDraw() - END");
        }
Пример #2
0
        //  This method will start sun wind. Or if there is one coming, this will reset it so it will start again.
        public static void Start()
        {
            IsActive = true;

            //m_burningCue = MyAudio.AddCue3D(MySoundCuesEnum.SfxSolarWind, m_initialSunWindPosition, m_directionFromSunNormalized, Vector3.Up, Vector3.Zero);

            const int meteorsCount = 5;
            //const int frontDistance = 1000;
            //const int sideDistance = 3000;

            const int minSpeed = 1000;
            const int maxSpeed = 4000;

            //Vector3 sphereCenter = MyCamera.Position + MyCamera.ForwardVector * frontDistance - MyCamera.LeftVector * sideDistance;
            Vector3 sphereCenter = MyCamera.Position + MyGuiScreenGamePlay.Static.GetDirectionToSunNormalized() * 10000;
            //Vector3 windForwardDirection = MyCamera.LeftVector ;

            int i = 0;

            while (i < meteorsCount)
            {
                //float distance = MyMwcUtils.GetRandomFloat(0, sphereRadius);
                //Vector3 position = sphereCenter + MyMwcUtils.GetRandomVector3Normalized() * new Vector3(distance, distance, distance);

                //Vector3 meteorDirection = (windForwardDirection + (MyMwcUtils.GetRandomVector3Normalized() * 0.05f)) * MyMwcUtils.GetRandomInt(minSpeed, maxSpeed);
                //Vector3 meteorDirection = -MyGuiScreenGamePlay.Static.GetDirectionToSunNormalized();// MyMwcUtils.GetRandomVector3HemisphereNormalized(-MyGuiScreenGamePlay.Static.GetDirectionToSunNormalized());
                Vector3 meteorDirection = MyMwcUtils.GetRandomVector3HemisphereNormalized(-MyGuiScreenGamePlay.Static.GetDirectionToSunNormalized());
                Vector3 position        = sphereCenter + meteorDirection * MyMwcUtils.GetRandomInt(100, 5000);

                //float normalizedDistance = distance / sphereRadius;

                float size = MyMwcUtils.GetRandomInt(minSize, maxSize);


                MyLine line = new MyLine(position, position + meteorDirection * 100);
                MyIntersectionResultLineBoundingSphere?result = MyEntities.GetIntersectionWithLineAndBoundingSphere(ref line, null, null, 1, null, true);
                if (result != null)
                {   //Do not create meteors colliding with base
                    if (!(result.Value.PhysObject is MyMeteor))
                    {
                        continue;
                    }
                }

                Matrix worldMatrix = Matrix.CreateFromAxisAngle(MyMwcUtils.GetRandomVector3Normalized(), MyMwcUtils.GetRandomFloat(0, MathHelper.Pi));
                worldMatrix.Translation = position;

                MyMeteor meteor = MyMeteor.GenerateMeteor(size, worldMatrix, position, m_fireMeteorMaterials[MyMwcUtils.GetRandomInt(0, m_fireMeteorMaterials.Count)]);


                float speed = MyMwcUtils.GetRandomInt(minSpeed, maxSpeed);


                meteor.Start(meteorDirection * speed, MyMwcUtils.GetRandomFloat(0, 1) > 0.92f ? 101 : 100);

                i++;
            }
        }
Пример #3
0
        private bool IsValidMeteor(MyMeteor meteor)
        {
            if (meteor != null)
            {
                return(!TargetMeteors);
            }

            return(false);
        }
Пример #4
0
        public static MyMeteor CreateComet(Vector3 position, Vector3 direction)
        {
            float size = MyMwcUtils.GetRandomInt(m_sizeMin, m_sizeMax);

            Matrix worldMatrix = Matrix.CreateFromAxisAngle(MyMwcUtils.GetRandomVector3Normalized(), MyMwcUtils.GetRandomFloat(0, MathHelper.Pi));

            worldMatrix.Translation = position;

            MyMeteor meteor = MyMeteor.GenerateMeteor(size, worldMatrix, position, m_iceMeteorMaterials[MyMwcUtils.GetRandomInt(0, m_iceMeteorMaterials.Count)]);

            meteor.Start(direction, 953);

            return(meteor);
        }
Пример #5
0
        public MyTomasInputComponent()
        {
            AddShortcut(MyKeys.Delete, true, true, false, false,
                        () => "Delete all characters",
                        delegate
            {
                foreach (var obj in MyEntities.GetEntities().OfType <MyCharacter>())
                {
                    if (obj == MySession.ControlledEntity)
                    {
                        MySession.SetCameraController(MyCameraControllerEnum.Spectator);
                    }
                    obj.Close();
                }

                foreach (var obj in MyEntities.GetEntities().OfType <MyCubeGrid>())
                {
                    foreach (var obj2 in obj.GetBlocks())
                    {
                        if (obj2.FatBlock is MyCockpit)
                        {
                            var cockpit = obj2.FatBlock as MyCockpit;
                            if (cockpit.Pilot != null)
                            {
                                cockpit.Pilot.Close();
                            }
                        }
                    }
                }
                return(true);
            });

            AddShortcut(MyKeys.NumPad4, true, false, false, false,
                        () => "Spawn cargo ship or barbarians",
                        delegate
            {
                var theEvent = MyGlobalEvents.GetEventById(new MyDefinitionId(typeof(MyObjectBuilder_GlobalEventBase), "SpawnCargoShip"));
                if (theEvent == null)
                {
                    theEvent = MyGlobalEvents.GetEventById(new MyDefinitionId(typeof(MyObjectBuilder_GlobalEventBase), "SpawnBarbarians"));
                }
                if (theEvent != null)
                {
                    MyGlobalEvents.RemoveGlobalEvent(theEvent);
                    theEvent.SetActivationTime(TimeSpan.FromSeconds(1));
                    MyGlobalEvents.AddGlobalEvent(theEvent);
                }
                return(true);
            });

            AddShortcut(MyKeys.NumPad5, true, false, false, false,
                        () => "Spawn random meteor",
                        delegate
            {
                var camera        = MySector.MainCamera;
                var target        = camera.Position + MySector.MainCamera.ForwardVector * 20.0f;
                var spawnPosition = target + MySector.DirectionToSunNormalized * 1000.0f;

                if (MyUtils.GetRandomFloat(0.0f, 1.0f) < 0.2f)
                {
                    MyMeteor.SpawnRandomLarge(spawnPosition, -MySector.DirectionToSunNormalized);
                }
                else
                {
                    MyMeteor.SpawnRandomSmall(spawnPosition, -MySector.DirectionToSunNormalized);
                }
                return(true);
            });

            AddShortcut(MyKeys.NumPad8, true, false, false, false,
                        () => "Switch control to next entity",
                        delegate
            {
                if (MySession.ControlledEntity != null)
                { //we already are controlling this object
                    var cameraController = MySession.GetCameraControllerEnum();
                    if (cameraController != MyCameraControllerEnum.Entity && cameraController != MyCameraControllerEnum.ThirdPersonSpectator)
                    {
                        MySession.SetCameraController(MyCameraControllerEnum.Entity, MySession.ControlledEntity.Entity);
                    }
                    else
                    {
                        var entities       = MyEntities.GetEntities().ToList();
                        int lastKnownIndex = entities.IndexOf(MySession.ControlledEntity.Entity);

                        var entitiesList = new List <MyEntity>();
                        if (lastKnownIndex + 1 < entities.Count)
                        {
                            entitiesList.AddRange(entities.GetRange(lastKnownIndex + 1, entities.Count - lastKnownIndex - 1));
                        }

                        if (lastKnownIndex != -1)
                        {
                            entitiesList.AddRange(entities.GetRange(0, lastKnownIndex + 1));
                        }

                        MyCharacter newControlledObject = null;

                        for (int i = 0; i < entitiesList.Count; i++)
                        {
                            var character = entitiesList[i] as MyCharacter;
                            if (character != null)
                            {
                                newControlledObject = character;
                                break;
                            }
                        }

                        if (newControlledObject != null)
                        {
                            MySession.LocalHumanPlayer.Controller.TakeControl(newControlledObject);
                        }
                    }
                }

                return(true);
            });


            AddShortcut(MyKeys.NumPad7, true, false, false, false,
                        () => "Use next ship",
                        delegate
            {
                MyCharacterInputComponent.UseNextShip();
                return(true);
            });

            AddShortcut(MyKeys.NumPad9, true, false, false, false,
                        () => "Debug new grid screen",
                        delegate
            {
                MyGuiSandbox.AddScreen(new DebugNewGridScreen());
                return(true);
            });

            AddShortcut(MyKeys.N, true, false, false, false,
                        () => "Refill all batteries",
                        delegate
            {
                foreach (var entity in MyEntities.GetEntities())
                {
                    MyCubeGrid grid = entity as MyCubeGrid;
                    if (grid != null)
                    {
                        foreach (var block in grid.GetBlocks())
                        {
                            MyBatteryBlock battery = block.FatBlock as MyBatteryBlock;
                            if (battery != null)
                            {
                                battery.CurrentStoredPower = battery.MaxStoredPower;
                            }
                        }
                    }
                }
                return(true);
            });

            AddShortcut(MyKeys.U, true, false, false, false,
                        () => "Spawn new character",
                        delegate
            {
                var character = MyCharacterInputComponent.SpawnCharacter();
                return(true);
            });


            AddShortcut(MyKeys.NumPad2, true, false, false, false,
                        () => "Merge static grids",
                        delegate
            {
                // Try to merge all static large grids
                HashSet <MyCubeGrid> ignoredGrids = new HashSet <MyCubeGrid>();
                while (true)
                {
                    // Flag that we need new entities enumeration
                    bool needNewEntitites = false;

                    foreach (var entity in MyEntities.GetEntities())
                    {
                        MyCubeGrid grid = entity as MyCubeGrid;
                        if (grid != null && grid.IsStatic && grid.GridSizeEnum == MyCubeSize.Large)
                        {
                            if (ignoredGrids.Contains(grid))
                            {
                                continue;
                            }

                            List <MySlimBlock> blocks = grid.GetBlocks().ToList();
                            foreach (var block in blocks)
                            {
                                var mergedGrid = grid.DetectMerge(block);
                                if (mergedGrid == null)
                                {
                                    continue;
                                }

                                needNewEntitites = true;
                                // Grid merged to other grid? Then break and loop all entities again.
                                if (mergedGrid != grid)
                                {
                                    break;
                                }
                            }

                            if (!needNewEntitites)
                            {
                                ignoredGrids.Add(grid);
                            }
                        }

                        if (needNewEntitites)
                        {
                            break;
                        }
                    }

                    if (!needNewEntitites)
                    {
                        break;
                    }
                }
                return(true);
            });

            AddShortcut(MyKeys.Add, true, false, false, false,
                        () => "Increase wheel animation speed",
                        delegate
            {
                USE_WHEEL_ANIMATION_SPEED += 0.05f;
                return(true);
            });

            AddShortcut(MyKeys.Subtract, true, false, false, false,
                        () => "Decrease wheel animation speed",
                        delegate
            {
                USE_WHEEL_ANIMATION_SPEED -= 0.05f;
                return(true);
            });

            AddShortcut(MyKeys.Divide, true, false, false, false,
                        () => "Show model texture names",
                        delegate
            {
                MyFakes.ENABLE_DEBUG_DRAW_TEXTURE_NAMES = !MyFakes.ENABLE_DEBUG_DRAW_TEXTURE_NAMES;
                return(true);
            });

            AddShortcut(MyKeys.NumPad1, true, false, false, false,
                        () => "Throw from spectator: " + Sandbox.Game.Components.MySessionComponentThrower.USE_SPECTATOR_FOR_THROW,
                        delegate
            {
                Sandbox.Game.Components.MySessionComponentThrower.USE_SPECTATOR_FOR_THROW = !Sandbox.Game.Components.MySessionComponentThrower.USE_SPECTATOR_FOR_THROW;
                return(true);
            });

            AddShortcut(MyKeys.F2, true, false, false, false, () => "Spectator to next small grid", () => SpectatorToNextGrid(MyCubeSize.Small));
            AddShortcut(MyKeys.F3, true, false, false, false, () => "Spectator to next large grid", () => SpectatorToNextGrid(MyCubeSize.Large));
        }
        public MyAsteroidsDebugInputComponent()
        {
            //AddShortcut(MyKeys.NumPad1, true, false, false, false,
            //    () => "Debug draw procedural asteroid seeds: " + m_drawSeeds,
            //    delegate
            //    {
            //        m_drawSeeds = !m_drawSeeds;
            //        return true;
            //    });

            //AddShortcut(MyKeys.NumPad2, true, false, false, false,
            //    () => "Debug draw procedural tracked entities: " + m_drawTrackedEntities,
            //    delegate
            //    {
            //        m_drawTrackedEntities = !m_drawTrackedEntities;
            //        return true;
            //    });

            //AddShortcut(MyKeys.NumPad3, true, false, false, false,
            //    () => "Debug draw around camera: " + m_drawAroundCamera,
            //    delegate
            //    {
            //        m_drawAroundCamera = !m_drawAroundCamera;
            //        return true;
            //    });

            //AddShortcut(MyKeys.NumPad4, true, false, false, false,
            //    () => "Toggle farplane distance: " + (MySector.MainCamera == null ? -1f : MySector.MainCamera.FarPlaneDistance),
            //    delegate
            //    {
            //        m_fakeFarPlaneDistance = !m_fakeFarPlaneDistance;
            //        if (m_originalFarPlaneDisatance == -1)
            //        {
            //            m_originalFarPlaneDisatance = MySector.MainCamera.FarPlaneDistance;
            //        }
            //        if (m_fakeFarPlaneDistance)
            //        {
            //            MySector.MainCamera.FarPlaneDistance = m_debugFarPlaneDistance;
            //        }
            //        else
            //        {
            //            MySector.MainCamera.FarPlaneDistance = m_originalFarPlaneDisatance;
            //        }
            //        return true;
            //    });

            //AddShortcut(MyKeys.NumPad5, true, false, false, false,
            //    () => "Debug draw procedural seed radius: " + m_drawRadius,
            //    delegate
            //    {
            //        m_drawRadius = !m_drawRadius;
            //        return true;
            //    });

            //AddShortcut(MyKeys.NumPad6, true, false, false, false,
            //    () => "Debug draw procedural seed distance: " + m_drawDistance,
            //    delegate
            //    {
            //        m_drawDistance = !m_drawDistance;
            //        return true;
            //    });


            //AddShortcut(MyKeys.NumPad8, true, false, false, false,
            //    () => "Debug draw procedural cells: " + m_drawCells,
            //    delegate
            //    {
            //        m_drawCells = !m_drawCells;
            //        return true;
            //    });

            //AddShortcut(MyKeys.NumPad9, true, false, false, false,
            //    () => "Spawn new moving player somewhere: " + m_plys.Count,
            //    delegate
            //    {
            //        var pos = new Vector3D(MyRandom.Instance.NextFloat() * 2 - 1f, MyRandom.Instance.NextFloat() * 2 - 1f, MyRandom.Instance.NextFloat() * 2 - 1f) * 150000;
            //        var vel = new Vector3(MyRandom.Instance.NextFloat() * 2 - 1f, MyRandom.Instance.NextFloat() * 2 - 1f, MyRandom.Instance.NextFloat() * 2 - 1f);
            //        vel.Normalize();
            //        var ply = MyCharacter.CreateCharacter(MatrixD.CreateTranslation(pos), vel * 100 * (MyRandom.Instance.NextFloat() * 0.5f + 0.5f), "ALIEN SPACE NINJA", MyCharacter.DefaultModel, null, null, false);
            //        m_plys.Add(ply);
            //        return true;
            //    });

            //AddShortcut(MyKeys.NumPad0, true, false, false, false,
            //    () => "Remove one spawned player: " + m_plys.Count,
            //    delegate
            //    {
            //        if (m_plys.Count == 0)
            //            return false;
            //        var ply = m_plys[0];
            //        m_plys.Remove(ply);
            //        ply.Close();
            //        return true;
            //    });

            AddShortcut(MyKeys.NumPad3, true, false, false, false, () => "Enable Meteor Debug Draw", delegate
            {
                MyDebugDrawSettings.DEBUG_DRAW_METEORITS_DIRECTIONS = true;
                return(true);
            });

            AddShortcut(MyKeys.NumPad2, true, false, false, false, () => "Spawn meteor shower", delegate
            {
                MyMeteorShower.StartDebugWave(MySession.Static.LocalCharacter.WorldMatrix.Translation);
                return(true);
            });

            AddShortcut(MyKeys.NumPad1, true, false, false, false, () => "Spawn small asteroid", delegate
            {
                Vector3 charpos = MySession.Static.LocalCharacter.WorldMatrix.Translation;
                Vector3 chardir = MySession.Static.LocalCharacter.WorldMatrix.Forward;
                MyMeteor.SpawnRandom(charpos + chardir * 2, chardir);
                return(true);
            });

            AddShortcut(MyKeys.NumPad0, true, false, false, false, () => "Spawn crater", delegate
            {
                SpawnCrater();
                return(true);
            });
        }