internal static ResourceManager LoadResourceManager(Type type)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            lock (_resourceManagers)
            {
                var result = _resourceManagers.Find(x => x.Type == type);

                if (result == null)
                {
                    result = new ResourceManagerData()
                    {
                        Type    = type,
                        Manager = new ResourceManager(type),
                    };

                    _resourceManagers.Add(result);
                }

                return(result.Manager);
            }
        }
        internal static ResourceManager LoadResourceManager(string assemblyName, string baseName)
        {
            if (string.IsNullOrEmpty(assemblyName))
            {
                throw new ArgumentNullException("assemblyName");
            }

            if (string.IsNullOrEmpty(baseName))
            {
                throw new ArgumentNullException("baseName");
            }

            var assembly = AppDomain.CurrentDomain.Load(assemblyName);

            lock (_resourceManagers)
            {
                var result = _resourceManagers.Find(x => x.Assembly == assembly && string.Equals(x.BaseName, baseName, StringComparison.CurrentCultureIgnoreCase));

                if (result == null)
                {
                    result = new ResourceManagerData()
                    {
                        Assembly = assembly,
                        BaseName = baseName,
                        Manager  = new ResourceManager(baseName, assembly),
                    };

                    _resourceManagers.Add(result);
                }

                return(result.Manager);
            }
        }
    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    {
        var fieldTransform = FieldObject.transform.localScale;

        var gridCounts = Vector2Int.RoundToInt(new Vector2(fieldTransform.x, fieldTransform.z) / this.ResourceSize);
        var gridSize   = new Vector2(fieldTransform.x / gridCounts.x, fieldTransform.z / gridCounts.y);
        var minGridPos = new Vector2((gridCounts.x - 1f) * -(0.5f * gridSize.x), (gridCounts.y - 1f) * -(0.5f * gridSize.y));

        var resourceManagerData = new ResourceManagerData
        {
            FloorHeight     = -(0.5f * fieldTransform.y),
            ResourceSize    = this.ResourceSize,
            ResourceGravity = this.ResourceGravity,
            SnapStiffness   = this.SnapStiffness,
            CarryStiffness  = this.CarryStiffness,
            SpawnRate       = this.SpawnRate,
            BeesPerResource = this.BeesPerResource,
            GridCounts      = gridCounts,
            GridSize        = gridSize,
            MinGridPos      = minGridPos,
        };

        var resourceMeshData = new RenderMeshInfo()
        {
            Mesh     = this.ResourceMesh,
            Material = this.ResourceMaterial
        };

        var spawnResourceData = new SpawnResourceData
        {
            SpawnCount = StartResourceCount
        };

        dstManager.AddComponentData(entity, resourceManagerData);
        dstManager.AddComponentData(entity, spawnResourceData);
        dstManager.AddSharedComponentData(entity, resourceMeshData);
    }
Example #4
0
        internal static ResourceManager LoadResourceManager(string assemblyName, string baseName)
        {
            if (string.IsNullOrEmpty(assemblyName))
            {
                throw new ArgumentNullException("assemblyName");
            }

            if (string.IsNullOrEmpty(baseName))
            {
                throw new ArgumentNullException("baseName");
            }

            var assembly = AppDomain.CurrentDomain.Load(assemblyName);

            lock (ResourceManagers)
            {
                var result = ResourceManagers.Find(x => x.Assembly == assembly && string.Equals(x.BaseName, baseName, StringComparison.CurrentCultureIgnoreCase));

                if (result == null)
                {
                    result = new ResourceManagerData
                                 {
                        Assembly = assembly,
                        BaseName = baseName,
                        Manager = new ResourceManager(baseName, assembly),
                    };

                    ResourceManagers.Add(result);
                }

                return result.Manager;
            }
        }
Example #5
0
        internal static ResourceManager LoadResourceManager(Type type)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            lock (ResourceManagers)
            {
                var result = ResourceManagers.Find(x => x.Type == type);

                if (result == null)
                {
                    result = new ResourceManagerData
                                 {
                        Type = type,
                        Manager = new ResourceManager(type),
                    };

                    ResourceManagers.Add(result);
                }

                return result.Manager;
            }
        }