Esempio n. 1
0
    /// <summary>
    /// Creates the lane asset pool.
    /// </summary>
    /// <param name="assetPool">Asset pool.</param>
    /// <param name="laneCount">Lane count.</param>
    private void CreateLaneAssetPool(ref AssetPool <Lane> assetPool, int laneCount, LaneResourceType laneResType)
    {
        // Prepare the pool
        if (assetPool == null)
        {
            // Create a new one if it hasn't been created yet
            assetPool = new AssetPool <Lane>(laneCount);
        }
        else
        {
            // Clear the pool if it already exists
            assetPool.ClearAllAssets();
            assetPool.Resize(laneCount);
        }
        // Populate the pool
        GameObject prefab = m_mapResources.GetLanePrefab(laneResType);

        for (int i = 0; i < laneCount; ++i)
        {
            GameObject newlaneObj = Instantiate <GameObject>(prefab);
            Lane       newLane    = newlaneObj.AddComponentNoDupe <Lane>();
            newLane.Initialize(m_mapManager, m_tileSize, m_activeTileCount, m_edgeTileCount, this);
            newlaneObj.transform.parent = m_lanesRoot;
            newlaneObj.SetActive(false);
            assetPool.AddAsset(newLane);
        }
    }
Esempio n. 2
0
        public void DrawWindow()
        {
            EditorGUILayout.BeginVertical();

            GUILayout.Label("Objects in pool:");

            if (AssetPool.IsPoolingEnabled())
            {
                scrollPos = EditorGUILayout.BeginScrollView(scrollPos);

                foreach (string s in AssetPool.pool.Keys)
                {
                    EditorGUILayout.BeginHorizontal();

                    GUILayout.Label(s + ":");

                    GUILayout.Label(AssetPool.pool[s].Count + " objects in pool.");

                    EditorGUILayout.EndHorizontal();
                }

                EditorGUILayout.EndScrollView();
            }
            else
            {
                GUILayout.Label("Asset pooling is disabled.");
            }

            EditorGUILayout.EndVertical();
        }
        /// <summary>
        /// Returns the default <see cref="AssetPool"/>.  If default is not specified, uses the first available <see cref="AssetPool"/>
        /// that is specified in the System Settings "AssetInventoryPools" setting.
        /// </summary>
        /// <returns></returns>
        public AssetPool GetDefaultAssetPool()
        {
            AssetPool result = null;

            // Return only the pools that match AssetInventoryPools SystemSetting.  Otherwise the asset won't be visible in asset selection.
            string[] fromSettings = GetAssetPoolsFromSettings();

            //If a pool named DEFAULT exists, return it.
            if (fromSettings.Contains("DEFAULT"))
            {
                result = _context.AssetPools.FirstOrDefault(x => x.Name.Equals("DEFAULT"));
                if (result != null)
                {
                    return(result);
                }
            }

            // No AssetPool named "DEFAULT".  Return the first one that matches a settings value
            foreach (string settingName in fromSettings)
            {
                result = _context.AssetPools.FirstOrDefault(x => x.Name.Equals(settingName));
                if (result != null)
                {
                    break;
                }
            }

            return(result);
        }
Esempio n. 4
0
        private List <LuaFileData> FetchFiles(AssetPool luaPoolData)
        {
            var filesList = new List <LuaFileData>();

            for (int i = 0; i < luaPoolData.PoolSize; i++)
            {
                var luaFile = AssetExport.Reader.ReadStruct <LuaFile>(luaPoolData.PoolPointer + (i * luaPoolData.AssetSize));

                if (luaFile.AssetSize == 0 || luaFile.RawDataPtr == 0)
                {
                    continue;
                }

                var name = AssetExport.Reader.ReadNullTerminatedString(luaFile.NamePtr);
                if (!name.EndsWith(".lua"))
                {
                    continue;
                }

                var luaFileData = AssetExport.Reader.ReadBytes(luaFile.RawDataPtr, luaFile.AssetSize);

                filesList.Add(new LuaFileData()
                {
                    Reader = new BinaryReader(new MemoryStream(luaFileData)),
                    Name   = name,
                });
            }

            return(filesList);
        }
