本文整理汇总了C#中EntityManager.GetEntitiesWithComponent方法的典型用法代码示例。如果您正苦于以下问题:C# EntityManager.GetEntitiesWithComponent方法的具体用法?C# EntityManager.GetEntitiesWithComponent怎么用?C# EntityManager.GetEntitiesWithComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityManager
的用法示例。
在下文中一共展示了EntityManager.GetEntitiesWithComponent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
public void Update(double elapsedTime, EntityManager entityManager)
{
var light= entityManager.GetEntitiesWithComponent<PositionalLightComponent>()
.Single();
var component = entityManager.GetComponent<PositionalLightComponent>(light);
//component.Position = new Vector3d(Math.Cos(elapsedTime) * 5, 2, Math.Sin(elapsedTime) * 5);
}
示例2: Update
public void Update(double elapsedTime, EntityManager entityManager)
{
var entities = entityManager.GetEntitiesWithComponent<InputComponent>();
var dt = elapsedTime - _elapsedTime;
foreach (var entity in entities)
{
var inputComponent = entityManager.GetComponent<InputComponent>(entity);
var lightPosition = entityManager.GetComponent<PositionalLightComponent>(entity);
if (_keyboardInputProcessor.IsButtonDown(inputComponent.Forward))
{
lightPosition.Position += new Vector3d(1, 0, 0) * dt * 100;
}
if (_keyboardInputProcessor.IsButtonDown(inputComponent.Backward))
{
lightPosition.Position -= new Vector3d(1, 0, 0) * dt * 100;
}
if (_keyboardInputProcessor.IsButtonDown(inputComponent.Right))
{
lightPosition.Position += new Vector3d(0, 0, 1) * dt * 100;
}
if (_keyboardInputProcessor.IsButtonDown(inputComponent.Left))
{
lightPosition.Position -= new Vector3d(0, 0, 1) * dt * 100;
}
if (_keyboardInputProcessor.IsButtonDown(inputComponent.Up))
{
lightPosition.Position += new Vector3d(0, 1, 0) * dt * 10;
}
if (_keyboardInputProcessor.IsButtonDown(inputComponent.Down))
{
lightPosition.Position -= new Vector3d(0, 1, 0) * dt * 10;
}
_elapsedTime = elapsedTime;
}
}
示例3: Update
public void Update(double elapsedTime, EntityManager entityManager)
{
GL.ClearColor(Color4.White);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.Enable(EnableCap.DepthTest);
GL.CullFace(CullFaceMode.Back);
GL.Enable(EnableCap.CullFace);
GL.FrontFace(FrontFaceDirection.Cw);
_simpleMaterial.Bind();
var light = entityManager.GetEntitiesWithComponent<PositionalLightComponent>().Single();
var positionalLightComponent = entityManager.GetComponent<PositionalLightComponent>(light);
_simpleMaterial.LightPosition.Set((Vector3) positionalLightComponent.Position);
_simpleMaterial.ProjectionMatrix.Set(_camera.ComputeProjectionMatrix().ToMatrix4());
_simpleMaterial.ViewMatrix.Set(_camera.ComputeCameraMatrix().ToMatrix4());
foreach (var entity in entityManager.GetEntitiesWithComponent<StaticMesh>())
{
var component = entityManager.GetComponent<StaticMesh>(entity);
//if(!component.IsVisible)
//continue;
//component.IsVisible = false;
var resources = EnsureResources(component);
resources.VertexArrayObject.Bind();
_simpleMaterial.ModelMatrix.Set(component.ModelMatrix);
_simpleMaterial.Color.Set(component.Color);
//GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
//GL.Disable(EnableCap.CullFace);
GL.DrawElements(BeginMode.Triangles, component.Mesh.Faces.Length * 3, DrawElementsType.UnsignedInt, 0);
//GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
//GL.Enable(EnableCap.CullFace);
resources.VertexArrayObject.Unbind();
}
_simpleMaterial.Unbind();
_normalDebugProgram.Bind();
_normalDebugProgram.ProjectionMatrix.Set(_camera.ComputeProjectionMatrix().ToMatrix4());
_normalDebugProgram.ViewMatrix.Set(_camera.ComputeCameraMatrix().ToMatrix4());
foreach (var entity in entityManager.GetEntitiesWithComponent<NormalComponent>())
{
var component = entityManager.GetComponent<StaticMesh>(entity);
var resources = EnsureResources(component);
resources.VertexArrayObject.Bind();
_normalDebugProgram.ModelMatrix.Set(component.ModelMatrix);
GL.DrawElements(BeginMode.Triangles, component.Mesh.Faces.Length * 3, DrawElementsType.UnsignedInt, 0);
resources.VertexArrayObject.Unbind();
}
_normalDebugProgram.Unbind();
}
示例4: Update
public void Update(double elapsedTime, EntityManager entityManager)
{
foreach (var water in entityManager.GetEntitiesWithComponent<OceanComponent>())
{
var waterComponent = entityManager.GetComponent<OceanComponent>(water);
var waterMesh = entityManager.GetComponent<StaticMesh>(water);
if (waterMesh == null)
{
waterMesh = new StaticMesh
{
Color = new Vector4(0f, 0f, 1f, 0f),
ModelMatrix = Matrix4.Identity
};
entityManager.AddComponentToEntity(water, waterMesh);
}
var mesh = CreateMesh(waterComponent);
waterMesh.Update(mesh);
for (var i = 0; i < waterMesh.Mesh.Vertices.Length; i++)
{
var position = waterMesh.Mesh.Vertices[i].Position;
var vector3D = Gerstner2.CalculateWave((Vector3d)position, elapsedTime, _waveSettings);
waterMesh.Mesh.Vertices[i] = new Vertex3V3N
{
Position = (Vector3)vector3D
};
}
waterMesh.Mesh.CalculateNormals();
waterMesh.Update(waterMesh.Mesh);
}
}