예제 #1
0
        private bool LoadShipBlueprint(MyObjectBuilder_ShipBlueprintDefinition shipBlueprint, Vector3D GridSaveLocation, Vector3D PlayerLocation, bool keepOriginalLocation, Chat chat, Hangar Plugin, bool force = false)
        {
            var grids = shipBlueprint.CubeGrids;

            if (grids == null || grids.Length == 0)
            {
                chat.Respond("No grids in blueprint!");
                return(false);
            }

            try
            {
                MyIdentity IDentity = MySession.Static.Players.TryGetPlayerIdentity(new MyPlayer.PlayerId(SteamID));

                if (Plugin.GridBackup != null)
                {
                    Plugin.GridBackup.GetType().GetMethod("BackupGridsManuallyWithBuilders", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance, null, new Type[2] {
                        typeof(List <MyObjectBuilder_CubeGrid>), typeof(long)
                    }, null).Invoke(Plugin.GridBackup, new object[] { grids.ToList(), IDentity.IdentityId });
                    Log.Warn("Successfully BackedUp grid!");
                }
            }
            catch (Exception e)
            {
                Log.Fatal(e);
            }

            Vector3D TargetLocation;
            bool     AlignToGravity = false;

            if (keepOriginalLocation)
            {
                TargetLocation = GridSaveLocation;
            }
            else
            {
                AlignToGravity = true;
                TargetLocation = PlayerLocation;
            }

            ParallelSpawner Spawner = new ParallelSpawner(grids, chat, AlignToGravity);

            Log.Info("Attempting Grid Spawning @" + TargetLocation.ToString());
            return(Spawner.Start(keepOriginalLocation, TargetLocation));
        }
        private bool LoadShipBlueprint(MyObjectBuilder_ShipBlueprintDefinition shipBlueprint, Vector3D GridSaveLocation, Vector3D SpawningPlayerLocation, bool keepOriginalLocation, Chat chat)
        {
            var grids = shipBlueprint.CubeGrids;

            if (grids == null || grids.Length == 0)
            {
                Chat?.Respond("No grids in blueprint!");
                return(false);
            }


            MyIdentity Identity = MySession.Static.Players.TryGetPlayerIdentity(new MyPlayer.PlayerId(SteamID));


            if (Identity != null)
            {
                PluginDependencies.BackupGrid(grids.ToList(), Identity.IdentityId);
            }


            Vector3D TargetLocation;
            bool     AlignToGravity = false;

            if (keepOriginalLocation || SpawningPlayerLocation == Vector3D.Zero)
            {
                TargetLocation = GridSaveLocation;
            }
            else
            {
                AlignToGravity = true;
                TargetLocation = SpawningPlayerLocation;
            }

            ParallelSpawner Spawner = new ParallelSpawner(grids, chat, AlignToGravity);

            Log.Info("Attempting Grid Spawning @" + TargetLocation.ToString());
            return(Spawner.Start(keepOriginalLocation, TargetLocation));
        }