void Start() { pool = Contexts.sharedInstance.pool; pool.GetGroup(PoolMatcher.Audio).OnEntityAdded += OnAudioAdded; pool.GetGroup(PoolMatcher.GameOver).OnEntityAdded += (group, entity, index, component) => StopMusic(); }
private async Task ProcessBlockAsync(long height, PoolContext db, CancellationToken cancellationToken) { var period = Period; var oldestHeight = height - period - 1; var accounts = await db.Accounts.Where(i => i.Shares.Any(x => x.BlockId <= height && x.BlockId > oldestHeight) && !i.AverageShareHistory.Any(x => x.Height == height)).Select(i => i.Id).ToListAsync(cancellationToken); int counter = 0; foreach (var account in accounts) { if (await db.AccountAverageShareHistory.AnyAsync(x => x.AccountId == account && x.Height == height, cancellationToken)) { continue; } var shares = await db.Shares.Where(i => i.AccountId == account && i.BlockId <= height && i.BlockId > oldestHeight).Select(i => new { i.BlockId, i.ShareValue }).ToListAsync(cancellationToken); var average = shares.GroupBy(i => i.BlockId).Select(x => x.Max(t => t.ShareValue)).Sum() / period; Logger.LogInformation("Account {accountId}, computed average shares {average} for block {blockHeight}", account, average, height); db.AccountAverageShareHistory.Add(new AccountAverageShareHistory() { AccountId = account, Height = height, AverageShares = average }); counter += 1; // Save every 1000 inserts, to avoid performance hit. if (counter % 1000 == 0) { await db.SaveChangesAsync(cancellationToken); } } await db.SaveChangesAsync(cancellationToken); }
public IActionResult OnPost() { if (!"requestTeam".Equals(action)) { return(OnGet()); } PoolContext dbCtx = new PoolContext(); availableTeams = dbCtx.Teams.OrderBy(t => t.Name).Where(t => !dbCtx.Owners.Select(o => o.TeamId).Contains(t.TeamId)).ToList(); ownerAssignments = dbCtx.Owners.OrderBy(o => o.Username).ToList(); checkCurrentOwnership(dbCtx); String userId = HttpContext.User.FindFirst(ClaimTypes.Name).Value.ToString(); String fullName = findFullName(); if (canRequest) { Team chosenTeam = availableTeams.ToArray()[new Random().Next(availableTeams.Count)]; Owner newOwner = new Owner { Username = userId, Team = chosenTeam, FullName = fullName }; dbCtx.Owners.Add(newOwner); dbCtx.SaveChanges(); } dbCtx.Dispose(); return(OnGet()); }
public static PoolEntity PlayAudio(this PoolContext context, BaseAudioComponent source) { var e = context.CreateEntity(); e.AddAudio(source.clips, source.randomizePitch); return(e); }
public static PoolEntity AddToFoodBag(this PoolContext context, int pointsToAdd) { int existingPoints = context.foodBag.points; context.ReplaceFoodBag(pointsToAdd + existingPoints); return(context.foodBagEntity); }
public static void DestroyEntityIfEmpty(this PoolContext context, PoolEntity entity) { if (entity.GetComponentIndices().Length == 0) { context.DestroyEntity(entity); } }
private void Initializers(PlayerData playerData, PoolContext poolContext, LevelGeneratorData levelGeneratorData) { new PlayerInitializeController(playerData, poolContext.PlayerStartPosition, poolContext); new LevelGeneratorInitializeController(poolContext, levelGeneratorData); new CameraInitializeController(poolContext); new WheelieDetectorInitializeController(poolContext); new PlayerDistanceViewInitializeContoller(poolContext); new PlayerWheelieViewInitializeController(poolContext); }
public TurnSystem(Contexts contexts) : base(contexts.pool) { pool = contexts.pool; turnBasedEntities = pool.GetGroup(PoolMatcher.TurnBased); turnBasedEntities.OnEntityAdded += OnTurnBasedEntityAdded; turnBasedEntities.OnEntityRemoved += OnTurnBasedEntityRemoved; }
private void Controllers(PoolContext poolContext, MainControllers updateController) { updateController.Add(new PlayerInputController(poolContext)); updateController.Add(new LevelGeneratorController(poolContext)); updateController.Add(new CameraController(poolContext)); updateController.Add(new WheelieDetectorController(poolContext)); updateController.Add(new PlayerDistanceView(poolContext)); updateController.Add(new PlayerWheelieView(poolContext)); updateController.Add(new RestartGameEventController(poolContext)); }
public IActionResult OnGet() { PoolContext dbCtx = new PoolContext(); availableTeams = dbCtx.Teams.OrderBy(t => t.Name).Where(t => !dbCtx.Owners.Select(o => o.TeamId).Contains(t.TeamId)).ToList(); ownerAssignments = dbCtx.Owners.Include(o => o.Team).OrderBy(o => o.Username).ToList(); checkCurrentOwnership(dbCtx); dbCtx.Dispose(); return(Page()); }
public static bool IsGameBoardPositionOpen(this PoolContext context, int x, int y, out ICollection <PoolEntity> entities) { var gameBoard = context.gameBoard; bool edge = x == -1 || x == gameBoard.columns || y == -1 || y == gameBoard.rows; if (edge) { entities = null; return(false); } entities = context.gameBoardCache.grid[x, y]; return(entities == null || entities.Empty()); }
public Contexts() { pool = new PoolContext(); var postConstructors = System.Linq.Enumerable.Where( GetType().GetMethods(), method => System.Attribute.IsDefined(method, typeof(Entitas.CodeGeneration.Attributes.PostConstructorAttribute)) ); foreach (var postConstructor in postConstructors) { postConstructor.Invoke(this, null); } }
protected void checkCurrentOwnership(PoolContext dbCtx) { String userId = HttpContext.User.FindFirst(ClaimTypes.Name).Value.ToString(); canRequest = false; myTeam = null; if ((userId != null) && (userId.Length > 0)) { Owner owner = dbCtx.Owners.Include(o => o.Team).Where(o => o.Username.Equals(userId)).DefaultIfEmpty(null).First(); canRequest = owner == null; if (owner != null) { myTeam = owner.Team; } } }
// Use awake to ensure that this fires before the systems boot // otherwise it misses the initial level set void Awake() { levelImage = GetComponent <Image>(); pool = Contexts.sharedInstance.pool; pool.GetGroup(PoolMatcher.Level).OnEntityAdded += (group, entity, index, component) => { currentLevel = pool.level.level; pool.isLevelTransitionDelay = true; Invoke("ShowLevelImage", displayDelay); }; pool.GetGroup(PoolMatcher.GameOver).OnEntityAdded += (group, entity, index, component) => { GameOver(); }; }
public GameBoardCacheSystem(Contexts contexts) { pool = contexts.pool; var gameBoard = pool.GetGroup(PoolMatcher.GameBoard); gameBoard.OnEntityAdded += (group, entity, index, component) => CreateNewGameBoardCache((GameBoardComponent)component); gameBoard.OnEntityUpdated += (group, entity, index, previousComponent, newComponent) => CreateNewGameBoardCache((GameBoardComponent)newComponent); var gameBoardElements = pool.GetGroup(Matcher <PoolEntity> .AllOf( PoolMatcher.GameBoardElement, PoolMatcher.Position)); gameBoardElements.OnEntityAdded += OnGameBoardElementAdded; gameBoardElements.OnEntityUpdated += OnGameBoardElementUpdated; gameBoardElements.OnEntityRemoved += OnGameBoardElementRemoved; }
public CoroutineSystem(Contexts contexts) { pool = contexts.pool; coroutinesGroup = pool.GetGroup(PoolMatcher.Coroutine); }
public CreateGameBoardSystem(Contexts contexts) : base(contexts.pool) { pool = contexts.pool; deleteOnExitGroup = pool.GetGroup(PoolMatcher.DeleteOnExit); }
public DestructibleSystem(Contexts contexts) : base(contexts.pool) { pool = contexts.pool; }
public AIMoveSystem(Contexts contexts) : base(contexts.pool) { pool = contexts.pool; }
public ExitSystem(Contexts contexts) : base(contexts.pool) { pool = contexts.pool; exitGroup = pool.GetGroup(PoolMatcher.Exit); }
public PlayerWheelieView(PoolContext poolContext) { _poolContext = poolContext; _poolContext.WheelieText.text = _displayText; }
public RidershipController(PoolContext context, HttpService httpservice) { dbContext = context; }
public LoginRegController(PoolContext context) { dbContext = context; }
public static bool IsGameBoardPositionOpen(this PoolContext context, PositionComponent position, out ICollection <PoolEntity> entities) { return(context.IsGameBoardPositionOpen(position.x, position.y, out entities)); }
public FoodSystem(Contexts contexts) : base(contexts.pool) { pool = contexts.pool; }
public GameOverSystem(Contexts contexts) : base(contexts.pool) { pool = contexts.pool; }
public InputSystem(Contexts contexts) : base(contexts.pool) { pool = contexts.pool; }
public AddViewSystem(Contexts contexts) : base(contexts.pool) { pool = contexts.pool; }
public AllControllersInitialozator(PlayerData playerData, PoolContext poolContext, MainControllers updateController, LevelGeneratorData levelGeneratorData) { Initializers(playerData, poolContext, levelGeneratorData); Controllers(poolContext, updateController); }
public ProfileController(PoolContext context, HttpService httpservice) { dbContext = context; }