Example #1
0
 public SimpleDynamicSituationFactory(Structure2D structure, IParticleFactory particlesFactory, List <IDecidable> decisionMakers, float executionTime)
 {
     this.structure        = structure;
     this.particlesFactory = particlesFactory;
     this.decisionMakers   = decisionMakers;
     this.executionTime    = executionTime;
 }
Example #2
0
        public static IParticleFactory ReadParticleFactory(this NetIncomingMessage msg)
        {
            IParticleFactory f = null;
            int hash           = msg.ReadInt32();

            if (hash == typeof(ParticleSphereFactory).GUID.GetHashCode())
            {
                f = new ParticleSphereFactory();
            }
            else if (hash == typeof(ParticleImageFactory).GUID.GetHashCode())
            {
                f = new ParticleImageFactory();
            }
            else if (hash == typeof(ParticleSmokeFactory).GUID.GetHashCode())
            {
                f = new ParticleSmokeFactory();
            }
            else if (hash == typeof(BaseParticleFactory).GUID.GetHashCode())
            {
                f = new BaseParticleFactory();
            }
            else
            {
                Logger.Error("Reading unsupported factory! Hash " + hash);
            }

            Logger.Warn("Reading particle factory (" + f.GetType().Name + ") hash " + hash);

            f.ReadObject(msg);
            return(f);
        }
Example #3
0
        public static void WriteParticleFactory(this NetOutgoingMessage msg, IParticleFactory f)
        {
            int hash = 0;

            if (f is ParticleSphereFactory)
            {
                hash = typeof(ParticleSphereFactory).GUID.GetHashCode();
            }
            else if (f is ParticleImageFactory)
            {
                hash = typeof(ParticleImageFactory).GUID.GetHashCode();
            }
            else if (f is ParticleSmokeFactory)
            {
                hash = typeof(ParticleSmokeFactory).GUID.GetHashCode();
            }
            else if (f is BaseParticleFactory)
            {
                hash = typeof(BaseParticleFactory).GUID.GetHashCode();
            }
            else
            {
                Logger.Error("Sending unsupported factory (" + f.GetType().Name + ")!");
            }

            Logger.Warn("Sending particle factory (" + f.GetType().Name + ") hash " + hash);
            msg.Write(hash);

            f.WriteObject(msg);
        }
Example #4
0
        /// <summary>
        /// The constructor creates an emitter.
        /// </summary>
        public Emitter()
        {
            m_particleFactory = m_creator;

            m_particles    = new List <Particle>();
            m_behaviours   = new SortedCollection <Behaviour>(this);
            m_initializers = new SortedCollection <Initializer>(this);
            m_activities   = new SortedCollection <Activity>(this);
            m_counter      = new ZeroCounter();
        }
Example #5
0
 internal AggregateFormationService
 (
     ISizeDistribution <int> aggregateSizeDistribution,
     ISizeDistribution <double> primaryParticleSizeDistribution,
     IAggregateFormationConfig config,
     IParticleFactory <Aggregate> particleFactory,
     ILogger logger,
     int seed = -1
 )
 {
     _seed = seed;
     _aggregateSizeDistribution       = aggregateSizeDistribution;
     _primaryParticleSizeDistribution = primaryParticleSizeDistribution;
     _config          = config;
     _logger          = logger;
     _particleFactory = particleFactory;
 }
Example #6
0
        public AggregateFormationService(
            IAggregateSizeDistributionFactory aggregateSizeDistributionFactory,
            IPrimaryParticleSizeDistributionFactory primaryParticleSizeDistributionFactory,
            IAggregateFormationFactory aggregateFormationFactory,
            INeighborslistFactory neighborslistFactory,
            IAggregateFormationConfig config,
            ILogger logger)
        {
            _aggregateSizeDistributionFactory       = aggregateSizeDistributionFactory ?? throw new ArgumentException(nameof(aggregateSizeDistributionFactory));
            _primaryParticleSizeDistributionFactory = primaryParticleSizeDistributionFactory ?? throw new ArgumentException(nameof(primaryParticleSizeDistributionFactory));
            _aggregateFormationFactory = aggregateFormationFactory ?? throw new ArgumentException(nameof(aggregateFormationFactory));
            _neighborslistFactory      = neighborslistFactory ?? throw new ArgumentException(nameof(neighborslistFactory));
            _config = config ?? throw new ArgumentException(nameof(config));
            _logger = logger ?? throw new ArgumentException(nameof(logger));

            var rndGen = new Random();

            _aggregateSizeDistribution       = aggregateSizeDistributionFactory.Build(rndGen, config);
            _primaryParticleSizeDistribution = primaryParticleSizeDistributionFactory.Build(rndGen, config);
            _particleFactory = _aggregateFormationFactory.Build(_primaryParticleSizeDistribution, _neighborslistFactory, _config, _logger);
        }
Example #7
0
        /// <summary>
        ///
        /// </summary>
        public override void Initialize()
        {
            if (Emitter == null)
            {
                var viewPort = GameContext.Game.GraphicsDevice.Viewport;
                Emitter = new ParticleEmitter(
                    new Rectangle(viewPort.Width / 2, viewPort.Height / 2, 1, 1),
                    new Vector2(-50, -100),
                    new Vector2(50, 100)
                    );
            }

            if (TextureSelector == null)
            {
                TextureSelector = new RandomTextureSelector();
            }

            if (ParticleFactory == null)
            {
                ParticleFactory = new DefaultParticleFactory(Vector2.Zero, Vector2.Zero, 2.0f, 10.0f);
            }

            base.Initialize();
        }
Example #8
0
        /// <summary>
        /// The constructor creates an emitter.
        /// </summary>
        public Emitter()
        {
            m_particleFactory = m_creator;

            m_particles = new List<Particle>();
            m_behaviours = new SortedCollection<Behaviour>(this);
            m_initializers = new SortedCollection<Initializer>(this);
            m_activities = new SortedCollection<Activity>(this);
            m_counter = new ZeroCounter();
        }