本文整理汇总了C#中fCraft.Player.CanPlace方法的典型用法代码示例。如果您正苦于以下问题:C# Player.CanPlace方法的具体用法?C# Player.CanPlace怎么用?C# Player.CanPlace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fCraft.Player
的用法示例。
在下文中一共展示了Player.CanPlace方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawOneBlock
//stolen from BuildingCommands
#region DrawOneBlock
static void DrawOneBlock ( Player player, Map map, Block drawBlock, Vector3I coord,
BlockChangeContext context, ref int blocks, ref int blocksDenied, fCraft.Drawing.UndoState undoState ) {
if ( map == null ) return;
if ( player == null ) throw new ArgumentNullException( "player" );
if ( !map.InBounds( coord ) ) return;
Block block = map.GetBlock( coord );
if ( block == drawBlock ) return;
if ( player.CanPlace( map, coord, drawBlock, context ) != CanPlaceResult.Allowed ) {
blocksDenied++;
return;
}
map.QueueUpdate( new BlockUpdate( null, coord, drawBlock ) );
Player.RaisePlayerPlacedBlockEvent( player, map, coord, block, drawBlock, context );
if ( !undoState.IsTooLargeToUndo ) {
if ( !undoState.Add( coord, block ) ) {
player.Message( "NOTE: This draw command is too massive to undo." );
player.LastDrawOp = null;
}
}
blocks++;
}
示例2: Place
static void Place(Player player, Command cmd)
{
if (player.LastUsedBlockType != Block.Undefined)
{
Vector3I Pos = new Vector3I(player.Position.X / 32, player.Position.Y / 32, (player.Position.Z / 32) - 2);
if (player.CanPlace(player.World.Map, Pos, player.LastUsedBlockType, BlockChangeContext.Manual) != CanPlaceResult.Allowed)
{
player.Message("&WYou are not allowed to build here");
return;
}
Player.RaisePlayerPlacedBlockEvent(player, player.WorldMap, Pos, player.WorldMap.GetBlock(Pos), player.LastUsedBlockType, BlockChangeContext.Manual);
BlockUpdate blockUpdate = new BlockUpdate(null, Pos, player.LastUsedBlockType);
player.World.Map.QueueUpdate(blockUpdate);
player.Message("Block placed below your feet");
}
else player.Message("&WError: No last used blocktype was found");
}
示例3: DisPlace
private static void DisPlace(Player player, CommandReader cmd) {
Block block;
if (cmd.Count <= 2) {
player.Message(CdDisPlace.Usage);
return;
}
string tryBlock = cmd.Next();
if (!Map.GetBlockByName(tryBlock, false, out block)) {
player.Message("Invalid block name/id: {0}", tryBlock);
return;
}
int dis;
string tryInt = cmd.Next();
if (!int.TryParse(tryInt, out dis)) {
player.Message("Invalid distance: {0}", tryInt);
return;
}
dis = dis*32;
byte rot = player.Position.R;
byte ud = player.Position.L;
if (225 < ud || ud < 32) {
if (225 <= rot || rot <= 32) {
Vector3I Pos = new Vector3I(player.Position.X/32, (player.Position.Y - dis)/32,
(player.Position.Z - 32)/32);
Pos.X = Math.Min(player.WorldMap.Width - 1, Math.Max(0, Pos.X));
Pos.Y = Math.Min(player.WorldMap.Length - 1, Math.Max(0, Pos.Y));
Pos.Z = Math.Min(player.WorldMap.Height - 1, Math.Max(0, Pos.Z));
if (player.CanPlace(player.World.Map, Pos, block, BlockChangeContext.Drawn) !=
CanPlaceResult.Allowed) {
player.Message("&WYou are not allowed to build here");
return;
}
Player.RaisePlayerPlacedBlockEvent(player, player.WorldMap, Pos, player.WorldMap.GetBlock(Pos),
block, BlockChangeContext.Drawn);
BlockUpdate blockUpdate = new BlockUpdate(null, Pos, block);
player.World.Map.QueueUpdate(blockUpdate);
player.Message("Block placed at {0} ({1} blocks away from you)", Pos, dis/32);
} else if (33 <= rot && rot <= 96) {
Vector3I Pos = new Vector3I((player.Position.X + dis)/32, player.Position.Y/32,
(player.Position.Z - 32) / 32);
Pos.X = Math.Min(player.WorldMap.Width - 1, Math.Max(0, Pos.X));
Pos.Y = Math.Min(player.WorldMap.Length - 1, Math.Max(0, Pos.Y));
Pos.Z = Math.Min(player.WorldMap.Height - 1, Math.Max(0, Pos.Z));
if (player.CanPlace(player.World.Map, Pos, block, BlockChangeContext.Drawn) !=
CanPlaceResult.Allowed) {
player.Message("&WYou are not allowed to build here");
return;
}
Player.RaisePlayerPlacedBlockEvent(player, player.WorldMap, Pos, player.WorldMap.GetBlock(Pos),
block, BlockChangeContext.Drawn);
BlockUpdate blockUpdate = new BlockUpdate(null, Pos, block);
player.World.Map.QueueUpdate(blockUpdate);
player.Message("Block placed at {0} ({1} blocks away from you)", Pos, dis/32);
} else if (97 <= rot && rot <= 160) {
Vector3I Pos = new Vector3I(player.Position.X/32, (player.Position.Y + dis)/32,
(player.Position.Z - 32) / 32);
Pos.X = Math.Min(player.WorldMap.Width - 1, Math.Max(0, Pos.X));
Pos.Y = Math.Min(player.WorldMap.Length - 1, Math.Max(0, Pos.Y));
Pos.Z = Math.Min(player.WorldMap.Height - 1, Math.Max(0, Pos.Z));
if (player.CanPlace(player.World.Map, Pos, block, BlockChangeContext.Drawn) !=
CanPlaceResult.Allowed) {
player.Message("&WYou are not allowed to build here");
return;
}
Player.RaisePlayerPlacedBlockEvent(player, player.WorldMap, Pos, player.WorldMap.GetBlock(Pos),
block, BlockChangeContext.Drawn);
BlockUpdate blockUpdate = new BlockUpdate(null, Pos, block);
player.World.Map.QueueUpdate(blockUpdate);
player.Message("Block placed at {0} ({1} blocks away from you)", Pos, dis/32);
} else if (161 <= rot && rot <= 224) {
Vector3I Pos = new Vector3I((player.Position.X - dis)/32, player.Position.Y/32,
(player.Position.Z - 32) / 32);
Pos.X = Math.Min(player.WorldMap.Width - 1, Math.Max(0, Pos.X));
Pos.Y = Math.Min(player.WorldMap.Length - 1, Math.Max(0, Pos.Y));
Pos.Z = Math.Min(player.WorldMap.Height - 1, Math.Max(0, Pos.Z));
if (player.CanPlace(player.World.Map, Pos, block, BlockChangeContext.Drawn) !=
CanPlaceResult.Allowed) {
player.Message("&WYou are not allowed to build here");
return;
}
Player.RaisePlayerPlacedBlockEvent(player, player.WorldMap, Pos, player.WorldMap.GetBlock(Pos),
block, BlockChangeContext.Drawn);
BlockUpdate blockUpdate = new BlockUpdate(null, Pos, block);
player.World.Map.QueueUpdate(blockUpdate);
player.Message("Block placed at {0} ({1} blocks away from you)", Pos, dis/32);
} else {
player.Message("Error occurred, please try again.");
return;
}
} else {
if (192 <= ud && ud <= 224) {
Vector3I Pos = new Vector3I(player.Position.X/32, player.Position.Y/32,
//.........这里部分代码省略.........
示例4: MessageBlockAdd
static void MessageBlockAdd( Player player, Vector3I[] marks, object tag )
{
string Message = ( string )tag;
Vector3I mark = marks[0];
if ( !player.Info.Rank.AllowSecurityCircumvention ) {
SecurityCheckResult buildCheck = player.World.BuildSecurity.CheckDetailed( player.Info );
switch ( buildCheck ) {
case SecurityCheckResult.BlackListed:
player.Message( "Cannot add a MessageBlock to world {0}&S: You are barred from building here.",
player.World.ClassyName );
return;
case SecurityCheckResult.RankTooLow:
player.Message( "Cannot add a MessageBlock to world {0}&S: You are not allowed to build here.",
player.World.ClassyName );
return;
//case SecurityCheckResult.RankTooHigh:
}
}
if ( player.LastUsedBlockType != Block.Undefined ) {
Vector3I Pos = mark;
if ( player.CanPlace( player.World.Map, Pos, player.LastUsedBlockType, BlockChangeContext.Manual ) != CanPlaceResult.Allowed ) {
player.Message( "&WYou are not allowed to build here" );
return;
}
Player.RaisePlayerPlacedBlockEvent( player, player.WorldMap, Pos, player.WorldMap.GetBlock( Pos ), player.LastUsedBlockType, BlockChangeContext.Manual );
BlockUpdate blockUpdate = new BlockUpdate( null, Pos, player.LastUsedBlockType );
player.World.Map.QueueUpdate( blockUpdate );
} else {
player.Message( "&WError: No last used blocktype was found" );
return;
}
MessageBlock MessageBlock = new MessageBlock( player.World.Name, mark,
MessageBlock.GenerateName( player.World ),
player.ClassyName, Message );
MessageBlock.Range = new MessageBlockRange( mark.X, mark.X, mark.Y, mark.Y, mark.Z, mark.Z );
MessageBlockHandler.CreateMessageBlock( MessageBlock, player.World );
NormalBrush brush = new NormalBrush( Block.Air );
Logger.Log( LogType.UserActivity, "{0} created MessageBlock {1} (on world {2})", player.Name, MessageBlock.Name, player.World.Name );
player.Message( "MessageBlock created on world {0}&S with name {1}", player.World.ClassyName, MessageBlock.Name );
}
示例5: VisitBlock
//true if not stopped
public bool VisitBlock(World world, Vector3I pos, Block block, Player owner, ref int restDistance, IList<BlockUpdate> updates, Block sending)
{
if (Block.TNT == block) //explode it
{
world.AddPhysicsTask(new TNTTask(world, pos, owner, false, true), _r.Next(150, 300));
}
if (Block.Air != block && Block.Water != block && Block.Lava != block)
if (owner.CanPlace(world.Map, pos, Block.Wood, BlockChangeContext.Manual) == CanPlaceResult.Allowed)
updates.Add(new BlockUpdate(null, pos, Block.Air));
return true;
}
示例6: DoorAdd
static void DoorAdd( Player player, Vector3I[] marks, object tag )
{
int sx = Math.Min( marks[0].X, marks[1].X );
int ex = Math.Max( marks[0].X, marks[1].X );
int sy = Math.Min( marks[0].Y, marks[1].Y );
int ey = Math.Max( marks[0].Y, marks[1].Y );
int sh = Math.Min( marks[0].Z, marks[1].Z );
int eh = Math.Max( marks[0].Z, marks[1].Z );
int volume = ( ex - sx + 1 ) * ( ey - sy + 1 ) * ( eh - sh + 1 );
if ( volume > 30 ) {
player.Message( "Doors are only allowed to be {0} blocks", 30 );
return;
}
if ( !player.Info.Rank.AllowSecurityCircumvention ) {
SecurityCheckResult buildCheck = player.World.BuildSecurity.CheckDetailed( player.Info );
switch ( buildCheck ) {
case SecurityCheckResult.BlackListed:
player.Message( "Cannot add a door to world {0}&S: You are barred from building here.",
player.World.ClassyName );
return;
case SecurityCheckResult.RankTooLow:
player.Message( "Cannot add a door to world {0}&S: You are not allowed to build here.",
player.World.ClassyName );
return;
//case SecurityCheckResult.RankTooHigh:
}
}
List<Vector3I> blocks = new List<Vector3I>();
for ( int x = sx; x < ex; x++ ) {
for ( int y = sy; y < ey; y++ ) {
for ( int z = sh; z < eh; z++ ) {
if ( player.CanPlace( player.World.Map, new Vector3I( x, y, z ), Block.Wood, BlockChangeContext.Manual ) != CanPlaceResult.Allowed ) {
player.Message( "Cannot add a door to world {0}&S: Build permissions in this area replied with 'denied'.",
player.World.ClassyName );
return;
}
blocks.Add( new Vector3I( x, y, z ) );
}
}
}
Door door = new Door( player.World.Name,
blocks.ToArray(),
fCraft.Doors.Door.GenerateName( player.World ),
player.ClassyName );
door.Range = new DoorRange( sx, ex, sy, ey, sh, eh );
DoorHandler.CreateDoor( door, player.World );
Logger.Log( LogType.UserActivity, "{0} created door {1} (on world {2})", player.Name, door.Name, player.World.Name );
player.Message( "Door created on world {0}&S with name {1}", player.World.ClassyName, door.Name );
}
示例7: Particle
/// <summary>
/// Initializes a new instance of the <see cref="Particle"/> class.
/// </summary>
/// <param name="world">The world.</param>
/// <param name="pos">The initial position.</param>
/// <param name="direction">The direction in which the particle is flying.</param>
/// <param name="owner">The owner of the particle.</param>
/// <param name="block">The block type of the particle.</param>
/// <param name="behavior">The partcle behavior. Includes how fare and fast it moves, what happens if it hits a player an obstacle etc.</param>
public Particle(World world, Vector3I pos, Vector3F direction, Player owner,
Block block, IParticleBehavior behavior)
: base(world)
{
_direction = direction.Normalize();
if (_direction == Vector3F.Zero)
throw new ArgumentException("direction vector cannot be zero");
_stepDelay = behavior.ProcessingStepsPerSecond <= 0 || behavior.ProcessingStepsPerSecond > 20
? 50
: 1000 / behavior.ProcessingStepsPerSecond;
_pos = pos;
_startingPos = pos;
_currentStep = 0;
_owner = owner;
_block = block;
_restDistance = behavior.MaxDistance;
_behavior = behavior;
lock (_world.SyncRoot)
{
//draw it once right now
if (null != _map && ReferenceEquals(_map, _world.Map))
{
_prevBlock = _map.GetBlock(pos);
if (Block.Undefined != _prevBlock) //out of bounds!
if (owner.CanPlace(_map, pos, Block.Wood, BlockChangeContext.Manual) == CanPlaceResult.Allowed)
UpdateMap(new BlockUpdate(null, pos, block));
}
}
}
示例8: Place
static void Place(Player player, Command cmd)
{
Block block;
if (player.LastUsedBlockType == Block.Undefined)
{
block = Block.Stone;
}
else
{
block = player.LastUsedBlockType;
}
Vector3I Pos = new Vector3I(player.Position.X / 32, player.Position.Y / 32, (player.Position.Z / 32) - 2);
if (player.CanPlace(player.World.Map, Pos, player.GetBind(block), BlockChangeContext.Manual) != CanPlaceResult.Allowed)
{
player.Message("&WYou are not allowed to build here");
return;
}
Player.RaisePlayerPlacedBlockEvent(player, player.WorldMap, Pos, player.WorldMap.GetBlock(Pos), block, BlockChangeContext.Manual);
BlockUpdate blockUpdate = new BlockUpdate(null, Pos, block);
player.World.Map.QueueUpdate(blockUpdate);
player.Message("Block placed below your feet");
}
示例9: ReplaceCallback
unsafe internal static void ReplaceCallback( Player player, Position[] marks, object drawArgs ) {
ReplaceArgs args = (ReplaceArgs)drawArgs;
byte* specialTypes = stackalloc byte[args.Types.Length];
int specialTypeCount = args.Types.Length;
for( int i = 0; i < args.Types.Length; i++ ) {
specialTypes[i] = (byte)args.Types[i];
}
bool doExclude = args.DoExclude;
// find start/end coordinates
int sx = Math.Min( marks[0].X, marks[1].X );
int ex = Math.Max( marks[0].X, marks[1].X );
int sy = Math.Min( marks[0].Y, marks[1].Y );
int ey = Math.Max( marks[0].Y, marks[1].Y );
int sh = Math.Min( marks[0].H, marks[1].H );
int eh = Math.Max( marks[0].H, marks[1].H );
int volume = (ex - sx + 1) * (ey - sy + 1) * (eh - sh + 1);
if( !player.CanDraw( volume ) ) {
player.MessageNow( "You are only allowed to run draw commands that affect up to {0} blocks. This one would affect {1} blocks.",
player.Info.Rank.DrawLimit,
volume );
return;
}
player.UndoBuffer.Clear();
bool cannotUndo = false;
int blocks = 0, blocksDenied = 0;
for( int x = sx; x <= ex; x += DrawStride ) {
for( int y = sy; y <= ey; y += DrawStride ) {
for( int h = sh; h <= eh; h++ ) {
for( int y3 = 0; y3 < DrawStride && y + y3 <= ey; y3++ ) {
for( int x3 = 0; x3 < DrawStride && x + x3 <= ex; x3++ ) {
byte block = player.World.Map.GetBlockByte( x + x3, y + y3, h );
bool skip = !args.DoExclude;
for( int i = 0; i < specialTypeCount; i++ ) {
if( block == specialTypes[i] ) {
skip = args.DoExclude;
break;
}
}
if( skip ) continue;
if( player.CanPlace( x + x3, y + y3, h, args.ReplacementBlock, false ) != CanPlaceResult.Allowed ) {
blocksDenied++;
continue;
}
player.World.Map.QueueUpdate( new BlockUpdate( null, x + x3, y + y3, h, args.ReplacementBlock ) );
Server.RaisePlayerPlacedBlockEvent( player, (short)x, (short)y, (short)h, (Block)block, args.ReplacementBlock, false );
if( blocks < MaxUndoCount ) {
player.UndoBuffer.Enqueue( new BlockUpdate( null, x + x3, y + y3, h, block ) );
} else if( !cannotUndo ) {
player.UndoBuffer.Clear();
player.UndoBuffer.TrimExcess();
player.MessageNow( "NOTE: This draw command is too massive to undo." );
cannotUndo = true;
if( player.Can( Permission.ManageWorlds ) ) {
player.MessageNow( "Reminder: You can use &H/wflush&S to accelerate draw commands." );
}
}
blocks++;
}
}
}
}
}
Logger.Log( "{0} replaced {1} blocks {2} ({3}) with {4} (on world {5})", LogType.UserActivity,
player.Name,
blocks,
(doExclude ? "except" : "of"),
args.Types.JoinToString(),
args.ReplacementBlock,
player.World.Name );
DrawingFinished( player, "replaced", blocks, blocksDenied );
}
示例10: DrawOneBlock
static void DrawOneBlock( Player player, byte drawBlock, int x, int y, int h, ref int blocks, ref int blocksDenied, ref bool cannotUndo ) {
if( !player.World.Map.InBounds( x, y, h ) ) return;
byte block = player.World.Map.GetBlockByte( x, y, h );
if( block == drawBlock ) return;
if( player.CanPlace( x, y, h, (Block)drawBlock, false ) != CanPlaceResult.Allowed ) {
blocksDenied++;
return;
}
// this would've been an easy way to do block tracking for draw commands BUT
// if i set "origin" to player, he will not receive the block update. I tried.
player.World.Map.QueueUpdate( new BlockUpdate( null, x, y, h, drawBlock ) );
Server.RaisePlayerPlacedBlockEvent( player, (short)x, (short)y, (short)h, (Block)block, (Block)drawBlock, false );
//player.SendDelayed( PacketWriter.MakeSetBlock( x, y, h, drawBlock ) );
if( blocks < MaxUndoCount ) {
player.UndoBuffer.Enqueue( new BlockUpdate( null, x, y, h, block ) );
} else if( !cannotUndo ) {
player.UndoBuffer.Clear();
player.UndoBuffer.TrimExcess();
player.MessageNow( "NOTE: This draw command is too massive to undo." );
if( player.Can( Permission.ManageWorlds ) ) {
player.MessageNow( "Reminder: You can use &H/wflush&S to accelerate draw commands." );
}
cannotUndo = true;
}
blocks++;
}
示例11: DoorAdd
static void DoorAdd( Player player, Vector3I[] marks, object tag )
{
int sx = Math.Min( marks[0].X, marks[1].X );
int ex = Math.Max( marks[0].X, marks[1].X );
int sy = Math.Min( marks[0].Y, marks[1].Y );
int ey = Math.Max( marks[0].Y, marks[1].Y );
int sh = Math.Min( marks[0].Z, marks[1].Z );
int eh = Math.Max( marks[0].Z, marks[1].Z );
int volume = ( ex - sx + 1 ) * ( ey - sy + 1 ) * ( eh - sh + 1 );
if ( volume > maxDoorBlocks ) {
player.Message( "Doors are only allowed to be {0} blocks", maxDoorBlocks );
return;
}
if ( !player.Info.Rank.AllowSecurityCircumvention ) {
SecurityCheckResult buildCheck = player.World.BuildSecurity.CheckDetailed( player.Info );
switch ( buildCheck ) {
case SecurityCheckResult.BlackListed:
player.Message( "Cannot add a door to world {0}&S: You are barred from building here.",
player.World.ClassyName );
return;
case SecurityCheckResult.RankTooLow:
player.Message( "Cannot add a door to world {0}&S: You are not allowed to build here.",
player.World.ClassyName );
return;
//case SecurityCheckResult.RankTooHigh:
}
}
for ( int x = sx; x < ex; x++ ) {
for ( int y = sy; y < ey; y++ ) {
for ( int z = sh; z < eh; z++ ) {
if ( player.CanPlace( player.World.Map, new Vector3I( x, y, z ), Block.Wood, BlockChangeContext.Manual ) != CanPlaceResult.Allowed ) {
player.Message( "Cannot add a door to world {0}&S: Build permissions in this area replied with 'denied'.",
player.World.ClassyName );
return;
}
}
}
}
Zone door = ( Zone )tag;
door.Create( new BoundingBox( marks[0], marks[1] ), player.Info );
player.WorldMap.Zones.Add( door );
Logger.Log( LogType.UserActivity, "{0} created door {1} (on world {2})", player.Name, door.Name, player.World.Name );
player.Message( "Door created: {0}x{1}x{2}", door.Bounds.Dimensions.X,
door.Bounds.Dimensions.Y,
door.Bounds.Dimensions.Z );
}