fCraft.Particle.Particle C# (CSharp) Method

Particle() public method

Initializes a new instance of the Particle class.
public Particle ( World world, Vector3I pos, Vector3F direction, Player owner, Block block, IParticleBehavior behavior ) : System
world World The world.
pos Vector3I The initial position.
direction Vector3F The direction in which the particle is flying.
owner Player The owner of the particle.
block Block The block type of the particle.
behavior IParticleBehavior The partcle behavior. Includes how fare and fast it moves, what happens if it hits a player an obstacle etc.
return System
        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 ) );
                }
            }
        }