private void OnPlayerJoin(IPlayer player)
        {
            fromPlayer = player as IServerPlayer;

            WorldEditWorkspace workspace = GetOrCreateWorkSpace(player);

            IBlockAccessorRevertable revertableBlockAccess = sapi.World.GetBlockAccessorRevertable(true, true);

            // Initialize all tools once to build up the workspace for the client gui tool options
            foreach (var val in ToolRegistry.ToolTypes)
            {
                ToolRegistry.InstanceFromType(val.Key, workspace, revertableBlockAccess);
            }


            if (workspace.ToolsEnabled)
            {
                if (workspace.ToolInstance != null)
                {
                    EnumHighlightBlocksMode mode = EnumHighlightBlocksMode.CenteredToSelectedBlock;
                    if (workspace.ToolOffsetMode == EnumToolOffsetMode.Attach)
                    {
                        mode = EnumHighlightBlocksMode.AttachedToSelectedBlock;
                    }

                    sapi.World.HighlightBlocks(player, (int)EnumHighlightSlot.Brush, workspace.ToolInstance.GetBlockHighlights(this), workspace.ToolInstance.GetBlockHighlightColors(this), mode);
                }
            }
            else
            {
                workspace.HighlightSelectedArea();
            }
        }
Exemple #2
0
 public void SetTool(string toolname)
 {
     this.ToolName = toolname;
     ToolInstance  = ToolRegistry.InstanceFromType(toolname, this, revertableBlockAccess);
 }
 public override void StartPre(ICoreAPI api)
 {
     ToolRegistry.RegisterDefaultTools();
 }
 public void RegisterTool(string toolname, Type tool)
 {
     ToolRegistry.RegisterToolType(toolname, tool);
 }