예제 #1
0
        public override void Execute(Data.Data data, Dictionary <string, object> parameters)
        {
            SessionHandler.EnqueueAction(() =>
            {
                var player = Utils.GetPlayer();
                if (player != null)
                {
                    if (Vehicle)
                    {
                        var controlledEntity = player.Controller.ControlledEntity;
                        if (controlledEntity is MyShipController controller)
                        {
                            var grid = controller.CubeGrid;
                            grid.CubeBlocks.Where(block => _random.NextDouble() < VehiclePercentage).ToList()
                            .ForEach(block => grid.RemoveBlock(block));
                        }
                    }

                    if (_random.NextDouble() < PlayerPercentage)
                    {
                        player.Character.Kill(true, new MyDamageInformation());
                    }
                    ActionNotification.SendActionMessage("SNAP!", Color.Red, "ArcHudGPSNotification1");
                }
            });
        }
예제 #2
0
 private void SendMessage(string msg, bool alwaysSendMessage, List <BaseAction> actions)
 {
     SessionHandler.RunOnMainThread(() =>
     {
         var actionMessage = GetMessage(actions);
         msg += actionMessage;
         Plugin.Logger.WriteLine(msg);
         if (actions.Count <= 0 && !alwaysSendMessage)
         {
             return;
         }
         ActionNotification.SendActionMessage(msg, null);
         Utils.SendChat(msg);
     });
 }
예제 #3
0
        public override void Execute(Data.Data data, Dictionary <string, object> parameters)
        {
            SessionHandler.EnqueueAction(() =>
            {
                var player = Utils.GetPlayer();
                if (player != null)
                {
                    var id = new MyDefinitionId((MyObjectBuilderType)typeof(MyObjectBuilder_RadioAntenna), "SmallBlockRadioAntenna");
                    var up = player.Character.PositionComp.GetOrientation().Up;
                    up.Normalize();
                    var definitionBase = (MyRadioAntennaDefinition)MyDefinitionManager.Static.GetCubeBlockDefinition(id);
                    var pos            = player.GetPosition() + up * 50;
                    var world          = MatrixD.CreateWorld(pos, Vector3.Forward, Vector3.Up);
                    var color          = Color.Red.ColorToHSV();
                    var pirateFaction  = MySession.Static.Factions.TryGetFactionByTag("SPRT");
                    MyCubeBuilder.SpawnDynamicGrid(definitionBase, player.Character, world, color,
                                                   MyStringHash.NullOrEmpty,
                                                   0L, MyCubeBuilder.SpawnFlags.Default | MyCubeBuilder.SpawnFlags.SpawnAsMaster,
                                                   pirateFaction.FounderId, entity =>
                    {
                        var grid           = (MyCubeGrid)entity;
                        var pirateAntennas = MySession.Static.GetComponent <MyPirateAntennas>();
                        if (pirateAntennas != null)
                        {
                            var drones = Utils.IsInSpace(pos) ? Configuration.Plugin.Get(c => c.SpaceDrones): Configuration.Plugin.Get(c => c.PlanetDrones);
                            var drone  = (string.IsNullOrEmpty(Drone) ? drones[_random.Next(drones.Length)]: Drone) ?? "Vulture Drone";

                            MyDefinitionManager.Static.TryGetDefinition(
                                new MyDefinitionId(
                                    (MyObjectBuilderType)typeof(MyObjectBuilder_SpawnGroupDefinition),
                                    drone), out MySpawnGroupDefinition spawnGroup);
                            if (spawnGroup != null)
                            {
                                Vector3D?nullable = new Vector3D?();
                                for (int index = 0; index < 10; ++index)
                                {
                                    world    = entity.WorldMatrix;
                                    nullable = MyEntities.FindFreePlace(
                                        world.Translation + MyUtils.GetRandomVector3Normalized() * 1500,
                                        spawnGroup.SpawnRadius);
                                    if (nullable.HasValue)
                                    {
                                        break;
                                    }
                                }

                                foreach (var antenna in grid.GetFatBlocks <MyRadioAntenna>())
                                {
                                    _spawnDrone.Invoke(pirateAntennas,
                                                       new object[]
                                    {
                                        antenna, pirateFaction.FounderId, nullable.Value, spawnGroup,
                                        new Vector3?(), new Vector3?()
                                    });
                                }

                                var spawns = spawnGroup.Prefabs.Select(prefab => prefab.SubtypeId.ToSplitCase())
                                             .GroupBy(s => s).Select(grouping =>
                                                                     (grouping.Count() > 1 ? grouping.Count() + "x " : "") + grouping.Key)
                                             .Join();
                                var msg = "Spawned " + spawns;
                                Utils.SendChat(msg);
                                ActionNotification.SendActionMessage(msg, Color.Red, "ArcHudGPSNotification1");
                            }
                        }
                        grid.CubeBlocks.ToList().ForEach(block => grid.RemoveBlock(block));
                    });
                }
            });
        }