Beispiel #1
0
        public ResourceHandle <AudioResource> Load(IFile file)
        {
            var key = new Key__(file, null, null);

            if (!resourceMap.TryGetValue(key, out var resourceEntity))
            {
                resourceMap[key] = resourceEntity = World.Mgr.CreateEntity();
                resourceEntity.Set(new AskLoadResource <AudioResource>());
                resourceEntity.Set(new LoadResourceViaFile {
                    File = file
                });
            }

            return(new ResourceHandle <AudioResource>(resourceEntity));
        }
Beispiel #2
0
        public ResourceHandle <AudioResource> Load(string path, IStorage storage)
        {
            var key = new Key__(null, path, storage);

            if (!resourceMap.TryGetValue(key, out var resourceEntity))
            {
                resourceMap[key] = resourceEntity = World.Mgr.CreateEntity();
                resourceEntity.Set(new AskLoadResource <AudioResource>());
                resourceEntity.Set(new LoadResourceViaStorage {
                    Path = path, Storage = storage
                });
            }

            return(new ResourceHandle <AudioResource>(resourceEntity));
        }
        public unsafe void Register(TransportConnection connection, int id, Span <byte> span)
        {
            var key = new Key__(connection, id);

            if (mapped.ContainsKey(key))
            {
                throw new InvalidOperationException("already mapped");
            }

            var wav = new Wav();

            fixed(byte *dataPtr = &span.GetPinnableReference())
            {
                wav.loadMem((IntPtr)dataPtr, (uint)span.Length, aCopy: 1);
            }

            sendAudioResourceData.Send(connection, id, ref wav);

            mapped[key] = wav;
        }
        public Wav GetWav(TransportConnection connection, int id)
        {
            var key = new Key__(connection, id);

            return(mapped[key]);
        }