private void RenderOuterComponent(Entity module, float opacity = 1.0f)
 {
     for (var x = 0; x < module.GetState <PhysicalState>().InternalWidth; x++)
     {
         for (var y = 0; y < module.GetState <PhysicalState>().InternalHeight; y++)
         {
             var grid = new GridCoordinate(x, y);
             var tile = SimplePool.Spawn(Tile);
             //SetOpacity(tile, opacity);
             tile.transform.parent   = outerRendererRoot.transform;
             tile.transform.position = GridCoordinate.GridToPosition(grid);
         }
     }
 }
        private void InitSubstanceTiles()
        {
            foreach (Transform child in substanceRenderRoot.transform)
            {
                SimplePool.Despawn(child.gameObject);
            }

            for (var x = 0; x < GlobalConstants.MaxWidth; x++)
            {
                for (var y = 0; y < GlobalConstants.MaxHeight; y++)
                {
                    var grid           = new GridCoordinate(x, y);
                    var tile           = SimplePool.Spawn(SubstanceTile);
                    var spriteRenderer = tile.GetComponent <SpriteRenderer>();
                    spriteRenderer.enabled  = false;
                    tileGrid[x, y]          = spriteRenderer;
                    tile.transform.parent   = substanceRenderRoot.transform;
                    tile.transform.position = GridCoordinate.GridToPosition(grid);
                }
            }
        }
        private void RenderInnerComponents(Entity entityToRender, float opacity = 1.0f)
        {
            for (var x = 0; x < entityToRender.GetState <PhysicalState>().InternalWidth; x++)
            {
                for (var y = 0; y < entityToRender.GetState <PhysicalState>().InternalHeight; y++)
                {
                    var grid = new GridCoordinate(x, y);

                    Profiler.BeginSample("Get entities at grid");
                    var innerEntities = entityToRender.GetState <PhysicalState>().GetEntitiesAtGrid(grid);
                    Profiler.EndSample();

                    foreach (var innerEntity in innerEntities)
                    {
                        Profiler.BeginSample("Resources Loading");
                        var innerModuleAsset = Resources.Load <GameObject>(innerEntity.GetState <EntityTypeState>().EntityType);
                        Profiler.EndSample();

                        if (innerModuleAsset == null)
                        {
                            UnityEngine.Debug.LogError(innerEntity.GetState <EntityTypeState>().EntityType);
                        }

                        var moduleGameObject = SimplePool.Spawn(innerModuleAsset);
                        //SetOpacity(moduleGameObject, opacity);
                        moduleGameObject.transform.parent   = innerRendererRoot.transform;
                        moduleGameObject.transform.position = GridCoordinate.GridToPosition(grid);
                        var possibleRenderer = moduleGameObject.GetComponent <IEntityRenderer>();
                        if (possibleRenderer != null)
                        {
                            possibleRenderer.OnRenderEntity(innerEntity);
                        }
                    }
                }
            }
        }