Esempio n. 5
0
    /// <summary>
    ///Show the selected block from the blockset
    /// </summary>
    public void Show()
    {
        Hide();

        if (blockSet == null || blockSet.Length <= 0)
        {
            return;
        }

        if (currentBlockIndex >= blockSet.Length)
        {
            currentBlockIndex = 0;
        }

        if (AssetPool.IsPoolingEnabled())
        {
            currentObject = AssetPool.Instantiate(blockSet[currentBlockIndex]);
        }
        else
        {
            currentObject = GameObject.Instantiate(blockSet[currentBlockIndex]) as GameObject;
        }

        currentObject.name = blockSet[currentBlockIndex].name;

        currentObject.transform.parent        = rootObject.transform;
        currentObject.transform.localPosition = offset;
        currentObject.transform.localRotation = Quaternion.Euler(rotation);

        //PREFAB
        //blockSet[currentBlockIndex].SetActiveRecursively(true);
    }
Esempio n. 6
0
        protected override void OnCreate()
        {
            base.OnCreate();

            m_Canvas                      = World.GetOrCreateSystem <ClientCanvasSystem>().CreateCanvas(out _, "UIDrumCanvas", defaultAddRaycaster: false);
            m_Canvas.renderMode           = RenderMode.WorldSpace;
            m_Canvas.transform.localScale = new Vector3() * 0.05f;

            m_CameraQuery = GetEntityQuery(typeof(GameCamera));

            var address = AddressBuilder.Client()
                          .Folder("Models")
                          .Folder("InGame")
                          .Folder("UIDrum")
                          .GetAsset("UIDrumPressure");

            for (var i = 1; i <= 4; i++)
            {
                DrumPresentationPools[i] = new AsyncAssetPool <GameObject>(address);
                DrumBackendPools[i]      = new AssetPool <GameObject>(CreateBackendDrumGameObject, World);
                DrumVariantCount[i]      = 0;
            }

            timeSystem = World.GetExistingSystem <TimeSystem>();

            m_EngineQuery = GetEntityQuery(typeof(RhythmEngineDescription), typeof(Relative <PlayerDescription>));
        }
Esempio n. 7
0
    /// <summary>
    ///Hide this blockset
    /// </summary>
    public void Hide()
    {
        if (currentObject == null)
        {
            return;
        }

        if (rootObject == null)
        {
            return;
        }

        if (AssetPool.IsPoolingEnabled())
        {
            AssetPool.Destroy(currentObject.gameObject);
            currentObject = null;
        }
        else
        {
            if (AssetPool.DestroyImmediate())
            {
                GameObject.DestroyImmediate(currentObject.gameObject);
            }
            else
            {
                GameObject.Destroy(currentObject.gameObject);
            }
            currentObject = null;
        }

        //PREFAB
        //rootObject.SetActiveRecursively(false);
        //rootObject.active = true;
    }
Esempio n. 8
0
    /// <summary>
    /// Creates a item asset pool
    /// </summary>
    /// <param name="assetPool"></param>
    /// <param name="itemCount"></param>
    /// <param name="itemType"></param>
    /// <param name="itemRoot"></param>
    private void CreatPlatformAssetPool(ref AssetPool <Platform> assetPool, int itemCount, MapItemType itemType, Transform itemRoot)
    {
        // Prepare the pool
        if (assetPool == null)
        {
            // Create a new one if it hasn't been created yet
            assetPool = new AssetPool <Platform>(itemCount);
        }
        else
        {
            // Clear the pool if it already exists
            assetPool.ClearAllAssets();
            assetPool.Resize(itemCount);
        }
        // Populate the pool
        GameObject prefab = m_mapResources.GetItemPrefab(itemType);

        for (int i = 0; i < itemCount; ++i)
        {
            GameObject newItem        = Instantiate <GameObject>(prefab);
            Platform   platformScript = newItem.AddComponentNoDupe <Platform>();
            platformScript.Initialize();
            newItem.transform.parent = itemRoot;
            newItem.SetActive(false);
            assetPool.AddAsset(platformScript);
        }
    }
