public static void Mountain(Point3 Start, int Radius, int Size, SubsystemTerrain subsystemTerrain, int id, int id1, int id2, ComponentPlayer player)
 {
     Task.Run(() =>
     {
         Game.Random random = new Game.Random();
         double num1        = Math.PI / 2.0;
         float num2         = (float)Size + 0.8f;
         int num3           = 0;
         double num4        = 10.0;
         double num5        = 15.0;
         float num6         = random.UniformFloat((float)num4, (float)num5) + 10f;
         for (int index1 = -Radius; index1 < Radius; ++index1)
         {
             for (int index2 = -Radius; index2 < Radius; ++index2)
             {
                 double num7  = Math.Cos(num1 * (double)index1 / (double)Radius) * Math.Cos(num1 * (double)index2 / (double)Radius) * (double)num2;
                 double num8  = Math.Sin(num1 * (double)index1 * 1.39999997615814 / (double)Radius + 4.0) * Math.Cos(num1 * (double)index2 * 1.39999997615814 / (double)Radius + 7.0) * (double)num2 * 0.25;
                 double num9  = Math.Cos(num1 * (double)index1 * 1.39999997615814 * 2.0 / (double)Radius + 4.0 * (double)num6) * Math.Sin(num1 * (double)index2 * 1.39999997615814 * 2.0 / (double)Radius + 8.0 * (double)num6) * (double)num2 * 0.200000002980232;
                 double num10 = Math.Sin(num1 * (double)index1 * 1.39999997615814 * 4.0 / (double)Radius + 4.0 * (double)num6 * 1.5) * Math.Sin(num1 * (double)index2 * 1.39999997615814 * 4.0 / (double)Radius + 8.0 * (double)num6 * 1.5) * (double)num2 * 0.150000005960464;
                 double num11 = num8;
                 double num12 = num7 - num11 + num9 - num10;
                 if (num12 > 0.0)
                 {
                     for (int index3 = 0; (double)index3 <= num12; ++index3)
                     {
                         if (index3 > 3)
                         {
                             subsystemTerrain.ChangeCell(Start.X + index1, Start.Y + (int)num12 - index3, Start.Z + index2, id, true);
                             ++num3;
                         }
                         else if (index3 > 0)
                         {
                             subsystemTerrain.ChangeCell(Start.X + index1, Start.Y + (int)num12 - index3, Start.Z + index2, id1, true);
                             ++num3;
                         }
                         else if (index3 == 0)
                         {
                             subsystemTerrain.ChangeCell(Start.X + index1, Start.Y + (int)num12, Start.Z + index2, id2, true);
                             ++num3;
                         }
                     }
                 }
             }
         }
         player.ComponentGui.DisplaySmallMessage(string.Format("Sucsses {0} place blocks", num3), true, true);
     });
 }
        public static void Round(bool s, int radius, int lenght, int pos, int id, TerrainRaycastResult?Point1, SubsystemTerrain subsystemTerrain, ComponentPlayer player)
        {
            Task.Run(() =>
            {
                string s2 = Convert.ToString(pos);
                //int num1 = 0;
                for (int index1 = 0; index1 < lenght; ++index1)
                {
                    for (int index2 = -radius; index2 <= 0; ++index2)
                    {
                        for (int index3 = -radius; index3 <= 0; ++index3)
                        {
                            if ((int)Math.Sqrt((double)(index2 * index2 + index3 * index3)) <= radius && (!s || (int)Math.Sqrt((double)((index2 - 1) * (index2 - 1) + index3 * index3)) > radius || (int)Math.Sqrt((double)(index2 * index2 + (index3 - 1) * (index3 - 1))) > radius))
                            {
                                int num2 = !true ? -index1 : index1;
                                if (pos == 2)
                                {
                                    subsystemTerrain.ChangeCell(Point1.Value.CellFace.Point.X + num2, Point1.Value.CellFace.Point.Y - index2, Point1.Value.CellFace.Point.Z - index3, id, true);
                                    subsystemTerrain.ChangeCell(Point1.Value.CellFace.Point.X + num2, Point1.Value.CellFace.Point.Y + index2, Point1.Value.CellFace.Point.Z - index3, id, true);
                                    subsystemTerrain.ChangeCell(Point1.Value.CellFace.Point.X + num2, Point1.Value.CellFace.Point.Y - index2, Point1.Value.CellFace.Point.Z + index3, id, true);
                                    subsystemTerrain.ChangeCell(Point1.Value.CellFace.Point.X + num2, Point1.Value.CellFace.Point.Y + index2, Point1.Value.CellFace.Point.Z + index3, id, true);
                                }
                                if (pos == 1)
                                {
                                    subsystemTerrain.ChangeCell(Point1.Value.CellFace.Point.X + index2, Point1.Value.CellFace.Point.Y + num2, Point1.Value.CellFace.Point.Z + index3, id, true);
                                    subsystemTerrain.ChangeCell(Point1.Value.CellFace.Point.X + index2, Point1.Value.CellFace.Point.Y + num2, Point1.Value.CellFace.Point.Z - index3, id, true);
                                    subsystemTerrain.ChangeCell(Point1.Value.CellFace.Point.X - index2, Point1.Value.CellFace.Point.Y + num2, Point1.Value.CellFace.Point.Z + index3, id, true);
                                    subsystemTerrain.ChangeCell(Point1.Value.CellFace.Point.X - index2, Point1.Value.CellFace.Point.Y + num2, Point1.Value.CellFace.Point.Z - index3, id, true);
                                }
                                if (pos == 3)
                                {
                                    subsystemTerrain.ChangeCell(Point1.Value.CellFace.Point.X + index2, Point1.Value.CellFace.Point.Y - index3, Point1.Value.CellFace.Point.Z + num2, id, true);
                                    subsystemTerrain.ChangeCell(Point1.Value.CellFace.Point.X + index2, Point1.Value.CellFace.Point.Y + index3, Point1.Value.CellFace.Point.Z + num2, id, true);
                                    subsystemTerrain.ChangeCell(Point1.Value.CellFace.Point.X - index2, Point1.Value.CellFace.Point.Y + index3, Point1.Value.CellFace.Point.Z + num2, id, true);
                                    subsystemTerrain.ChangeCell(Point1.Value.CellFace.Point.X - index2, Point1.Value.CellFace.Point.Y - index3, Point1.Value.CellFace.Point.Z + num2, id, true);
                                }

                                // num1 += 4;
                            }
                        }
                    }
                }
            });
        }
        /*
         *
         * public static void lingZhui(bool s, int r, int blockID, TerrainRaycastResult? Point1, SubsystemTerrain subsystemTerrain)
         * {
         *
         *  Task.Run(() =>
         *  {
         *      int num = 0;
         *      for (int index1 = -r; index1 <= r; ++index1)
         *      {
         *          for (int index2 = -r; index2 <= r; ++index2)
         *          {
         *              for (int index3 = -r; index3 <= r; ++index3)
         *              {
         *                  if (Math.Abs(index1) + Math.Abs(index2) + Math.Abs(index3) <= r && (!s || Math.Abs(index1) + Math.Abs(index2) + Math.Abs(index3) >= r))
         *                  {
         *
         *                      subsystemTerrain.ChangeCell(Point1.Value.CellFace.Point.X + index1, Point1.Value.CellFace.Point.Y + index2, Point1.Value.CellFace.Point.Z + index3, blockID, true);
         ++num;
         *
         *                  }
         *              }
         *          }
         *      }
         *      // this.player.ComponentGui.DisplaySmallMessage(string.Format("操作成功,共生成{0}个方块", (object)num), true, true);
         *  });
         * }
         */



        public static void CreativeMaze(Point3 Start, Point3 End, int BlockID, SubsystemTerrain subsystemTerrain, ComponentPlayer player)
        {
            if (Start.X < End.X)
            {
                int x = Start.X;
                Start.X = End.X;
                End.X   = x;
            }
            if (Start.Y < End.Y)
            {
                int y = Start.Y;
                Start.Y = End.Y;
                End.Y   = y;
            }
            if (Start.Z < End.Z)
            {
                int z = Start.Z;
                Start.Z = End.Z;
                End.Z   = z;
            }
            if (Start.Z - End.Z < 5 || Start.X - End.X < 5)
            {
                player.ComponentGui.DisplaySmallMessage("Too small", true, true);
            }
            else
            {
                Task.Run(() =>
                {
                    int num1          = 0;
                    int num2          = Start.X - End.X;
                    int num3          = Start.Z - End.Z;
                    bool[,] boolArray = new Maze(num2 / 2, num3 / 2).GetBoolArray();
                    for (int index1 = 0; index1 <= (num2 % 2 != 0 ? num2 - 1 : num2); ++index1)
                    {
                        for (int index2 = 0; index2 <= (num3 % 2 != 0 ? num3 - 1 : num3); ++index2)
                        {
                            if ((index1 != 1 || index2 != 0) && (index1 != (num2 % 2 != 0 ? num2 - 1 : num2) || index2 != (num3 % 2 != 0 ? num3 - 1 : num3) - 1) && boolArray[index1, index2])
                            {
                                for (int index3 = 0; index3 <= Start.Y - End.Y; ++index3)
                                {
                                    subsystemTerrain.ChangeCell(End.X + index1, End.Y + index3, End.Z + index2, BlockID, true);
                                    ++num1;
                                }
                            }
                        }
                    }
                    player.ComponentGui.DisplaySmallMessage(string.Format("Sucsses {0} place blocks", num1), true, true);
                });
            }
        }
