Ejemplo n.º 1
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>));
        }
        public EntityVisualDefinition Register(AssetPath assetPath)
        {
            if (m_DefinitionByAddress.TryGetValue(assetPath, out var definition))
            {
                return new EntityVisualDefinition {
                           PoolId = definition
                }
            }
            ;

            var index = (uint)(m_DefinitionByAddress.Count + 1);

            m_DefinitionByAddress[assetPath] = index;
            m_PoolByDefinition[index]        = new AsyncAssetPool <GameObject>(assetPath);

            return(new EntityVisualDefinition
            {
                PoolId = index
            });
        }
        public EntityVisualDefinition Register(GameObject prefab)
        {
            AssetPath assetPath = ("internal", prefab.GetInstanceID().ToString());

            if (m_DefinitionByAddress.TryGetValue(assetPath, out var definition))
            {
                return new EntityVisualDefinition {
                           PoolId = definition
                }
            }
            ;

            var index = (uint)(m_DefinitionByAddress.Count + 1);

            m_DefinitionByAddress[assetPath] = index;
            m_PoolByDefinition[index]        = new AsyncAssetPool <GameObject>(prefab);

            return(new EntityVisualDefinition
            {
                PoolId = index
            });
        }
        private bool tryGet(string archetype, string kit, out AsyncAssetPool <GameObject> pool)
        {
            ResPath.Inspection archInspect, kitInspect;
            try
            {
                archInspect = ResPath.Inspect(archetype);
                kitInspect  = ResPath.Inspect(kit);
            }
            catch (InvalidOperationException ex)             // catch parse error
            {
                pool = null;
                return(false);
            }

            pool = null;
            if (!m_PoolByArchetype.TryGetValue(archInspect.ResourcePath, out var kitMap))
            {
                return(false);
            }

            return(kitMap.TryGetValue(kitInspect.ResourcePath, out pool));
        }
 public bool TryGetArchetypePool(string archetype, string kit, out AsyncAssetPool <GameObject> pool)
 {
     return(tryGet(archetype, kit, out pool) || tryGet(archetype, string.Empty, out pool));
 }
 public bool TryGetPool(string archetype, out AsyncAssetPool <GameObject> pool)
 {
     return(m_PoolByArchetype.TryGetValue(new ResPath(archetype), out pool));
 }
 public void AddPool(string masterserverId, AsyncAssetPool <GameObject> pool)
 {
     Debug.Log($"adding {masterserverId} -> {pool.AssetPath}");
     m_PoolByArchetype[new ResPath(masterserverId)] = pool;
 }