Esempio n. 9
0
    //第二种方案:协程挂起加载
    private T LoadAssetsAsyncByIEnumerator <T>(string sPath, ResType rt, Action <T> fun, bool bInstantiate = false) where T : Object
    {
        string sName = GetAssetName(sPath);

        //正在被加载 还没加载完成
        foreach (AssetInfo item in _listLoading)
        {
            if (item.SName == sName)
            {
                Action <Object> action = o => fun((T)o);
                item.AddListener(action, bInstantiate);
                return(null);
            }
        }

        AssetInfo ai = AssetPool.AssetGet(sName, sPath, (int)rt);

        if (ai != null)
        {
            var obj = (T)ai.Obj;
            return(obj);
        }
        else
        {
            //都没有 先创建
            AssetInfo       asset  = new AssetInfo(sName, sPath, (int)rt, null);
            Action <Object> action = o => fun((T)o); //T 转为Object类型
            asset.AddListener(action, bInstantiate); //添加回调
            _dicLoading.Add(sName, asset);           //缓存
            StartCoroutine(IeLoadAsync(asset));      //挂起
            return(null);
        }
    }
    public void DestroyEntity()
    {
        this.controller.UnSubscribeEntity(this);

        OnDestroyEntity();

        AssetPool.Destroy(gameObject);
    }
Esempio n. 11
0
        private GameObject CreateBackendDrumGameObject(AssetPool <GameObject> poolCaller)
        {
            var go = new GameObject("(Not Init) BackendPressure", typeof(RectTransform), typeof(UIDrumPressureBackend), typeof(GameObjectEntity));

            go.SetActive(false);
            go.GetComponent <UIDrumPressureBackend>().SetRootPool(poolCaller);

            return(go);
        }
Esempio n. 12
0
    private void Awake()
    {
        _assetPool = gameObject.GetComponent <AssetPool>();

        // Set up containers
        _wallsContainer = new GameObject("Walls");
        InteractableObjectsContainer    = new GameObject("InteractableObjects");
        NonInteractableObjectsContainer = new GameObject("NonInteractableObjects");
    }
Esempio n. 13
0
        private void add_Button_Click(object sender, EventArgs e)
        {
            var pool = new AssetPool();

            if (EditEntry(pool) == DialogResult.OK)
            {
                AddPool(pool);
            }
        }
Esempio n. 14
0
    /// <summary>
    /// Sets the block at the target chunk coordinate
    /// </summary>
    /// <param name="x">
    ///The target chunk x coordinate
    /// </param>
    /// <param name="y">
    ///The target chunk y coordinate
    /// </param>
    /// <param name="b">
    ///The block to add to the target chunk coordinate
    /// </param>
    public void SetBlockAt(int x, int y, Block b, bool destroyImmediate)
    {
        if (chunkPieces == null)
        {
            Debug.LogWarning("Block array in chunk: " + this.x + "," + this.y + " has not been initialized.");
            return;
        }

        if (x < 0 || x >= parentMap.chunkWidth)
        {
            Debug.LogWarning("Fundamental mathematics problem attempting to set block " + x + "," + y + " in chunk: " + this.x + "," + this.y);
            return;
        }

        if (y < 0 || y >= parentMap.chunkHeight)
        {
            Debug.LogWarning("Fundamental mathematics problem attempting to set block " + x + "," + y + " in chunk: " + this.x + "," + this.y);
            return;
        }

        int index = y * parentMap.chunkWidth + x;

        if (index >= chunkPieces.Length)
        {
            Debug.LogWarning("Index exceeded array length in chunk: " + x + "," + y + ". Index: " + index + " Length: " + chunkPieces.Length);
            return;
        }

        InitializeBlockPlacement(x, y, b);

        if (chunkPieces[index] != null)
        {
            //Block cb = chunkPieces[index];

            if (AssetPool.IsPoolingEnabled())
            {
                AssetPool.Destroy(chunkPieces[index].gameObject);
                chunkPieces[index] = null;
                //cb = null;
            }
            else
            {
                if (destroyImmediate)
                {
                    GameObject.DestroyImmediate(chunkPieces[index].gameObject);
                    chunkPieces[index] = null;
                }
                else
                {
                    GameObject.Destroy(chunkPieces[index].gameObject);
                    chunkPieces[index] = null;
                }
            }
        }

        chunkPieces[index] = b;
    }
