本文整理汇总了C#中System.Entity.Get方法的典型用法代码示例。如果您正苦于以下问题:C# Entity.Get方法的具体用法?C# Entity.Get怎么用?C# Entity.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Entity
的用法示例。
在下文中一共展示了Entity.Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MovementUpdate
public MovementUpdate(Entity entity)
{
id = entity.Id;
newPosition = entity.Get<PositionComponent>().Position;
newRotation = entity.Get<PositionComponent>().Rotation;
newVel = entity.Get<MovementComponent>().Velocity;
}
示例2: DrawBullet
private void DrawBullet(GraphicsContext graphicsContext, Entity entity, CBullet bullet)
{
TextureDefinition texture = this.GetTexture(bullet.Weapon.Type);
if (bullet.Weapon.Type == WeaponType.RocketLauncher)
{
graphicsContext.SpriteBatch.DrawCentered(texture, entity.Transform.Position, Color.White, entity.Transform.Rotation, 2);
}
else if (bullet.Weapon.Type == WeaponType.Bouncer)
{
graphicsContext.SpriteBatch.DrawCentered(texture, entity.Transform.Position, new Color(160, 160, 160), entity.Transform.Rotation, 1);
}
else if (bullet.Weapon.Type == WeaponType.Flamethrower)
{
CLifeTime lifeTime = entity.Get<CLifeTime>();
Color color = Color.Lerp(Color.LightGoldenrodYellow, Color.OrangeRed, 1 - lifeTime.NormalizedTimeRemaining) * 0.75f;
graphicsContext.SpriteBatch.DrawCentered(graphicsContext.BlankTexture, entity.Transform.Position, color * lifeTime.NormalizedTimeRemaining, 0, FlaiMath.Scale(lifeTime.NormalizedTimeRemaining, 1, 0, 8, 32));
}
else if (bullet.Weapon.Type == WeaponType.Waterblaster)
{
CLifeTime lifeTime = entity.Get<CLifeTime>();
Color color = Color.Lerp(Color.AliceBlue, new Color(0, 69, 255), 1 - lifeTime.NormalizedTimeRemaining) * 0.75f;
graphicsContext.SpriteBatch.DrawCentered(graphicsContext.BlankTexture, entity.Transform.Position, color * lifeTime.NormalizedTimeRemaining, 0, FlaiMath.Scale(lifeTime.NormalizedTimeRemaining, 1, 0, 8, 32));
}
else
{
graphicsContext.SpriteBatch.DrawCentered(texture, entity.Transform.Position, new Color(255, 255, 128) * 0.625f, entity.Transform.Rotation, 4);
}
}
示例3: Update
public void Update(Entity e, GameTime t)
{
// We burn through just enough time for emission to occur. We
// update the state, then perform an emission. Then we pick up
// where we left off (when the loop loops).
uint dt = (uint) t.ElapsedGameTime.TotalMilliseconds;
while (dt > 0) {
uint emitTime = e.Get(EmitTime);
uint timeToEmission = e.Get(TimeToEmission);
if (timeToEmission == 0) {
timeToEmission = emitTime;
}
uint burntTime = Math.Min(timeToEmission, dt);
timeToEmission -= burntTime;
dt -= burntTime;
e.Set(TimeToEmission, timeToEmission);
if (timeToEmission == 0 && e.Get(IsEmitting)) {
this.onEmit(e);
}
}
}
示例4: OnEntityAdded
public override void OnEntityAdded(Entity entity)
{
if (Contains<Animation>(entity) &&
Contains<Position>(entity))
{
_animations.Add(entity.Get<Animation>());
_positions.Add(entity.Get<Position>());
_entities.Add(entity);
}
if (Contains<Tilemap>(entity)
&& Contains<Tilesheet>(entity))
{
if (entity.Get<Tilemap>().Layer <= 0)
{
_bgTilemaps.Add(entity);
_bgTilemaps.Sort();
}
else
{
_fgTilemaps.Add(entity);
_fgTilemaps.Sort();
}
}
if (Contains<Viewport>(entity))
{
_viewports.Add(entity);
}
}
示例5: Process
public override void Process(Entity entity, GameTime gameTime)
{
foreach (InputEvent e in entity.Get<InputComponent>().InputEvents.Keys)
{
if(e is KeyboardInputEvent)
{
KeyboardInputEvent key = (KeyboardInputEvent)e;
if (Keyboard.CheckInput(key.Key, key.InputType))
{
//then we have a match, do something
Message message = entity.Get<InputComponent>().InputEvents[e]();
Messageboard.PostMessage(message);
}
}
else if (e is GamepadButtonInputEvent || e is GamepadAnalogStickInputEvent)
{
if (Gamepad.CheckInput(e))
{
if (e is GamepadButtonInputEvent)
{
Message message = entity.Get<InputComponent>().InputEvents[e]();
Messageboard.PostMessage(message);
}
else
{
Vector2 stickInput = Gamepad.GetAnalogStick(((GamepadAnalogStickInputEvent)e).Stick);
Vector3 movement = new Vector3(stickInput.X, 0, stickInput.Y) * 3f;
Message message = entity.Get<InputComponent>().InputEvents[e](movement);
Messageboard.PostMessage(message);
}
}
}
}
}
示例6: Bind
public override void Bind(Entity result, Main main, bool creating = false)
{
this.SetMain(result, main);
Transform transform = result.Get<Transform>();
Model model = result.Get<Model>("Model");
model.Add(new Binding<Matrix>(model.Transform, transform.Matrix));
}
示例7: AttachEditorComponents
public override void AttachEditorComponents(Entity result, Main main)
{
base.AttachEditorComponents(result, main);
Model model = result.Get<Model>("EditorModel");
model.Add(new Binding<Vector3, string>(model.Color, x => string.IsNullOrEmpty(x) ? Vector3.One : new Vector3(1.0f, 0.0f, 0.0f), result.Get<Script>().Errors));
}
示例8: Bind
public override void Bind(Entity result, Main main, bool creating = false)
{
result.CannotSuspendByDistance = true;
Transform transform = result.Get<Transform>();
DirectionalLight directionalLight = result.Get<DirectionalLight>();
this.SetMain(result, main);
directionalLight.Add(new TwoWayBinding<Vector3, Matrix>
(
directionalLight.Direction,
delegate(Matrix x)
{
Vector3 y = Vector3.Normalize(-x.Forward);
if (Vector3.Dot(y, directionalLight.Direction) > 0.0f)
return y;
return -y;
},
transform.Orientation,
delegate(Vector3 x)
{
Matrix matrix = Matrix.Identity;
matrix.Forward = Vector3.Normalize(-x);
matrix.Left = x.Equals(Vector3.Up) ? Vector3.Left : Vector3.Normalize(Vector3.Cross(x, Vector3.Up));
matrix.Up = Vector3.Normalize(Vector3.Cross(matrix.Left, matrix.Forward));
return matrix;
}
));
}
示例9: Bind
public override void Bind(Entity result, Main main, bool creating = false)
{
this.SetMain(result, main);
result.CannotSuspendByDistance = true;
Transform transform = result.Get<Transform>();
ModelAlpha model = new ModelAlpha();
model.Color.Value = new Vector3(1.2f, 1.0f, 0.8f);
model.Editable = false;
model.Serialize = false;
model.Filename.Value = "Models\\electricity";
model.DrawOrder.Value = 11;
result.Add("Model", model);
result.GetOrMakeProperty<bool>("IsMapEdge", true, true);
PhysicsBlock block = result.Get<PhysicsBlock>();
block.Box.BecomeKinematic();
this.boundaries.Add(result);
result.Add(new CommandBinding(result.Delete, delegate() { this.boundaries.Remove(result); }));
block.Add(new TwoWayBinding<Matrix>(transform.Matrix, block.Transform));
model.Add(new Binding<Matrix>(model.Transform, transform.Matrix));
model.Add(new Binding<Vector3>(model.Scale, x => new Vector3(x.X * 0.5f, x.Y * 0.5f, 1.0f), block.Size));
Property<Vector2> scaleParameter = model.GetVector2Parameter("Scale");
model.Add(new Binding<Vector2, Vector3>(scaleParameter, x => new Vector2(x.Y, x.X), model.Scale));
model.Add(new CommandBinding(main.ReloadedContent, delegate()
{
scaleParameter.Reset();
}));
}
示例10: Bind
public override void Bind(Entity result, Main main, bool creating = false)
{
this.SetMain(result, main);
Transform transform = result.Get<Transform>();
Sound sound = result.Get<Sound>("Sound");
sound.Add(new Binding<Vector3>(sound.Position, transform.Position));
result.CannotSuspendByDistance = !sound.Is3D;
result.Add(new NotifyBinding(delegate()
{
result.CannotSuspendByDistance = !sound.Is3D;
}, sound.Is3D));
Property<float> min = result.GetProperty<float>("MinimumInterval");
Property<float> max = result.GetProperty<float>("MaximumInterval");
Random random = new Random();
float interval = min + ((float)random.NextDouble() * (max - min));
result.Add(new Updater
{
delegate(float dt)
{
if (!sound.IsPlaying)
interval -= dt;
if (interval <= 0)
{
sound.Play.Execute();
interval = min + ((float)random.NextDouble() * (max - min));
}
}
});
}
示例11: AttachEditorComponents
public override void AttachEditorComponents(Entity result, Main main)
{
base.AttachEditorComponents(result, main);
Model editorModel = result.Get<Model>("EditorModel");
Model model = result.Get<Model>("Model");
editorModel.Add(new Binding<bool>(editorModel.Enabled, x => !x, model.IsValid));
}
示例12: Bind
public override void Bind(Entity result, Main main, bool creating = false)
{
if (result.GetOrMakeProperty<bool>("Attach", true))
MapAttachable.MakeAttachable(result, main);
this.SetMain(result, main);
if (main.EditorEnabled)
{
result.Add("Spawn Here", new Command
{
Action = delegate()
{
((GameMain)main).StartSpawnPoint.Value = result.ID;
Editor editor = main.Get("Editor").First().Get<Editor>();
if (editor.NeedsSave)
editor.Save.Execute();
main.EditorEnabled.Value = false;
IO.MapLoader.Load(main, null, main.MapFile);
},
ShowInEditor = true,
});
}
Transform transform = result.Get<Transform>();
PlayerSpawn spawn = result.Get<PlayerSpawn>();
spawn.Add(new TwoWayBinding<Vector3>(transform.Position, spawn.Position));
spawn.Add(new Binding<float, Vector3>(spawn.Rotation, x => ((float)Math.PI * -0.5f) - (float)Math.Atan2(x.Z, x.X), transform.Forward));
PlayerTrigger trigger = result.Get<PlayerTrigger>();
trigger.Enabled.Editable = true;
trigger.Add(new TwoWayBinding<Vector3>(transform.Position, trigger.Position));
trigger.Add(new CommandBinding<Entity>(trigger.PlayerEntered, delegate(Entity player) { spawn.Activate.Execute(); }));
}
示例13: Bind
public override void Bind(Entity result, Main main, bool creating = false)
{
this.SetMain(result, main);
Transform transform = result.Get<Transform>();
ParticleEmitter emitter = result.Get<ParticleEmitter>();
emitter.Add(new Binding<Vector3>(emitter.Position, transform.Position));
}
示例14: CalculateRectAfterMove
private static Rectangle CalculateRectAfterMove(Entity entity)
{
var pointAfterVerticalMovement =
new Vector2D(
entity.Get<Rectangle>().TopLeft.X + entity.Get<Velocity2D>().velocity.X * Time.Delta,
entity.Get<Rectangle>().TopLeft.Y + entity.Get<Velocity2D>().velocity.Y * Time.Delta);
return new Rectangle(pointAfterVerticalMovement, entity.Get<Rectangle>().Size);
}
示例15: AttachEditorComponents
public override void AttachEditorComponents(Entity entity, Main main)
{
base.AttachEditorComponents(entity, main);
VoxelAttachable.AttachEditorComponents(entity, main, entity.Get<Model>().Color);
EntityConnectable.AttachEditorComponents(entity, "Target", entity.Get<VoxelFill>().Target);
}