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 ) );
}
}
}