Esempio n. 15
0
 protected override void ApplyMesh()
 {
     if (!this.meshBatch)
     {
         this.meshBatch = AssetPool.Get <UnityEngine.Mesh>();
     }
     this.meshData.Apply(this.meshBatch);
     this.meshBatch.UploadMeshData(false);
 }
 protected override void ApplyMesh()
 {
     if (!this.meshBatch)
     {
         this.meshBatch = AssetPool.Get <UnityEngine.Mesh>();
     }
     this.meshLookup.Apply();
     this.meshData.Apply(this.meshBatch);
 }
Esempio n. 17
0
 protected override void ApplyMesh()
 {
     if (!meshBatch)
     {
         meshBatch = AssetPool.Get <UnityEngine.Mesh>();
     }
     meshLookup.Apply();
     meshData.Apply(meshBatch);
     meshBatch.UploadMeshData(false);
 }
Esempio n. 18
0
 public void Unload()
 {
     if (Running == false)
     {
         AssetPool.Unload();
     }
     else
     {
         throw new InvalidOperationException();
     }
 }
Esempio n. 19
0
        /** 加载一个(计数+1) */
        public static void loadOne(int type, int id, Action overFunc)
        {
            AssetPool pool = _poolArr[type];

            if (pool == null)
            {
                Ctrl.warnLog("未注册AssetPoolType", type);
                return;
            }

            pool.loadOne(id, overFunc);
        }
Esempio n. 20
0
    /// <summary>
    /// Create grass edge items
    /// </summary>
    private void CreateGrassObstacles()
    {
        // TODO: Handle possible special obstacles

        // Compute the maximum number of obstacles
        // [- m_activeLaneCount] accounts for a single-tile open path
        int itemCount = (m_activeLaneCount * m_activeTileCount) - m_activeLaneCount;

        // Prepare the pool
        if (m_grassObstacles == null)
        {
            m_grassObstacles = new AssetPool <Transform>(itemCount);
        }
        else
        {
            m_grassObstacles.ClearAllAssets();
            m_grassObstacles.Resize(itemCount);
        }

        float[] prob =
        {
            m_tallTreeObstacleProb,
            m_mediumTreeObstacleProb,
            m_shortTreeObstacleProb,
            m_treeTrunkObstacleProb,
            m_rockObstacleProb
        };

        // Populate the pool
        for (int i = 0; i < itemCount; ++i)
        {
            // Determine item type based on probability
            float       rand       = Random.value;
            float       cumulative = prob[0];
            MapItemType itemType   = MapItemType.Tree_Tall;
            for (int j = 0; rand > cumulative; ++j)
            {
                if (j + 1 == prob.Length)
                {
                    break;
                }
                cumulative += prob[j + 1];
                itemType    = (MapItemType)((int)itemType + 1);
            }

            // Create a new instance
            GameObject prefab  = m_mapResources.GetItemPrefab(itemType);
            GameObject newItem = Instantiate <GameObject>(prefab);
            newItem.transform.parent = m_grassObstaclesRoot;
            newItem.SetActive(false);
            m_grassObstacles.AddAsset(newItem.transform);
        }
    }
