public BlockGrid(Transform container, Action destroyCallback, IGridInstance parent) : base(totals: (parent as Ship)?.Totals) { this.container = container; this.destroyCallback = destroyCallback; Parent = parent; Metadata = new BlockGridMetadata(GridMembers); }
public void AttemptRebuild(IGridInstance gridInstance) { var blockGrid = gridInstance.BlockGrid; if (!blockGrid.Any()) { return; } var clusters = GetClusters(gridInstance.BlockGrid); if (clusters.Count() > 1) { Rebuild(gridInstance, clusters); } }
private void Rebuild(IGridInstance gridInstance, IEnumerable <Cluster> clusters) { var blockGrid = gridInstance.BlockGrid; blockGrid.Rebuilding = true; var clustersScheduledForRebuild = clusters.Where(cluster => !cluster.containsController); foreach (var cluster in clustersScheduledForRebuild) { var debris = this.InstantiateAndGet <Debris>(debrisGridPrefab, transform); debris.FromCluster(cluster); debris.Rigidbody2D.velocity = gridInstance.Rigidbody2D.velocity; } blockGrid.Rebuilding = false; blockGrid.DestroyIfEmpty(); }
public void Setup(float animTime, IGridInstance parent, BlockContext damageMask) { this.animTime = animTime; barrelAnimator["BarrelAnimation"].speed = 1f / animTime; firingPoint.Setup(parent, damageMask); }