public void LoadContent() { _spriteBatch = new SpriteBatch(_graphics); _world = new StaticEntityWorld(_game.Services); var pp = _graphics.PresentationParameters; _camera = new DefaultCamera(null, new Viewport(0, 0, pp.BackBufferWidth, pp.BackBufferHeight)); _cameraNode = _world.Scene.Root.CreateChild("Camera"); _cameraNode.Position = new Vector3(_camera.ScreenSize / 2.0f, 0.0f); _cameraNode.Scale = new Vector3(.5f); _cameraNode.Attach(_camera); // Create the tile map. _terrain = new Terrain(new Vector2(102.4f, 102.4f), 51.2f, 9); _terrain.DebugEnabled = true; _world.Add(_terrain); // Create the circle brush. _circleBrush = new CircleBrush(2.5f); _circleBrushNode = _world.Scene.CreateSceneNode(); _circleBrushNode.Attach(new CircleRenderable(2.5f, 64) { Color = Vector3.One }); }
protected override void OnWorldChanged(IEntityWorld world) { if (_blockGrid != null) { foreach (var quadTree in _blockGrid) { quadTree.World = world; } } }
public ScatteredGame() { graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = Width; graphics.PreferredBackBufferHeight = Height; IsFixedTimeStep = false; graphics.SynchronizeWithVerticalRetrace = false; entityWorld = EntityManagerFactory.CreateEntityWorld(256, 256, BitmaskSize.Bit32); IsMouseVisible = true; }
protected override void OnWorldChanged(IEntityWorld world) { DestroyPhysics(); if (world != null) { _physicsWorld = ((DynamicEntityWorld)world).PhysicsWorld; InitializePhysics(); } else { _physicsWorld = null; } }
public Entity Create(Vector2 spawnLocation, IEntityWorld world, bool liftPosition = true) { if (Species == -1 || Components.HasChanged) { Species = ++currentSpecies; entityNames.Add(Species, Name); Components.ResolveComponentDependencies( ); Components.Sort( ); } if (liftPosition) { spawnLocation += new Vector2(0, Transform.HalfSize.Y); } return(new Entity(Components, new Transform(spawnLocation, Transform.Size), world, Species)); }
public Entity(ComponentList Components, Transform Transform, IEntityWorld World, int Species) { this.World = World; this.Transform = Transform; this.Species = Species; this.ID = ++currentInstance; for (int i = 0; i < pendingComponentInfos.Length; i++) { pendingComponentInfos[i] = new Queue <object[]>( ); } this.Components = new Component[Components.Count]; for (int i = 0; i < this.Components.Length; i++) { this.Components[i] = Components[i].Create(this); } World.Add(this); }
public EntityFactory(RenderingSystem renderingSystem, IEntityWorld entityManager) { this.renderingSystem = renderingSystem; this.entityManager = entityManager; }
/// <summary> /// Creates a new ComponentMapper instance associated with the specified entity world. /// </summary> /// <param name="world">Entity world instance to associate with.</param> public ComponentMapper(IEntityWorld world) { _world = world; _componentType = ComponentTypeManager.GetTypeFor <T>(); }
/// <summary> /// This method is called when a new world has been set for the entity. /// </summary> /// <param name="world">The new world. Can be null.</param> protected virtual void OnWorldChanged(IEntityWorld world) { }
protected override void OnWorldChanged(IEntityWorld world) { DestroyPhysics(); }