Esempio n. 21
0
        public static void ExportLuaFIles(ProcessReader reader, long assetPoolsAddress, long assetSizesAddress, string gameType)
        {
            // Found the game
            Console.WriteLine("Found supported game: Call of Duty: Black Ops 4");

            // Get Base Address for ASLR and Scans
            long baseAddress = reader.GetBaseAddress();

            // Validate by XModel Name
            if (reader.ReadUInt64(reader.ReadStruct <AssetPool>(baseAddress + assetPoolsAddress + 0x20 * 0x4).PoolPointer) == 0x04647533e968c910)
            {
                AssetPool LuaPoolData = reader.ReadStruct <AssetPool>(baseAddress + assetPoolsAddress + 0x20 * 0x67);

                long address    = LuaPoolData.PoolPointer;
                long endAddress = LuaPoolData.PoolSize * LuaPoolData.AssetSize + address;

                Directory.CreateDirectory("t8_luafiles");
                int filesExported = 0;
                for (int i = 0; i < LuaPoolData.PoolSize; i++)
                {
                    var data = reader.ReadStruct <LuaFile>(address + (i * LuaPoolData.AssetSize));

                    if (data.NullPointer != 0 || data.Hash == 0)
                    {
                        continue;
                    }
                    if (data.Hash >= address && data.Hash <= endAddress)
                    {
                        continue;
                    }

                    filesExported++;
                    var    RawData = reader.ReadBytes(data.startLocation, data.DataSize);
                    ulong  assetHash = (ulong)data.Hash & 0xFFFFFFFFFFFFFFF;
                    string HashString, fileName;
                    //if (!Program.AssetNameCache.Entries.TryGetValue(assetHash, out HashString))
                    fileName = String.Format("t8_luafiles\\LuaFile_{0:x}.lua", assetHash);
                    //else
                    //fileName = String.Format("t8_luafiles\\{0}.lua", HashString);
                    if (File.Exists(fileName) && new FileInfo(fileName).Length == data.DataSize)
                    {
                        continue;
                    }
                    File.WriteAllBytes(fileName, RawData);
                }

                Console.WriteLine("Exported {0} files", filesExported);
            }
            else
            {
                Console.WriteLine("Unsupported version of game found");
            }
        }
Esempio n. 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AssetPoolEditForm"/>
 /// </summary>
 /// <param name="pool">The account pool</param>
 /// <param name="context">The context</param>
 public AssetPoolEditForm(AssetPool pool, AssetInventoryContext context)
 {
     InitializeComponent();
     UserInterfaceStyler.Configure(this, FormStyle.FixedDialog);
     ShowIcon             = true;
     _provider            = new ErrorProvider();
     _provider.BlinkStyle = ErrorBlinkStyle.NeverBlink;
     _provider.SetIconAlignment(poolNameTextBox, ErrorIconAlignment.MiddleLeft);
     _provider.SetIconAlignment(administratorComboBox, ErrorIconAlignment.MiddleLeft);
     _pool    = pool;
     _context = context;
 }
Esempio n. 23
0
        /** 卸载一个(obj可为空)(计数-1) */
        public static void unloadOne(int type, int id, GameObject obj)
        {
            AssetPool pool = _poolArr[type];

            if (pool == null)
            {
                Ctrl.warnLog("未注册AssetPoolType", type);
                return;
            }

            pool.unloadOne(id, obj);
        }
Esempio n. 24
0
        /** 注册一池 */
        public static void registPool(int type, int num, int time)
        {
            AssetPool pool = _poolArr[type];

            if (pool == null)
            {
                _poolArr[type] = pool = new AssetPool();
            }

            pool.keepNum  = num;
            pool.keepTime = time;
        }
Esempio n. 25
0
        /** 获取自定义asset(计数+1) */
        public static GameObject getCustomAsset(int type, int id)
        {
            AssetPool pool = _poolArr[type];

            if (pool == null)
            {
                Ctrl.warnLog("未注册AssetPoolType", type);
                return(null);
            }

            return(pool.getCustomAsset(id));
        }
Esempio n. 26
0
 protected override void OnPooled()
 {
     if ((bool)meshFilter)
     {
         meshFilter.sharedMesh = null;
     }
     if ((bool)meshBatch)
     {
         AssetPool.Free(ref meshBatch);
     }
     meshData.Free();
     meshGroup.Free();
 }
Esempio n. 27
0
 protected override void OnPooled()
 {
     if (this.meshFilter)
     {
         this.meshFilter.sharedMesh = null;
     }
     if (this.meshBatch)
     {
         AssetPool.Free(ref this.meshBatch);
     }
     this.meshData.Free();
     this.meshGroup.Free();
 }
