コード例 #1
0
        public override InteractResult OnActRight(InteractionContext context)
        {
            try
            {
                if (context.BlockPosition == null || !context.BlockPosition.HasValue)
                {
                    return(InteractResult.Success);
                }

                Vector3i pos = context.BlockPosition.Value;

                pos.X = pos.X < 0 ? pos.X + Shared.Voxel.World.VoxelSize.X : pos.X;
                pos.Z = pos.Z < 0 ? pos.Z + Shared.Voxel.World.VoxelSize.Z : pos.Z;

                pos.X = pos.X % Shared.Voxel.World.VoxelSize.X;
                pos.Z = pos.Z % Shared.Voxel.World.VoxelSize.Z;

                UserSession userSession = WorldEditManager.GetUserSession(context.Player.User);
                userSession.SetSecondPosition(pos);

                context.Player.MsgLoc($"Second Position set to ({pos.x}, {pos.y}, {pos.z})");
            }
            catch (Exception e)
            {
                Log.WriteError(Localizer.Do($"{e}"));
            }
            return(InteractResult.NoOp);
        }
コード例 #2
0
        public static void Selclaim(User user)
        {
            try
            {
                Vector3i    pos      = user.Position.Round;
                Vector2i    claimPos = PlotUtil.NearestPlotPosInWorld(pos.XZ);
                UserSession session  = WorldEditManager.GetUserSession(user);

                session.SetFirstPosition(claimPos.X_Z(pos.Y - 1));
                session.SetSecondPosition(WorldEditUtils.SecondPlotPos(claimPos).X_Z(pos.Y - 1));

                user.Player.MsgLoc($"First Position set to {session.Selection.min}");
                user.Player.MsgLoc($"Second Position set to {session.Selection.max}");
            }
            catch (Exception e)
            {
                Log.WriteError(Localizer.Do($"{e}"));
            }
        }
コード例 #3
0
        public static void SetPos2(User user)
        {
            try
            {
                Vector3 pos = user.Position;
                pos.X = pos.X < 0 ? pos.X + Shared.Voxel.World.VoxelSize.X : pos.X;
                pos.Z = pos.Z < 0 ? pos.Z + Shared.Voxel.World.VoxelSize.Z : pos.Z;
                pos.X = pos.X % Shared.Voxel.World.VoxelSize.X;
                pos.Z = pos.Z % Shared.Voxel.World.VoxelSize.Z;

                UserSession session = WorldEditManager.GetUserSession(user);
                session.SetSecondPosition(pos.Round);

                user.Player.MsgLoc($"Second Position set to {pos}");
            }
            catch (Exception e)
            {
                Log.WriteError(Localizer.Do($"{e}"));
            }
        }