Ejemplo n.º 4
0
        public static bool Touch(CreatorAPI creatorAPI, Point3 position)
        {
            ComponentPlayer player    = creatorAPI.componentMiner.ComponentPlayer;
            int             cellValue = GameManager.Project.FindSubsystem <SubsystemTerrain>(true).Terrain.GetCellValue(position.X, position.Y, position.Z);



/*            if (creatorAPI.twoPointsOfAttachment && creatorAPI.numberPoint == CreatorAPI.NumberPoint.Two)
 *          {
 *              Task.Run(delegate
 *              {
 *                  ChunkData chunkData = new ChunkData(creatorAPI);
 *                  creatorAPI.revokeData = new ChunkData(creatorAPI);
 *                  int num = 0;
 *                  foreach (Point3 point3 in creatorAPI.creatorGenerationAlgorithm.TwoPointLineGeneration2(creatorAPI.Position[0], creatorAPI.Position[1]))
 *                  {
 *                      creatorAPI.CreateBlock(point3, cellValue,chunkData);
 *                      num++;
 *                  }
 *                  chunkData.Render();
 *                  player.ComponentGui.DisplaySmallMessage($"操作成功,共生成{num}个方块", true, true);
 *              });
 *          }
 */

            if (creatorAPI.oneKeyGeneration)
            {
                if (creatorAPI.onekeyType == CreatorAPI.OnekeyType.Build)
                {
                    if (File.Exists(CreatorMain.OneKeyFile))
                    {
                        Task.Run(delegate
                        {
                            OnekeyGeneration.GenerationData(creatorAPI, CreatorMain.OneKeyFile, position);
                        });
                    }
                    else
                    {
                        player.ComponentGui.DisplaySmallMessage($"未发现一键生成缓存文件,目录:{CreatorMain.OneKeyFile}\n请变更一键生成类型或关闭该功能", true, true);
                    }
                }
                else
                {
                }
                return(false);
            }

            if (creatorAPI.ClearBlock)
            {
                Task.Run(delegate
                {
                    creatorAPI.revokeData = new ChunkData(creatorAPI);
                    int num = 0;
                    List <Point3> clearBlockList = new List <Point3>();
                    List <Point3> addList        = new List <Point3>();
                    clearBlockList.Add(position);
                    while (true)
                    {
                        if (clearBlockList.Count <= 0)
                        {
                            break;
                        }
                        foreach (Point3 point3 in clearBlockList)
                        {
                            if (!creatorAPI.launch)
                            {
                                return;
                            }
                            if (creatorAPI.revokeData != null && creatorAPI.revokeData.GetChunk(point3.X, point3.Z) == null)
                            {
                                creatorAPI.revokeData.CreateChunk(point3.X, point3.Z, true);
                            }
                            creatorAPI.SetBlock(point3.X, point3.Y, point3.Z, 0);
                            num++;
                            for (int x = -1; x <= 1; x++)
                            {
                                for (int y = -1; y <= 1; y++)
                                {
                                    for (int z = -1; z <= 1; z++)
                                    {
                                        if (point3.Y + y > 127)
                                        {
                                            continue;
                                        }
                                        int blockID = GameManager.Project.FindSubsystem <SubsystemTerrain>(true).Terrain.GetCellContentsFast(point3.X + x, point3.Y + y, point3.Z + z);
                                        if (blockID == 0 || blockID == 1)
                                        {
                                            continue;
                                        }
                                        if (MathUtils.Abs(x) + MathUtils.Abs(y) + MathUtils.Abs(z) > 1)
                                        {
                                            continue;
                                        }
                                        Point3 p = new Point3(point3.X + x, point3.Y + y, point3.Z + z);
                                        if (!clearBlockList.Contains(p) && !addList.Contains(p))
                                        {
                                            addList.Add(p);
                                        }
                                    }
                                }
                            }
                        }
                        clearBlockList = addList;
                        addList        = new List <Point3>();
                    }
                    player.ComponentGui.DisplaySmallMessage($"操作成功,共清除{num}个方块", true, true);
                });
                return(false);
            }
            return(true);
        }