Esempio n. 28
0
    /// <summary>
    /// Creates shared assets
    /// </summary>
    private void CreateSharedAssets()
    {
        // Create coins

        // Prepare the pool
        if (m_coins == null)
        {
            // Create a new one if it hasn't been created yet
            m_coins = new AssetPool <Coin>(m_coinCountMax);
        }
        else
        {
            // Clear the pool if it already exists
            m_coins.ClearAllAssets();
            m_coins.Resize(m_coinCountMax);
        }
        // Populate the pool
        GameObject prefab = m_mapResources.GetCoinPrefab();

        for (int i = 0; i < m_coinCountMax; ++i)
        {
            GameObject coinObj    = Instantiate <GameObject>(prefab);
            Coin       coinScript = coinObj.AddComponentNoDupe <Coin>();
            coinObj.SetActive(false);
            coinObj.transform.parent = m_coinsRoot;
            coinScript.SetCoinRoot(m_coinsRoot);
            coinScript.Initialize();
            m_coins.AddAsset(coinScript);
        }

        // Create the eagle
        if (m_eagle == null)
        {
            prefab = m_mapResources.GetEaglePrefab();
            GameObject eagleObj = Instantiate <GameObject>(prefab);
            m_eagle = eagleObj.AddComponentNoDupe <Eagle>();
            eagleObj.transform.parent = m_sharedItemsRoot;
            eagleObj.SetActive(false);
        }

        // Create the water splash
        if (m_waterSplash == null)
        {
            prefab = m_mapResources.GetWaterSplashPrefab();
            GameObject waterSplashObj = Instantiate <GameObject>(prefab);
            m_waterSplash = waterSplashObj.GetComponent <ParticleSystem>();
            waterSplashObj.transform.parent = m_sharedItemsRoot;
            waterSplashObj.SetActive(false);
        }
    }
    private void Awake()
    {
        pools = new AssetPool();
        if (torpedo)
        {
            pools.CreatePool(TORPEDO_POOL, torpedo.gameObject);
        }

        foreach (var enemy in enemies)
        {
            pools.CreatePool(enemy.GroupId, enemy.gameObject);
        }
        loader = new AsyncLoader(this);
    }
Esempio n. 30
0
        public static void ExportLuaFIles(ProcessReader reader, long assetPoolsAddress, long assetSizesAddress, string gameType)
        {
            // Found the game
            Console.WriteLine("Found supported game: Call of Duty: Black Ops 3");

            // Get Base Address for ASLR and Scans
            long baseAddress = reader.GetBaseAddress();

            // Validate by XModel Name
            if (reader.ReadNullTerminatedString(reader.ReadInt64(reader.ReadInt64(baseAddress + assetPoolsAddress + 0x80))) == "void")
            {
                AssetPool LuaPoolData = reader.ReadStruct <AssetPool>(baseAddress + assetPoolsAddress + 0x20 * 47);

                long address    = LuaPoolData.PoolPointer;
                long endAddress = LuaPoolData.PoolSize * LuaPoolData.AssetSize + address;

                Directory.CreateDirectory("t7_luafiles");
                int filesExported = 0;

                for (int i = 0; i < LuaPoolData.PoolSize; i++)
                {
                    var data = reader.ReadStruct <LuaFile>(address + (i * LuaPoolData.AssetSize));

                    if (!(data.AssetSize != 0))
                    {
                        continue;
                    }

                    filesExported++;
                    var RawData = reader.ReadBytes(data.RawDataPtr, data.AssetSize);

                    string exportName = Path.Combine("t7_luafiles", reader.ReadNullTerminatedString(data.NamePtr));

                    if (Path.GetExtension(exportName) != ".lua" || File.Exists(exportName) && new FileInfo(exportName).Length == data.AssetSize)
                    {
                        continue;
                    }
                    Directory.CreateDirectory(Path.GetDirectoryName(exportName));

                    File.WriteAllBytes(exportName, RawData);
                }

                Console.WriteLine("Exported {0} files", filesExported);
            }
            else
            {
                Console.WriteLine("Unsupported version of game found");
            }
        }
Esempio n. 31
0
 public void Awake() {
     Instance = this;
     _pools = new Dictionary<GameObject, Queue<GameObject>>();
 }