Esempio n. 1
0
 public TreeSystem(SystemManager systemManager, EntityManager entityManager)
 {
     _systemManager = systemManager;
     _entityManager = entityManager;
     _physicsSystem = _systemManager.getSystem(SystemType.Physics) as PhysicsSystem;
     _renderSystem  = _systemManager.getSystem(SystemType.Render) as RenderSystem;
     _markerGrid    = new Dictionary <string, Dictionary <int, Dictionary <int, MarkerCell> > >();
     _metamerGrid   = new Dictionary <string, Dictionary <int, Dictionary <int, List <Metamer> > > >();
 }
Esempio n. 2
0
        public FluidSystem(SystemManager systemManager, EntityManager entityManager)
        {
            _systemManager = systemManager;
            _entityManager = entityManager;

            _physicsSystem = (PhysicsSystem)_systemManager.getSystem(SystemType.Physics);
            _renderSystem = (RenderSystem)_systemManager.getSystem(SystemType.Render);
            fluidGrid = new Dictionary<int, Dictionary<int, List<int>>>();
            liquid = new Particle[MAX_PARTICLES];
            activeParticles = new int[MAX_PARTICLES];
            _simPositions = new Vector2[MAX_PARTICLES];
            _simVelocities = new Vector2[MAX_PARTICLES];
            _delta = new Vector2[MAX_PARTICLES];
            for (int i = 0; i < MAX_PARTICLES; i++)
            {
                liquid[i] = new Particle(this, i, LIQUID_ORIGIN);
            }
        }
Esempio n. 3
0
        public FluidSystem(SystemManager systemManager, EntityManager entityManager)
        {
            _systemManager = systemManager;
            _entityManager = entityManager;

            _physicsSystem  = (PhysicsSystem)_systemManager.getSystem(SystemType.Physics);
            _renderSystem   = (RenderSystem)_systemManager.getSystem(SystemType.Render);
            fluidGrid       = new Dictionary <int, Dictionary <int, List <int> > >();
            liquid          = new Particle[MAX_PARTICLES];
            activeParticles = new int[MAX_PARTICLES];
            _simPositions   = new Vector2[MAX_PARTICLES];
            _simVelocities  = new Vector2[MAX_PARTICLES];
            _delta          = new Vector2[MAX_PARTICLES];
            for (int i = 0; i < MAX_PARTICLES; i++)
            {
                liquid[i] = new Particle(this, i, LIQUID_ORIGIN);
            }
        }
Esempio n. 4
0
        // initializeLevelData -- Takes a level's data and initializes the states needed for the loading process
        private void initializeLevelData(XElement levelData)
        {
            string        levelUid         = levelData.Attribute("name").Value;
            int           levelEntityCount = 0;
            PhysicsSystem physicsSystem    = _systemManager.getSystem(SystemType.Physics) as PhysicsSystem;

            _finalized = false;
            _paused    = true;
            _levelsData.Add(levelUid, levelData);
            _firstPassEntities.Add(levelUid, new List <XElement>());
            _secondPassEntities.Add(levelUid, new List <XElement>());
            _thirdPassEntities.Add(levelUid, new List <XElement>());
            _numEntitiesProcessed.Add(levelUid, 0);
            _finishedLoading.Add(levelUid, false);

            // Create worlds
            physicsSystem.addWorld(levelUid, Loader.loadVector2(levelData.Attribute("gravity"), Vector2.Zero));

            // Parse actors
            foreach (XElement actorData in levelData.Elements("Actor"))
            {
                string type = actorData.Attribute("type").Value;

                // Sort entities into first and second passses
                if (type == "Circuit" || type == "Fluid" || type == "Rope" || type == "Revolute" || type == "Prismatic" || type == "CollisionFilter" || type == "Decal")
                {
                    _thirdPassEntities[levelUid].Add(actorData);
                }
                else if (type == "Tree")
                {
                    _secondPassEntities[levelUid].Add(actorData);
                }
                else
                {
                    _firstPassEntities[levelUid].Add(actorData);
                }
                levelEntityCount++;

                // Reserve actor ids as entity ids
                _entityManager.reserveEntityId(levelUid, int.Parse(actorData.Attribute("id").Value));
            }

            _numEntities.Add(levelUid, levelEntityCount);
        }