Ejemplo n.º 5
0
        public CreatorWidget(CreatorAPI creatorAPI)
        {
            this.player     = creatorAPI.componentMiner.ComponentPlayer;;
            this.creatorAPI = creatorAPI;
            XElement node;

            if (creatorAPI.oldMainWidget)
            {
                node = ContentManager.Get <XElement>("NewWidgets/CreatorAPIWidget");
            }
            else
            {
                node = ContentManager.Get <XElement>("NewWidgets/NewCreatorAPIWidget");
            }
            WidgetsManager.LoadWidgetContents(this, this, node);
            this.worldSettings = player.Project.FindSubsystem <SubsystemGameInfo>(true).WorldSettings;

            this.SphereButton      = Children.Find <ButtonWidget>("球体");
            this.PrismButton       = Children.Find <ButtonWidget>("棱体");
            this.PyramidButton     = Children.Find <ButtonWidget>("棱锥");
            this.CylindricalButton = Children.Find <ButtonWidget>("圆柱");
            this.PrismColumnButton = Children.Find <ButtonWidget>("棱柱");
            this.PillarsButton     = Children.Find <ButtonWidget>("柱子");
            this.RectangularButton = Children.Find <ButtonWidget>("矩形");
            this.CircleButton      = Children.Find <ButtonWidget>("圆环");
            this.MazeButton        = Children.Find <ButtonWidget>("迷宫");
            this.FillingButton     = Children.Find <ButtonWidget>("填充");
            this.PavageButton      = Children.Find <ButtonWidget>("平铺");
            this.MountainButton    = Children.Find <ButtonWidget>("山脉");
            this.TransferButton    = Children.Find <ButtonWidget>("传送");
            this.LevelSetButton    = Children.Find <ButtonWidget>("等级");
            this.SetButton         = Children.Find <ButtonWidget>("设置");
            this.SpiralButton      = Children.Find <ButtonWidget>("螺旋");
            this.PenetrateButton   = Children.Find <ButtonWidget>("穿透");

            this.SetLinkButton = Children.Find <ButtonWidget>("连线");

            this.SetPositionButton = Children.Find <ButtonWidget>("设点");
            this.RevokeButton      = Children.Find <ButtonWidget>("撤回");
            this.SetSpawn          = Children.Find <ButtonWidget>("出生点");

            this.EditWorldButton  = Children.Find <ButtonWidget>("编辑世界");
            this.EditRegionButton = Children.Find <ButtonWidget>("编辑区域");
            this.ModButton        = Children.Find <ButtonWidget>("模组专用");
            this.ReplaceButton    = Children.Find <ButtonWidget>("方块替换");
            this.OnekeyButton     = Children.Find <ButtonWidget>("一键生成");
            this.CopyPasteButton  = Children.Find <ButtonWidget>("复制粘贴");
            this.ClearCacheButton = Children.Find <ButtonWidget>("清除缓存");
            this.SetModeButton    = Children.Find <ButtonWidget>("变更模式");

            this.RemoveItemButton   = Children.Find <ButtonWidget>("清除掉落");
            this.RemoveAnimalButton = Children.Find <ButtonWidget>("清除动物");
            this.ClearBlockButton   = Children.Find <ButtonWidget>("清理方块");
            this.TerrainTestButton  = Children.Find <ButtonWidget>("测试地形");

            this.SetPositionCarefulButton = this.Children.Find <ButtonWidget>("精准设点");
            this.AdjustPositionButton     = this.Children.Find <ButtonWidget>("点位调整");
            this.SetDifficultyButton      = this.Children.Find <ButtonWidget>("变更难度");
            this.ThreePointPlaneButton    = this.Children.Find <ButtonWidget>("3点成面");
            this.FourPointSpaceButton     = this.Children.Find <ButtonWidget>("4点空间");
            this.LightWorldButton         = this.Children.Find <ButtonWidget>("发光世界");
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Play a new file by file path.
        /// </summary>
        private async Task PlayNewFile(string path, bool play)
        {
            var sw = Stopwatch.StartNew();

            var             playerInst  = InstanceManage.GetInstance <PlayersInst>();
            var             dbInst      = InstanceManage.GetInstance <OsuDbInst>();
            ComponentPlayer audioPlayer = null;

            if (path == null)
            {
                return;
            }
            if (File.Exists(path))
            {
                try
                {
                    var osuFile = await OsuFile.ReadFromFileAsync(path); //50 ms

                    var fi = new FileInfo(path);
                    if (!fi.Exists)
                    {
                        throw new FileNotFoundException("Cannot locate.", fi.FullName);
                    }
                    var dir = fi.Directory.FullName;

                    /* Clear */
                    ClearHitsoundPlayer();

                    /* Set new hitsound player*/
                    playerInst.SetAudioPlayer(path, osuFile);
                    audioPlayer = playerInst.AudioPlayer;
                    SignUpPlayerEvent(audioPlayer);
                    await audioPlayer.InitializeAsync(); //700 ms

                    /* Set Meta */
                    var nowIdentity = new MapIdentity(fi.Directory.Name, osuFile.Metadata.Version);

                    MapInfo mapInfo = DbOperate.GetMapFromDb(nowIdentity);
                    Beatmap beatmap = BeatmapQuery.FilterByIdentity(nowIdentity);

                    bool isFavorite = IsMapFavorite(mapInfo); //50 ms

                    audioPlayer.HitsoundOffset = mapInfo.Offset;
                    Offset.Value = audioPlayer.HitsoundOffset;

                    var currentInfo = new CurrentInfo(
                        osuFile.Metadata.Artist,
                        osuFile.Metadata.ArtistUnicode,
                        osuFile.Metadata.Title,
                        osuFile.Metadata.TitleUnicode,
                        osuFile.Metadata.Creator,
                        osuFile.Metadata.Source,
                        osuFile.Metadata.TagList,
                        osuFile.Metadata.BeatmapId,
                        osuFile.Metadata.BeatmapSetId,
                        beatmap?.DiffSrNoneStandard ?? 0,
                        osuFile.Difficulty.HpDrainRate,
                        osuFile.Difficulty.CircleSize,
                        osuFile.Difficulty.ApproachRate,
                        osuFile.Difficulty.OverallDifficulty,
                        audioPlayer.Duration,
                        nowIdentity,
                        mapInfo,
                        beatmap,
                        isFavorite); // 20 ms
                    InstanceManage.GetInstance <PlayerList>().CurrentInfo = currentInfo;
                    ViewModel.Player.CurrentInfo = currentInfo;

                    /*start of ui*/
                    LblTitle.Content  = osuFile.Metadata.TitleMeta.ToUnicodeString();
                    LblArtist.Content = osuFile.Metadata.ArtistMeta.ToUnicodeString();
                    ((ToolTip)NotifyIcon.TrayToolTip).Content =
                        (string)LblArtist.Content + " - " + (string)LblTitle.Content;
                    /*end of ui*/

                    /* Set Lyric */
                    SetLyricSynchronously();

                    /* Set Progress */
                    PlayProgress.Maximum = audioPlayer.Duration;
                    PlayProgress.Value   = 0;

                    PlayerViewModel.Current.Duration = InstanceManage.GetInstance <PlayersInst>().AudioPlayer.Duration;

                    /* Set Storyboard */
                    if (true)
                    {
                        // Todo: Set Storyboard
                    }

                    /* Set Video */
                    bool showVideo = PlayerViewModel.Current.EnableVideo && !ViewModel.IsMiniMode;
                    if (VideoElement != null)
                    {
                        await SafelyRecreateVideoElement(showVideo);

                        if (showVideo)
                        {
                            var videoName = osuFile.Events.VideoInfo?.Filename;
                            if (videoName == null)
                            {
                                VideoElement.Source           = null;
                                VideoElementBorder.Visibility = Visibility.Hidden;
                            }
                            else
                            {
                                var vPath = Path.Combine(dir, videoName);
                                if (File.Exists(vPath))
                                {
                                    VideoElement.Source = new Uri(vPath);
                                    _videoOffset        = -(osuFile.Events.VideoInfo.Offset);
                                    if (_videoOffset >= 0)
                                    {
                                        _waitAction = () => { };
                                        _position   = TimeSpan.FromMilliseconds(_videoOffset);
                                    }
                                    else
                                    {
                                        _waitAction = () => { Thread.Sleep(TimeSpan.FromMilliseconds(-_videoOffset)); };
                                    }
                                }
                                else
                                {
                                    VideoElement.Source           = null;
                                    VideoElementBorder.Visibility = Visibility.Hidden;
                                }
                            }
                        }
                    }

                    /* Set Background */
                    if (osuFile.Events.BackgroundInfo != null)
                    {
                        var bgPath = Path.Combine(dir, osuFile.Events.BackgroundInfo.Filename);
                        BlurScene.Source = File.Exists(bgPath) ? new BitmapImage(new Uri(bgPath)) : null;
                        Thumb.Source     = File.Exists(bgPath) ? new BitmapImage(new Uri(bgPath)) : null;
                    }
                    else
                    {
                        BlurScene.Source = null;
                    }

                    /* Start Play */
                    switch (MainFrame.Content)
                    {
                    case RecentPlayPage recentPlayPage:
                        var item = recentPlayPage.DataModels.FirstOrDefault(k =>
                                                                            k.GetIdentity().Equals(nowIdentity));
                        recentPlayPage.RecentList.SelectedItem = item;
                        break;

                    case CollectionPage collectionPage:
                        collectionPage.MapList.SelectedItem =
                            collectionPage.ViewModel.Beatmaps.FirstOrDefault(k =>
                                                                             k.GetIdentity().Equals(nowIdentity));
                        break;
                    }

                    _videoPlay = play;
                    if (play)
                    {
                        if (showVideo && VideoElement?.Source != null)
                        {
                            // use event to control here.
                            //VideoPlay();
                            //App.HitsoundPlayer.Play();
                        }
                        else
                        {
                            audioPlayer.Play();
                        }
                    }

                    //if (!App.PlayerList.Entries.Any(k => k.GetIdentity().Equals(nowIdentity)))
                    //    App.PlayerList.Entries.Add(entry);
                    PlayerConfig.Current.CurrentPath = path;
                    PlayerConfig.SaveCurrent();

                    DbOperate.UpdateMap(nowIdentity);
                }
                catch (Exception ex)
                {
                    var result = MsgBox.Show(this, @"发生未处理的异常问题:" + (ex.InnerException ?? ex), Title,
                                             MessageBoxButton.OK, MessageBoxImage.Error);
                    if (result == MessageBoxResult.OK)
                    {
                        if (audioPlayer == null)
                        {
                            return;
                        }
                        if (audioPlayer.PlayerStatus != PlayerStatus.Playing)
                        {
                            await PlayNextAsync(false, true);
                        }
                    }

                    Console.WriteLine(ex);
                }
            }
            else
            {
                MsgBox.Show(this, @"所选文件不存在,可能是db没有及时更新。请关闭此播放器或osu后重试。",
                            Title, MessageBoxButton.OK, MessageBoxImage.Warning);
            }

            sw.Stop();
            Console.WriteLine(sw.ElapsedMilliseconds);
        }
Ejemplo n.º 7
0
 public void SetAudioPlayer(string filePath, OsuFile osuFile)
 {
     AudioPlayer = new ComponentPlayer(filePath, osuFile);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// 粘贴
        /// </summary>
        /// <param name="creatorAPI"></param>
        /// <param name="path"></param>
        /// <param name="Start"></param>
        /// <param name="End"></param>
        /// <param name="type"></param>
        public static void PasetData(CreatorAPI creatorAPI, string path, Point3 Start, Point3 End)
        {
            ChunkData chunkData = new ChunkData(creatorAPI);

            creatorAPI.revokeData = new ChunkData(creatorAPI);
            ComponentPlayer    player       = creatorAPI.componentMiner.ComponentPlayer;
            Stream             fileStream   = new FileStream(path, FileMode.Open).CreateStream();
            EngineBinaryReader binaryReader = new EngineBinaryReader(fileStream, false);
            int count = 0;
            int MaxX  = binaryReader.ReadInt32();
            int MaxY  = binaryReader.ReadInt32();
            int MaxZ  = binaryReader.ReadInt32();

            for (int PositionX = 0; PositionX <= MaxX; PositionX++)
            {
                for (int PositionY = 0; PositionY <= MaxY; PositionY++)
                {
                    for (int PositionZ = 0; PositionZ <= MaxZ; PositionZ++)
                    {
                        if (!creatorAPI.launch)
                        {
                            return;
                        }
                        int x, y, z;
                        int id = binaryReader.ReadInt32();
                        if (!creatorAPI.AirIdentify && Terrain.ExtractContents(id) == 0)
                        {
                            continue;
                        }
                        y = Start.Y + PositionY;
                        if (Start.X <= End.X && Start.Z <= End.Z)
                        {
                            x = Start.X + PositionX;
                            z = Start.Z + PositionZ;
                            if (creatorAPI.pasteLimit && (End.X < x || End.Z < z))
                            {
                                continue;
                            }
                            creatorAPI.CreateBlock(x, y, z, id, chunkData);
                        }
                        else if (Start.X >= End.X && Start.Z <= End.Z)
                        {
                            if (!creatorAPI.pasteRotate)
                            {
                                x = Start.X - MaxX + PositionX;
                                z = Start.Z + PositionZ;
                                if (creatorAPI.pasteLimit && (Start.X > x + Start.X - End.X || End.Z < z))
                                {
                                    continue;
                                }
                                creatorAPI.CreateBlock(x, y, z, id, chunkData);
                            }
                            else
                            {
                                int _x = Start.X - PositionZ;
                                int _z = Start.Z + PositionX;
                                if (creatorAPI.pasteLimit && (Start.X > _x + Start.X - End.X || End.Z < _z))
                                {
                                    continue;
                                }
                                creatorAPI.CreateBlock(_x, y, _z, id, chunkData);
                            }
                        }
                        else if (Start.X >= End.X && Start.Z >= End.Z)
                        {
                            if (!creatorAPI.pasteRotate)
                            {
                                x = Start.X - MaxX + PositionX;
                                z = Start.Z - MaxZ + PositionZ;
                                if (creatorAPI.pasteLimit && (Start.X > x + Start.X - End.X || Start.Z > z + Start.Z - End.Z))
                                {
                                    continue;
                                }
                                creatorAPI.CreateBlock(x, y, z, id, chunkData);
                            }
                            else
                            {
                                int _x = Start.X - PositionX;
                                int _z = Start.Z - PositionZ;
                                if (creatorAPI.pasteLimit && (Start.X > _x + Start.X - End.X || Start.Z > _z + Start.Z - End.Z))
                                {
                                    continue;
                                }
                                creatorAPI.CreateBlock(_x, y, _z, id, chunkData);
                            }
                        }
                        else if (Start.X <= End.X && Start.Z >= End.Z)
                        {
                            if (!creatorAPI.pasteRotate)
                            {
                                x = Start.X + PositionX;
                                z = Start.Z - MaxZ + PositionZ;
                                if (creatorAPI.pasteLimit && (End.X < x || Start.Z > z + Start.Z - End.Z))
                                {
                                    continue;
                                }
                                creatorAPI.CreateBlock(x, y, z, id, chunkData);
                            }
                            else
                            {
                                int _x = Start.X + PositionZ;
                                int _z = Start.Z - PositionX;
                                if (creatorAPI.pasteLimit && (End.X < _x || Start.Z > _z + Start.Z - End.Z))
                                {
                                    continue;
                                }
                                creatorAPI.CreateBlock(_x, y, _z, id, chunkData);
                            }
                        }
                        count++;
                    }
                }
            }
            binaryReader.Dispose();
            fileStream.Dispose();
            chunkData.Render();
            creatorAPI.componentMiner.ComponentPlayer.ComponentGui.DisplaySmallMessage($"粘贴成功,共{count}个方块", true, true);
        }
Ejemplo n.º 9
0
 public InterfaceDialog(CreatorAPI creatorAPI)
 {
     this.creatorAPI       = creatorAPI;
     this.player           = creatorAPI.componentMiner.ComponentPlayer;
     this.subsystemTerrain = player.Project.FindSubsystem <SubsystemTerrain>(true);
 }
Ejemplo n.º 10
0
        public Square(ComponentPlayer player, int id, TerrainRaycastResult?Point1, SubsystemTerrain subsystemTerrain)
        {
            m_subsystemTerrain = subsystemTerrain;
            Point       = Point1;
            id1         = id;
            this.player = player;
            WidgetsManager.LoadWidgetContents(this, this, ContentManager.Get <XElement>("WE/DialogsWE/SquareDialog"));

            m_title = this.Children.Find <LabelWidget>("Square_Dialog.Title", true);

            Mode      = this.Children.Find <LabelWidget>("Square_Dialog.Mode", true);
            mPosition = this.Children.Find <LabelWidget>("Square_Dialog.Pos", true);

            Icon_select = this.Children.Find <ButtonWidget>("Square_Dialog.Icon_select", true);

            mselect_pos = this.Children.Find <ButtonWidget>("Square_Dialog.Select_pos", true);

            m_radius = this.Children.Find <SliderWidget>("Square_Dialog.Slider1", true);
            m_lenght = this.Children.Find <SliderWidget>("Square_Dialog.Slider2", true);

            plusButton  = this.Children.Find <ButtonWidget>("Square_Dialog.Button4", true);
            minusButton = this.Children.Find <ButtonWidget>("Square_Dialog.Button3", true);

            lenght_plusButton  = this.Children.Find <ButtonWidget>("Square_Dialog.Button2", true);
            lenght_minusButton = this.Children.Find <ButtonWidget>("Square_Dialog.Button1", true);



            mSelect_mode = this.Children.Find <ButtonWidget>("Square_Dialog.Select_mode", true);

            m_okButton     = this.Children.Find <ButtonWidget>("Square_Dialog.OK", true);
            m_cancelButton = this.Children.Find <ButtonWidget>("Square_Dialog.Cancel", true);

            this.m_blockIconWidget = this.Children.Find <BlockIconWidget>("Square_Dialog.Icon", true);


            m_title.Text = "Square";

            //switch_mode.Text = "Holow";

            //m_blockIconWidget.Value

            mPosition.Text = "Flat";
            Mode.Text      = "Hollow";


            m_radius.MinValue = 1f;
            m_radius.MaxValue = 100;
            m_radius.Value    = 1f;

            m_lenght.MinValue = 1f;
            m_lenght.MaxValue = 100;
            m_lenght.Value    = 1f;

            m_blockIconWidget.Value = id;

            names.Add("Soild");
            names.Add("Hollow");

            names_pos.Add("Flat");
            names_pos.Add("Pos_X");
            names_pos.Add("Pos_Y");


            foreach (string category in names)
            {
                m_categories.Add(new Category()
                {
                    Name = category,
                });
            }

            foreach (string category in names_pos)
            {
                m_categories_pos.Add(new Category()
                {
                    Name = category,
                });
            }
        }
Ejemplo n.º 11
0
        public static bool TryGetComponentPlayer(this int entity, out ComponentPlayer component)
        {
            component = Storage <ComponentPlayer> .Instance.TryGet(entity);

            return(component != null);
        }
        public override bool OnEditInventoryItem(IInventory inventory, int slotIndex, ComponentPlayer componentPlayer)
        {
            int value = inventory.GetSlotValue(slotIndex);
            int count = inventory.GetSlotCount(slotIndex);
            int data  = Terrain.ExtractData(value);
            int delay = AdjustableDelayGateBlock.GetDelay(data);

            DialogsManager.ShowDialog(componentPlayer.GuiWidget, new EditAdjustableDelayGateDialog(delay, delegate(int newDelay)
            {
                int data2 = AdjustableDelayGateBlock.SetDelay(data, newDelay);
                int num   = Terrain.ReplaceData(value, data2);
                if (num != value)
                {
                    inventory.RemoveSlotItems(slotIndex, count);
                    inventory.AddSlotItems(slotIndex, num, 1);
                }
            }));
            return(true);
        }
Ejemplo n.º 13
0
    void DistributeKills(uLink.NetworkPlayer victim, uLink.NetworkPlayer killer, E_BodyPart bodyPart)
    {
        ComponentPlayer p = Player.GetPlayer(victim);

        float left = p.Owner.BlackBoard.RealMaxHealth;

        Dictionary <uLink.NetworkPlayer, float> killers = new Dictionary <uLink.NetworkPlayer, float>();

        foreach (BlackBoard.DamageData data in p.Owner.BlackBoard.AttackersDamageData)
        {
            float damage = Mathf.Min(left, data.Damage);

            if (Player.GetPlayer(data.Attacker) == null)            //player is fadeout , f**k him.. or it cause crash in hud on client
            {
                continue;
            }

            if (killers.ContainsKey(data.Attacker))
            {
                killers[data.Attacker] += damage;
            }
            else
            {
                killers.Add(data.Attacker, damage);
            }

            left -= damage;

            if (left <= 0)
            {
                break;
            }
        }


        //PlayerPersistantInfo victimPPI  = PPIManager.Instance.GetPPI(victim);


        foreach (KeyValuePair <uLink.NetworkPlayer, float> pair in killers)
        {
            PlayerPersistantInfo killerPPI = PPIManager.Instance.GetPPI(pair.Key);

            if (killerPPI == null)
            {
                continue;                 // one of the killers could disconnect
            }
            float percent = pair.Value / p.Owner.BlackBoard.RealMaxHealth;

            if (pair.Key == killer)
            {
                percent = 1.0f;
            }
            else if (percent < 0.1f)
            {
                percent = 0.1f;
            }
            else if (percent > 0.6f)
            {
                percent = 0.6f;
            }



            int score = Mathf.FloorToInt(GameplayRewards.Kill * percent);


            if (killer == pair.Key)
            {
                Server.Instance.ShowCombatMsgOnClient(killerPPI.Player, Client.E_MessageType.Kill, (short)score, (short)(score * GameplayRewards.MoneyModificator));

                if (bodyPart == E_BodyPart.Head)
                {
                    Server.Instance.ShowCombatMsgOnClient(killerPPI.Player, Client.E_MessageType.HeadShot, GameplayRewards.HeadShot, (short)(GameplayRewards.HeadShot * GameplayRewards.MoneyModificator));
                    score += GameplayRewards.HeadShot;
                }
            }
            else
            {
                Server.Instance.ShowCombatMsgOnClient(killerPPI.Player, Client.E_MessageType.KillAssist, (short)score, (short)(score * GameplayRewards.MoneyModificator));
            }


            killerPPI.AddScore(score);

            if (Server.Instance.GameInfo.GameType == E_MPGameType.DeathMatch)
            {
                killerPPI.AddExperience(score, E_AddMoneyAction.KillDM);
            }
            else
            {
                killerPPI.AddExperience(score, E_AddMoneyAction.KillZC);
            }

            SynchronizeScore(killerPPI);
        }
    }
Ejemplo n.º 14
0
 public override bool OnUse(Vector3 start, Vector3 direction, ComponentMiner componentMiner)
 {
     componentPlayer = componentMiner.ComponentPlayer;
     return(base.OnUse(start, direction, componentMiner));
 }
        public static void Coppy_zone(string path, Point3 Point1, Point3 Point2, SubsystemTerrain subsystemTerrain, ComponentPlayer player)
        {
            int startX = Math.Min(Point1.X, Point2.X);
            int endX   = Math.Max(Point1.X, Point2.X);
            int startY = Math.Min(Point1.Y, Point2.Y);
            int endY   = Math.Max(Point1.Y, Point2.Y);
            int startZ = Math.Min(Point1.Z, Point2.Z);
            int endZ   = Math.Max(Point1.Z, Point2.Z);

            FileStream         fileStream         = new FileStream(path, FileMode.Create);
            EngineBinaryWriter engineBinaryWriter = new EngineBinaryWriter((Stream)fileStream, true);

            engineBinaryWriter.Write((byte)79);
            engineBinaryWriter.Write((byte)110);
            engineBinaryWriter.Write((byte)101);
            engineBinaryWriter.Write((byte)75);
            engineBinaryWriter.Write((byte)101);
            engineBinaryWriter.Write((byte)121);
            engineBinaryWriter.Write((byte)0);
            engineBinaryWriter.Write(0);


            blockCount = 0;
            BlockList.Clear();

            for (int x = 0; x <= endX - startX; x++)
            {
                for (int y = 0; y <= endY - startY; y++)
                {
                    for (int z = 0; z <= endZ - startZ; z++)
                    {
                        BlockMem blmem = new BlockMem();
                        int      X, Y, Z;
                        if (Point1.X > Point2.X)
                        {
                            blmem.x = -x;
                            X       = Point1.X - x;
                        }
                        else
                        {
                            blmem.x = x;
                            X       = Point1.X + x;
                        }

                        if (Point1.Y > Point2.Y)
                        {
                            blmem.y = -y;
                            Y       = Point1.Y - y;
                        }
                        else
                        {
                            blmem.y = y;
                            Y       = Point1.Y + y;
                        }

                        if (Point1.Z > Point2.Z)
                        {
                            blmem.z = -z;
                            Z       = Point1.Z - z;
                        }
                        else
                        {
                            blmem.z = z;
                            Z       = Point1.Z + z;
                        }
                        blmem.id = subsystemTerrain.Terrain.GetCellValueFast(X, Y, Z);


                        engineBinaryWriter.Write(blmem.x);
                        engineBinaryWriter.Write(blmem.y);
                        engineBinaryWriter.Write(blmem.z);
                        engineBinaryWriter.Write(blmem.id);

                        ++blockCount;


                        BlockList.Add(blmem);
                        blockCount++;
                    }
                }
            }
            player.ComponentGui.DisplaySmallMessage(string.Format("Sucsses {0} place blocks", blockCount), true, true);
            engineBinaryWriter.BaseStream.Position = 7L;
            engineBinaryWriter.Write(blockCount);
            engineBinaryWriter.Dispose();
            fileStream.Dispose();
        }
Ejemplo n.º 16
0
        public Img(ComponentPlayer player, string path, TerrainRaycastResult?Point1, SubsystemTerrain subsystemTerrain)
        {
            path_img = path;



            Point = new Point3(Point1.Value.CellFace.Point.X, Point1.Value.CellFace.Point.Y, Point1.Value.CellFace.Point.Z);
            m_subsystemTerrain = subsystemTerrain;


            this.player = player;
            WidgetsManager.LoadWidgetContents(this, this, ContentManager.Get <XElement>("WE/DialogsWE/ImgDialog"));
            // WidgetsManager.LoadWidgetContents(this, this, XElement.Load(@"D:\Games\WSC\Content\WE\DialogsWE\ImgDialog.xml"));

            m_okButton     = this.Children.Find <ButtonWidget>("Img_Dialog.OK", true);
            m_cancelButton = this.Children.Find <ButtonWidget>("Img_Dialog.Cancel", true);


            m_type_creatingButton = this.Children.Find <ButtonWidget>("Img_Dialog.type_cr_btn", true);
            m_type_creatingLabel  = this.Children.Find <LabelWidget>("Img_Dialog.type_cr_text", true);

            m_resizeSlider = this.Children.Find <SliderWidget>("Img_Dialog.resize_sl", true);
            m_furniture_resolutionSlider = this.Children.Find <SliderWidget>("Img_Dialog.furn_res_sl", true);
            m_deep_colorSlider           = this.Children.Find <SliderWidget>("Img_Dialog.Slider_deep", true);
            m_color_ofsetSlider          = this.Children.Find <SliderWidget>("Img_Dialog.ofst_sl", true);

            m_posButton = this.Children.Find <ButtonWidget>("Img_Dialog.pos_sel", true);
            m_rotButton = this.Children.Find <ButtonWidget>("Img_Dialog.rot_sel", true);

            m_posLabel = this.Children.Find <LabelWidget>("Img_Dialog.pos_txt", true);
            m_rotLabel = this.Children.Find <LabelWidget>("Img_Dialog.rot_txt", true);


            m_colors_useBox = this.Children.Find <CheckboxWidget>("Img_Dialog.Line0", true);
            m_color_saveBox = this.Children.Find <CheckboxWidget>("Img_Dialog.Line1", true);
            m_mirrorBox     = this.Children.Find <CheckboxWidget>("Img_Dialog.mirror", true);

            m_resizeSlider.MinValue = 1f;
            m_resizeSlider.MaxValue = 8f;

            m_furniture_resolutionSlider.MinValue = 2f;
            m_furniture_resolutionSlider.MaxValue = 16f;


            m_color_ofsetSlider.MinValue = 0f;
            m_color_ofsetSlider.MaxValue = 8f;


            m_deep_colorSlider.MinValue = 2f;
            m_deep_colorSlider.MaxValue = 16f;



            t_c_txt = "Furniture";


            m_colors_useBox.IsChecked = false;
            m_color_saveBox.IsChecked = false;

            m_resizeSlider.Value = 2;
            m_furniture_resolutionSlider.Value = 16;
            m_deep_colorSlider.Value           = 16;



            pos_txt = "Horizontally";
            rot_txt = "Front";
        }
        public static void Paste_zone(Point3 Point3, SubsystemTerrain subsystemTerrain, ComponentPlayer player, string path)
        {
            FileStream fileStream = new FileStream(path, FileMode.Open);

            BinaryReader engineBinaryReader = new BinaryReader(fileStream);



            engineBinaryReader.BaseStream.Position = 7L;

            int num2 = engineBinaryReader.ReadInt32();

            try
            {
                for (var i = 0; i < num2; i++)
                {
                    var xPos = Point3.X + engineBinaryReader.ReadInt32();
                    var yPos = Point3.Y + engineBinaryReader.ReadInt32();
                    var zPos = Point3.Z + engineBinaryReader.ReadInt32();
                    var id   = engineBinaryReader.ReadInt32();

                    subsystemTerrain.ChangeCell(xPos, yPos, zPos, id);
                }
            }
            catch (Exception ex)
            {
                player.ComponentGui.DisplaySmallMessage(string.Format("Sucsses {0} place blocks", num2), true, true);
            }

            engineBinaryReader.Dispose();
            fileStream.Dispose();
        }
Ejemplo n.º 18
0
        public override bool OnEditInventoryItem(IInventory inventory, int slotIndex, ComponentPlayer Player)
        {
/*            Run();*/
            if (Player.ComponentGui.ModalPanelWidget is CreatorWidget)
            {
                Player.ComponentGui.ModalPanelWidget = null;
            }
            else
            {
                CreatorAPI creatorAPI;
                if (!dictionaryPlayers.TryGetValue(Player, out creatorAPI))
                {
                    listPlayer.Add(Player);
                    creatorAPI = new CreatorAPI(Player.ComponentMiner);
                    dictionaryPlayers.Add(Player, creatorAPI);
                }
                if (CreatorMain.canUse)
                {
                    Player.ComponentGui.ModalPanelWidget = new CreatorWidget(creatorAPI);
                }
                else
                {
                    DialogsManager.ShowDialog(Player.View.GameWidget, new PasswordDialog(Player));
                }
            }
            return(true);
        }
Ejemplo n.º 19
0
 void OnTriggerEnter(Collider other)
 {
     ComponentPlayer player = other.GetComponent <ComponentPlayer>();
     //if(player)
     //    player.Teleport(this);
 }
Ejemplo n.º 20
0
        public ApplicationLoopEditor(DirectoryInfo aDirectoryInfoInput, DirectoryInfo aDirectoryInfoOutput)
        {
            player = new PlayerNull();
            directoryInfoRecentInputList  = new List <DirectoryInfo>();
            directoryInfoRecentOutputList = new List <DirectoryInfo>();
            tooltipPrevious = "";

            try
            {
                using (StreamReader u = new StreamReader(Application.streamingAssetsPath + "/Config/LoopToolInput.ini"))
                {
                    for (string line = u.ReadLine(); line != null; line = u.ReadLine())
                    {
                        if (Directory.Exists(line) == true)
                        {
                            directoryInfoRecentInputList.Add(new DirectoryInfo(line));

                            if (directoryInfoRecentInputList.Count >= 5)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception aExpection)
            {
                Logger.BreakDebug("Exception:" + aExpection);

                using (StreamWriter u = new StreamWriter(Application.streamingAssetsPath + "/Config/LoopToolInput.ini"))
                {
                    Logger.BreakDebug("Create LoopToolInput.ini");
                }
            }

            try
            {
                using (StreamReader u = new StreamReader(Application.streamingAssetsPath + "/Config/LoopToolOutput.ini"))
                {
                    for (string line = u.ReadLine(); line != null; line = u.ReadLine())
                    {
                        if (Directory.Exists(line) == true)
                        {
                            directoryInfoRecentOutputList.Add(new DirectoryInfo(line));

                            if (directoryInfoRecentOutputList.Count >= 5)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception aExpection)
            {
                using (StreamWriter u = new StreamWriter(Application.streamingAssetsPath + "/Config/LoopToolOutput.ini"))
                {
                    Logger.BreakDebug("Exception:" + aExpection);
                    Logger.BreakDebug("Create LoopToolOutput.ini");
                }
            }

            if (directoryInfoRecentInputList.Count == 0)
            {
                directoryInfoRecentInputList.Add(aDirectoryInfoInput);
            }

            if (directoryInfoRecentOutputList.Count == 0)
            {
                directoryInfoRecentOutputList.Add(aDirectoryInfoOutput);
            }

            mode = Mode.Search;
            menu = new MenuBar(Application.streamingAssetsPath + "/Language/LoopTool/Menu/MenuBar.language", this);
            componentLoopPlayer         = new ComponentPlayer(ChangeMusicPrevious, ChangeMusicNext);
            componentLoopEditor         = new ComponentLoopEditor(ChangeMusicPrevious, ChangeMusicNext);
            componentLoopSelector       = new ComponentLoopSelector(componentLoopEditor);
            componentDirectoryBarInput  = new ComponentDirectoryBar(SetInput, directoryInfoRecentInputList);
            componentDirectoryBarOutput = new ComponentDirectoryBar(SetOutput, directoryInfoRecentOutputList);

            componentInputlist = new ComponentInputlist(directoryInfoRecentInputList[0], PlayMusic, GetPlayingMusic);
            componentPlaylist  = new ComponentPlaylist(directoryInfoRecentOutputList[0], PlayMusic, GetPlayingMusic);

            componentLoopSearch = new ComponentLoopSearch(componentInputlist, componentPlaylist);
            componentLoopSave   = new ComponentLoopSave(componentPlaylist);

            SetInput(directoryInfoRecentInputList[0]);
            SetOutput(directoryInfoRecentOutputList[0]);
        }
Ejemplo n.º 21
0
 public void ClearAudioPlayer()
 {
     AudioPlayer?.Stop();
     AudioPlayer?.Dispose();
     AudioPlayer = null;
 }
        // public static readonly string sdcard = "/sdcard/Survivalcraft/WorldEdit";

        // public readonly string oneKeyFile =
        // public readonly string CopyFile = string.Format("{0}/Cache/Cache.w", (object));



        public static void draw_img(bool mirror, int ofset_paletr, bool save_colors, bool use_castom_paletr, int deep_color, bool on_furn, int size, int furn_resol, bool pos, bool rotate, string pa, Point3 start, SubsystemTerrain subsystemTerrain, ComponentPlayer p)
        {
            Task.Run(() =>
            {
                try
                {
                    System.Drawing.Bitmap im = null;
                    try
                    {
                        im = (System.Drawing.Bitmap)System.Drawing.Image.FromFile(pa);
                    }
                    catch (Exception ex)
                    {
                        p.ComponentGui.DisplaySmallMessage(string.Format("Error read image"), true, true);

                        return;
                    }



                    if (!on_furn)
                    {
                        furn_resol = 1;
                    }



                    if (!mirror)
                    {
                        im.RotateFlip(System.Drawing.RotateFlipType.RotateNoneFlipX);
                    }



                    if (pos)
                    {
                        im.RotateFlip(System.Drawing.RotateFlipType.Rotate90FlipNone);
                    }



                    im = (new System.Drawing.Bitmap(im, new System.Drawing.Size(im.Width / size, im.Height / size)));



                    var num1 = 0;
                    for (var index = 0; index < 1024; ++index)
                    {
                        if (subsystemTerrain.SubsystemFurnitureBlockBehavior.GetDesign(index) != null)
                        {
                            ++num1;
                        }
                    }
                    num1  = 1024 - num1;
                    var a = (im.Width / furn_resol) * (im.Height / furn_resol);

                    if (on_furn && a > num1)
                    {
                        p.ComponentGui.DisplaySmallMessage(string.Format("Not enough furniture blocks (" + num1.ToString() + "/" + a.ToString() + ")"), true, true);

                        return;
                    }



                    Image img = new Image(im.Width, im.Height);

                    for (int x = 0; x < im.Width; x++)
                    {
                        for (int y = 0; y < im.Height; y++)
                        {
                            img.SetPixel(x, y, new Color(im.GetPixel(x, y).R, im.GetPixel(x, y).G, im.GetPixel(x, y).B, im.GetPixel(x, y).A));
                        }
                    }


                    if (use_castom_paletr)
                    {
                        top_colors(ofset_paletr, save_colors, deep_color, img, subsystemTerrain.SubsystemPalette);
                    }


                    List <int> fur_bl_img = new List <int>();
                    for (int x = 0; x < img.Width / furn_resol; x++)
                    {
                        for (int y = 0; y < img.Height / furn_resol; y++)
                        {
                            if (on_furn)
                            {
                                List <int> bl_img = new List <int>();
                                bool is_a_bl      = false;
                                for (int x1 = 0; x1 < furn_resol; x1++)
                                {
                                    for (int y1 = 0; y1 < furn_resol; y1++)
                                    {
                                        if (get_block_id(GetClosestColor(subsystemTerrain.SubsystemPalette.m_colors, img.GetPixel((x * furn_resol) + x1, (y * furn_resol) + y1)), subsystemTerrain.SubsystemPalette) != 0 && is_a_bl == false)
                                        {
                                            is_a_bl = true;
                                        }
                                        bl_img.Add(get_block_id(GetClosestColor(subsystemTerrain.SubsystemPalette.m_colors, img.GetPixel((x * furn_resol) + x1, (y * furn_resol) + y1)), subsystemTerrain.SubsystemPalette));
                                    }
                                }
                                if (is_a_bl)
                                {
                                    int img_id = create_dsg(rotate, pos, furn_resol, bl_img, subsystemTerrain, ("x " + x.ToString() + "  " + "y " + y.ToString()).ToString());
                                    if (pos)
                                    {
                                        if (rotate)
                                        {
                                            subsystemTerrain.ChangeCell(start.X, start.Y + x, start.Z + y, img_id);
                                        }
                                        else
                                        {
                                            subsystemTerrain.ChangeCell(start.X + y, start.Y + x, start.Z, img_id);
                                        }
                                    }
                                    else
                                    {
                                        subsystemTerrain.ChangeCell(start.X + y, start.Y, start.Z + x, img_id);
                                    }
                                }
                            }
                            else
                            {
                                int img_id = get_block_id(GetClosestColor(subsystemTerrain.SubsystemPalette.m_colors, img.GetPixel(x, y)), subsystemTerrain.SubsystemPalette);
                                if (pos)
                                {
                                    if (rotate)
                                    {
                                        subsystemTerrain.ChangeCell(start.X, start.Y + x, start.Z + y, img_id);
                                    }
                                    else
                                    {
                                        subsystemTerrain.ChangeCell(start.X + y, start.Y + x, start.Z, img_id);
                                    }
                                }
                                else
                                {
                                    subsystemTerrain.ChangeCell(start.X + y, start.Y, start.Z + x, img_id);
                                }
                            }
                        }
                    }

                    p.ComponentGui.DisplaySmallMessage(string.Format("Success " + a + " blocks"), true, true);

                    AnalyticsManager.LogEvent("WE image sucsees", new AnalyticsParameter("blocks", a.ToString()));
                }catch (Exception ex)
                {
                    p.ComponentGui.DisplaySmallMessage(string.Format("Failed cause: " + ex.Message), true, true);
                    AnalyticsManager.LogError("WE image fail", ex);
                }
            });
        }
        public Rectangle(ComponentPlayer player, int id, TerrainRaycastResult?Point1, TerrainRaycastResult?Point2, SubsystemTerrain subsystemTerrain)
        {
            m_subsystemTerrain = subsystemTerrain;
            Point       = Point1;
            this.Point2 = Point2;
            id1         = id;
            this.player = player;
            WidgetsManager.LoadWidgetContents(this, this, ContentManager.Get <XElement>("WE/DialogsWE/PillarDialog"));

            m_title = this.Children.Find <LabelWidget>("Pillar_Dialog.Title", true);

            mPosition = this.Children.Find <LabelWidget>("Pillar_Dialog.Pos", true);

            Icon_select = this.Children.Find <ButtonWidget>("Pillar_Dialog.Icon_select", true);

            mselect_pos = this.Children.Find <ButtonWidget>("Pillar_Dialog.Select_pos", true);



            m_okButton     = this.Children.Find <ButtonWidget>("Pillar_Dialog.OK", true);
            m_cancelButton = this.Children.Find <ButtonWidget>("Pillar_Dialog.Cancel", true);

            this.m_blockIconWidget = this.Children.Find <BlockIconWidget>("Pillar_Dialog.Icon", true);


            m_title.Text = "Frame or box";

            //switch_mode.Text = "Holow";

            //m_blockIconWidget.Value

            mPosition.Text = "Frame";



            m_blockIconWidget.Value = id;

            names.Add("Soild");
            names.Add("Hollow");

            names_pos.Add("Frame");
            names_pos.Add("Hollow Box");
            names_pos.Add("Soild Box");



            foreach (string category in names)
            {
                m_categories.Add(new Category()
                {
                    Name = category,
                });
            }

            foreach (string category in names_pos)
            {
                m_categories_pos.Add(new Category()
                {
                    Name = category,
                });
            }
        }
Ejemplo n.º 24
0
        public override bool OnEditInventoryItem(IInventory inventory, int slotIndex, ComponentPlayer componentPlayer)
        {
            int value        = inventory.GetSlotValue(slotIndex);
            int count        = inventory.GetSlotCount(slotIndex);
            int data         = Terrain.ExtractData(value);
            int voltageLevel = BatteryBlock.GetVoltageLevel(data);

            DialogsManager.ShowDialog(componentPlayer.GuiWidget, new EditBatteryDialog(voltageLevel, delegate(int newVoltageLevel)
            {
                int data2 = BatteryBlock.SetVoltageLevel(data, newVoltageLevel);
                int num   = Terrain.ReplaceData(value, data2);
                if (num != value)
                {
                    inventory.RemoveSlotItems(slotIndex, count);
                    inventory.AddSlotItems(slotIndex, num, 1);
                }
            }));
            return(true);
        }