protected override void UpdateEntity(float dt, Entity entity) { var position = entity.Get<Position>(); var direction = entity.Get<Direction>(); for (int i = 0; i < entity.Count(); ++i) { position.X[i] += direction.X[i] * dt; position.Y[i] += direction.Y[i] * dt; } }
protected override void UpdateEntity(float dt, Entity entity) { var tc = entity.Get<TypeChanger>(); if ((tc.TTL -= dt) <= 0) { for (int i = 0; i < entity.Count(); ++i) { entity.Transform(i, tc.Transformation); } } }
private static bool EntityListFieldEqual(object field1, object field2) { Entity[] fieldList1 = new Entity[0]; Entity[] fieldList2 = new Entity[0]; if (field1 is EntityCollection ec1) { fieldList1 = ec1.Entities.ToArray(); } else if (field1 is Entity[]) { fieldList1 = (Entity[])field1; } if (field2 is EntityCollection ec2) { fieldList2 = ec2.Entities.ToArray(); } else if (field2 is Entity[]) { fieldList2 = (Entity[])field2; } if (!fieldList1.Any() && !fieldList2.Any()) { return(true); } else if (!fieldList1.Any() || !fieldList2.Any()) { return(false); } else if (fieldList1.Count() != fieldList2.Count()) { return(false); } var entityType = fieldList1.First().LogicalName; if (entityType != Entities.activityparty) { throw new NotImplementedException($"EntityListFieldEqual not implemented for entity type {entityType}"); } var fieldToMatch = new[] { Fields.activityparty_.partyid, Fields.activityparty_.addressused }; foreach (var entity in fieldList1) { var matchingIn1 = fieldList1.Where(e => fieldToMatch.All(f => FieldsEqual(e.GetField(f), entity.GetField(f)))).ToArray(); var matchingIn2 = fieldList2.Where(e => fieldToMatch.All(f => FieldsEqual(e.GetField(f), entity.GetField(f)))).ToArray(); if (matchingIn1.Count() != matchingIn2.Count()) { return(false); } } return(true); }
protected override void UpdateEntity(float dt, Entity entity) { if (entity.Count() == 0) { return; } var direction = entity.Get<Direction>(); var position = entity.Get<Position>(); var input = entity.Get<InputComponent>(); var hotspots = entity.Get<Hotspots>(); float accel = dt * 0.8f; if (input.Right) { direction.X[0] = direction.X[0] + accel * (24.0f - direction.X[0]); } if (input.Left) { direction.X[0] = direction.X[0] + accel * (-24.0f - direction.X[0]); } if (!(input.Left || input.Right)) { if (hotspots.BottomHit[0]) { direction.X[0] = direction.X[0] + dt * (0 - direction.X[0]); } else { direction.X[0] = direction.X[0] + dt * .1f * (0 - direction.X[0]); } } if (input.Jump && hotspots.BottomHit[0]) { if (input.Down) { direction.Y[0] = 1.5f; entity.Transform(0, input.DroppingPlayer); input.DroppingPlayer.Get<TypeChanger>().Transformation = entity; input.DroppingPlayer.Get<TypeChanger>().TTL = 0.8f; } else { direction.Y[0] = -32.0f; } } }
/// <summary> /// Count entities by lambda expression /// </summary> /// <param name="predicate"></param> /// <returns></returns> public int Count(Expression <Func <T, bool> > predicate) { return(Entity.Count(predicate)); }
public int GetCountForAll() { return(Entity.Count()); }
public int GetAllCount() { return(Entity.Count()); }