Exemple #1
0
        MessageHandleResult LoginHandler(
            NetConnection connection,
            ByteBuffer byteBuffer,
            NetIncomingMessage message)
        {
            Msg_SC_Login msg = InstancePool.Get <Msg_SC_Login>();

            Msg_SC_Login.GetRootAsMsg_SC_Login(byteBuffer, msg);
            if (!msg.Success)
            {
                GameStateLog.Error("Login failed:" + msg.Error);
                TransitTo <Error>(msg.Error);
            }
            else
            {
                game.id = msg.Id;
                GameStateLog.Info("Login success, game id:" + msg.Id);

                Msg_SC_UpdatePlayers updateplayers = InstancePool.Get <Msg_SC_UpdatePlayers>();
                msg.GetPlayers(updateplayers);
                PlayerManagerClient.Instance.UpdatePlayers(updateplayers);
                GameStateLog.Info("Update players");

                TransitTo <DataFullUpdate>();
            }
            return(MessageHandleResult.Finished);
        }
Exemple #2
0
 protected override void Dispose(bool disposeManagedResources)
 {
     if (disposeManagedResources)
     {
         InstancePool.Dispose();
         base.Dispose(true);
         DisposeCore();
     }
 }
    private void Awake()
    {
        // ランタイムの初期化を行う
        BridgeRuntime.InitializeRuntime();

        // Rust側のインスタンス(RotFerris)を取得する
        unsafe {
            _rustInstance = Internal.new_ferris(InstancePool.AppendInstance(this));
        }
    }
Exemple #4
0
        void ReleasePool(IResourceProvider provider, IResourceLocation location)
        {
            InstancePool pool;

            if (!m_Pools.TryGetValue(location, out pool))
            {
                m_Pools.Add(location, pool = new InstancePool(provider, location));
            }
            pool.holdCount--;
        }
Exemple #5
0
 /// <summary>
 /// 获取mongo单例
 /// </summary>
 /// <param name="url">连接字符串</param>
 /// <param name="database">数据库</param>
 /// <returns></returns>
 public static MongoDbClient GetInstance(string url, string database)
 {
     InstancePool.TryGetValue(url + database, out var instance);
     if (instance is null)
     {
         instance = new MongoDbClient(url, database);
         InstancePool.TryAdd(url + database, instance);
     }
     return(instance);
 }
Exemple #6
0
 static void InstancePoolTest()
 {
     Debug.Assert(InstancePool.Get <PhoneNumber>() != null);
     Debug.Assert(InstancePool.Get <Person>() != null);
     Debug.Assert(InstancePool.Get <AddressBook>() != null);
     Debug.Assert(InstancePool.Get <TestMessage>() != null);
     Debug.Assert(InstancePool.Get <TestMessage2>() != null);
     Debug.Assert(InstancePool.sInstances.Count == 5);
     Console.WriteLine("Instance Pool Checked");
 }
        MessageHandleResult UpdatePlayersHandler(
            NetConnection connection,
            ByteBuffer byteBuffer,
            NetIncomingMessage message)
        {
            Msg_SC_UpdatePlayers updateplayers = InstancePool.Get <Msg_SC_UpdatePlayers>();

            Msg_SC_UpdatePlayers.GetRootAsMsg_SC_UpdatePlayers(byteBuffer, updateplayers);
            UpdatePlayers(updateplayers);
            return(MessageHandleResult.Finished);
        }
        public T Acquire()
        {
            var item = InstancePool.Count > 0 ? InstancePool.Pop() : Constructor.Invoke();

            if (StoresAcquired)
            {
                AcquiredList.Push(item);
            }

            return(item);
        }
Exemple #9
0
        void Parse(TickObject obj, out Vector3 pos, out Quaternion rot)
        {
            Protocol.Kinematics data = InstancePool.Get <Protocol.Kinematics>();
            obj.GetData(data);
            Vec3 vec3 = InstancePool.Get <Vec3>();

            data.GetPos(vec3);
            pos = new Vector3(vec3.X, vec3.Y, vec3.Z);
            data.GetRot(vec3);
            rot = Quaternion.Euler(vec3.X, vec3.Y, vec3.Z);
        }
Exemple #10
0
        /// <summary>
        /// 获取mongo默认单例
        /// </summary>
        /// <param name="database">数据库</param>
        /// <returns></returns>
        public static MongoDbClient GetDefaultInstance(string database)
        {
            string cs = ConfigurationManager.ConnectionStrings["MongoDB"].ConnectionString ?? "mongodb://127.0.0.1:27017";

            InstancePool.TryGetValue(cs + database, out var instance);
            if (instance is null)
            {
                instance = new MongoDbClient(cs, database);
                InstancePool.TryAdd(cs + database, instance);
            }
            return(instance);
        }
Exemple #11
0
        /// <inheritdoc/>
        public bool ReleaseInstance(IResourceProvider loadProvider, IResourceLocation location, Object instance)
        {
            InstancePool pool;

            if (!m_Pools.TryGetValue(location, out pool))
            {
                m_Pools.Add(location, pool = new InstancePool(loadProvider, location));
            }
            pool.holdCount--;
            pool.Put(instance);
            return(false);
        }
Exemple #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SoundEffectInstancePool"/> class.
        /// </summary>
        /// <param name="audioManager">The associated audio manager instance.</param>
        public SoundEffectInstancePool(AudioManager audioManager)
        {
            if (audioManager == null)
            {
                throw new ArgumentNullException("audioManager");
            }

            AudioManager = audioManager;

            sharedVoicePools   = new Dictionary <uint, SourceVoicePool>();
            unsharedVoicePools = new List <SourceVoicePool>();
            instancePool       = new InstancePool();
        }
        public static void ValidateInstancePool(
            InstancePool actual, string name, int vCores, string subnetId, string location, Dictionary <string, string> tags)
        {
            Assert.NotNull(actual);

            Assert.Equal(name, actual.Name);
            Assert.Equal(vCores, actual.VCores);
            Assert.Equal(subnetId, actual.SubnetId);
            SqlManagementTestUtilities.AssertCollection(tags, actual.Tags);

            // Location is being returned two different ways across different APIs.
            Assert.Equal(location.ToLower().Replace(" ", ""), actual.Location.ToLower().Replace(" ", ""));
        }
Exemple #14
0
        MessageHandleResult SnapshotHandler(
            NetConnection connection,
            ByteBuffer byteBuffer,
            NetIncomingMessage message)
        {
            Msg_SC_Snapshot snapshot = InstancePool.Get <Msg_SC_Snapshot>();

            Msg_SC_Snapshot.GetRootAsMsg_SC_Snapshot(byteBuffer, snapshot);
            SyncManagerClient.Instance.FullUpdate(snapshot);
            GameStateLog.Info("apply full update");
            TransitTo <InGame>();

            return(MessageHandleResult.Finished);
        }
Exemple #15
0
 public void UpdateInput(Protocol.Msg_CS_InputDataArray inputDataArray)
 {
     Protocol.InputData inputData = InstancePool.Get <Protocol.InputData>();
     for (int i = 0; i < inputDataArray.InputDataLength; ++i)
     {
         inputDataArray.GetInputData(inputData, i);
         mInputQueue.Enqueue(new InputData()
         {
             index       = inputData.Index,
             keyboard    = inputData.Keyboard,
             mouseHasHit = inputData.MouseHasHit,
             mouseHit    = new Vector3(inputData.MouseHit.X, inputData.MouseHit.Y, inputData.MouseHit.Z),
         });
     }
 }
        MessageHandleResult InputDataArrayHandler(
            NetConnection connection,
            ByteBuffer byteBuffer,
            NetIncomingMessage message)
        {
            Player player = Get(connection);

            if (null != player)
            {
                Msg_CS_InputDataArray ida = InstancePool.Get <Msg_CS_InputDataArray>();
                Msg_CS_InputDataArray.GetRootAsMsg_CS_InputDataArray(byteBuffer, ida);
                player.UpdateInput(ida);
            }
            return(MessageHandleResult.Finished);
        }
        public async Task Delete()
        {
            string       instancePoolName = Recording.GenerateAssetName("instance-pool-");
            var          collection       = _resourceGroup.GetInstancePools();
            InstancePool instancePool     = await CreateInstancePool(instancePoolName);

            var list = await _resourceGroup.GetInstancePools().GetAllAsync().ToEnumerableAsync();

            Assert.AreEqual(1, list.Count);

            await instancePool.DeleteAsync();

            list = await _resourceGroup.GetInstancePools().GetAllAsync().ToEnumerableAsync();

            Assert.AreEqual(0, list.Count);
        }
Exemple #18
0
        void Simulate()
        {
            if (null == mProcessing && mCachedSnapshots.Count < cacheSnapshots)
            {
                return;
            }

            if (null == mProcessing)
            {
                mProcessing = mCachedSnapshots.Dequeue();
            }

            int  simulateCount = 1;
            uint sot           = Game.Instance.snapshotOverTick;

            if (mCachedSnapshots.Count > cacheSnapshots - 1)
            {
                uint k = (uint)mCachedSnapshots.Count;
                uint ticksToSimulate        = (k + 1) * sot - mSimulateTicks;
                uint ticksSupposeToSimulate = cacheSnapshots * sot - mSimulateTicks;
                simulateCount = Mathf.Max(1, Mathf.FloorToInt((float)ticksToSimulate / ticksSupposeToSimulate));
            }

            Msg_SC_Snapshot ss = InstancePool.Get <Msg_SC_Snapshot>();

            Msg_SC_Snapshot.GetRootAsMsg_SC_Snapshot(mProcessing, ss);
            for (int i = 0; i < simulateCount; ++i)
            {
                mServerTick = ss.TickNow - sot + mSimulateTicks;
                float nt = (float)(mSimulateTicks + 1) / sot;
                mTickObjects.Simulate(nt, new TickObjectDictionary.TickObjectEnumerator(ss));
                ++mSimulateTicks;
                ++mServerTick;

                if (mSimulateTicks >= sot)
                {
                    mSimulateTicks = 0;
                    ByteBufferPool.Dealloc(ref mProcessing);
                    if (mCachedSnapshots.Count <= 0)
                    {
                        break;
                    }
                    mProcessing = mCachedSnapshots.Dequeue();
                    Msg_SC_Snapshot.GetRootAsMsg_SC_Snapshot(mProcessing, ss);
                }
            }
        }
Exemple #19
0
        MessageHandleResult ReconnectHandler(
            NetConnection connection,
            ByteBuffer byteBuffer,
            NetIncomingMessage message)
        {
            Msg_SC_Reconnect msg = InstancePool.Get <Msg_SC_Reconnect>();

            Msg_SC_Reconnect.GetRootAsMsg_SC_Reconnect(byteBuffer, msg);
            if (msg.Success)
            {
                TransitTo <DataFullUpdate>();
            }
            else
            {
                TransitTo <Login>();
            }
            return(MessageHandleResult.Finished);
        }
 public AzureSqlInstancePoolModel CreateInstancePoolModelFromResponse(
     InstancePool instancePoolResp)
 {
     return(new AzureSqlInstancePoolModel()
     {
         Edition = instancePoolResp.Sku.Tier,
         ComputeGeneration = instancePoolResp.Sku.Family,
         InstancePoolName = instancePoolResp.Name,
         Location = instancePoolResp.Location,
         ResourceGroupName = new ResourceIdentifier(instancePoolResp.Id).ResourceGroupName,
         Id = instancePoolResp.Id,
         SubnetId = instancePoolResp.SubnetId,
         Tags = TagsConversionHelper.CreateTagDictionary(TagsConversionHelper.CreateTagHashtable(instancePoolResp.Tags), false),
         Type = instancePoolResp.Type,
         VCores = instancePoolResp.VCores,
         LicenseType = instancePoolResp.LicenseType,
         Sku = instancePoolResp.Sku,
     });
 }
Exemple #21
0
        MessageHandleResult SnapshotHandler(
            NetConnection connection,
            ByteBuffer byteBuffer,
            NetIncomingMessage message)
        {
            Msg_SC_Snapshot snapshot = InstancePool.Get <Msg_SC_Snapshot>();

            Msg_SC_Snapshot.GetRootAsMsg_SC_Snapshot(byteBuffer, snapshot);
            if (snapshot.Full)
            {
                SyncManagerClient.Instance.FullUpdate(snapshot);
                return(MessageHandleResult.Finished);
            }
            else
            {
                SyncManagerClient.Instance.AddDelta(snapshot.TickNow, byteBuffer, message);
                return(MessageHandleResult.Processing);
            }
        }
        /// <summary>
        /// Creates an instance of a LoginServerManager.
        /// </summary>
        public LoginServerManager()
        {
            Active = true;

            // Init instance pools
            Trace.WriteLine("Init instance pools.");
            Trace.Indent();

            InstancePool = new InstancePool();

            Trace.Unindent();
            Trace.WriteLine("End instance pools.");

            // Init datastructures
            ClientsQueuedForGame = new Queue <Client>();

            // Init Networking
            NetworkManager = new NetworkManager();
            NetworkManager.OnClientConnect += HandleClientConnect;
        }
Exemple #23
0
        /// <inheritdoc/>
        public IAsyncOperation <TObject> ProvideInstanceAsync <TObject>(IResourceProvider loadProvider, IResourceLocation location, IAsyncOperation <IList <object> > loadDependencyOperation, InstantiationParameters instantiateParameters) where TObject : Object
        {
            if (location == null)
            {
                throw new ArgumentNullException("location");
            }
            if (loadProvider == null)
            {
                throw new ArgumentNullException("loadProvider");
            }
            InstancePool pool;

            if (!m_Pools.TryGetValue(location, out pool))
            {
                m_Pools.Add(location, pool = new InstancePool(loadProvider, location));
            }

            pool.holdCount++;
            return(pool.ProvideInstanceAsync <TObject>(loadProvider, loadDependencyOperation, instantiateParameters));
        }
Exemple #24
0
        public void AddDelta(uint tick, ByteBuffer byteBuffer, NetIncomingMessage msg)
        {
            if (!mHasFullUpdated || tick <= mServerTick)
            {
                TCLog.WarnFormat("drop delta update, hasFullUpdated:{0}, tick:{1}, current serverTick:{2}", mHasFullUpdated, tick, mServerTick);
            }
            else
            {
                mCachedSnapshots.Enqueue(byteBuffer);
                int choke = msg.ReadInt32();
                InputManager.Instance.UpdateChoke(choke);
                for (int i = 0; i < Game.Instance.snapshotOverTick; ++i)
                {
                    InputManager.Instance.AckInput(msg.ReadUInt32());
                }

                Msg_SC_Snapshot snapshot = InstancePool.Get <Msg_SC_Snapshot>();
                Msg_SC_Snapshot.GetRootAsMsg_SC_Snapshot(byteBuffer, snapshot);
                mTickObjects.ApplyDeltaForPredict(new TickObjectDictionary.TickObjectEnumerator(snapshot));
            }
        }
Exemple #25
0
    private object _InvokeRustFunction(string methodName, params object[] args)
    {
        // Rust側のインスタンスの関数を呼び出す
        var methodName1 = System.Text.Encoding.UTF8.GetBytes(methodName);
        var args1       = args.Select(InstancePool.AppendInstance)
                          .ToArray();

        unsafe
        {
            fixed(UInt64 *a = args1)
            fixed(byte *b = methodName1)
            {
                var res = Internal.unibridge_invoke(_rustInstance,
                                                    new Slice <char>((char *)b, (UIntPtr)methodName1.Length),
                                                    new Slice <UInt64>(a, (UIntPtr)args1.Length));

                var res1 = InstancePool.GetInstance(res);

                InstancePool.DisposeInstance(res);

                return(res1);
            }
        }
    }
Exemple #26
0
    static void FB_Deserialize(ByteBuffer byteBuffer)
    {
        AddressBook addressBookInst = InstancePool.Get <AddressBook>();
        Person      personInst      = InstancePool.Get <Person>();
        PhoneNumber phoneNumberInst = InstancePool.Get <PhoneNumber>();

        AddressBook addressBook = AddressBook.GetRootAsAddressBook(byteBuffer, addressBookInst);
        int         plen        = addressBook.PeopleLength;

        for (int p = 0; p < plen; ++p)
        {
            Person person = addressBook.GetPeople(personInst, p);
            Debug.Assert(0 == string.Compare(person.Name, personName + p));
            Debug.Assert(person.Id == p);
            Debug.Assert(0 == string.Compare(person.Email, string.Format("{0}{1}@gmail.com", personName, p)));
            int len = person.PhonesLength;
            for (int n = 0; n < len; ++n)
            {
                PhoneNumber pn = person.GetPhones(phoneNumberInst, n);
                Debug.Assert(0 == string.Compare(pn.Number, (p * 100 + n).ToString()));
                Debug.Assert(pn.Type == (PhoneType)(n % 3));
            }
        }
    }
Exemple #27
0
 public void Free()
 {
     Timer = null;
     InstancePool.Enqueue(this);
 }
Exemple #28
0
    private void Awake()
    {
        particles_ = particlesSetup.Finalise<Particle>(sort: false);

        prev = Camera.main.ScreenToWorldPoint(Input.mousePosition);
    }
Exemple #29
0
 public void Free(T item)
 {
     InstancePool.Push(item);
 }
 private void Start()
 {
     scenes = scenesSetup.FinaliseMono<Scene, SceneToggle>();
 }
 private void Awake()
 {
     palette = paletteSetup.FinaliseMono<Tile, TileToggle>();
     browser = browserSetup.FinaliseMono<Tile, TileToggle>();
 }
Exemple #32
0
 public void FullUpdate(TickObject obj)
 {
     Protocol.Avatar data = InstancePool.Get <Protocol.Avatar>();
     obj.GetData(data);
     mCommon.color = (new Color()).FromInt(data.Color);
 }
 public InstancePoolInfoImpl(InstancePool <TInstance> pool, Type generatedType, TypeGenerationResult typeGenerationResult)
 {
     this._pool                 = pool;
     this._generatedType        = generatedType;
     this._typeGenerationResult = typeGenerationResult;
 }
Exemple #34
0
    private void SetupEditor()
    {
        SetupCommon();

        hud.mode = HUD.Mode.Draw;

        borderSprite0 = TextureByte.Pooler.Instance.GetSprite(40, 40, IntVector2.one * 20);
        borderSprite1 = TextureByte.Pooler.Instance.GetSprite(40, 40, IntVector2.one * 20);
        brushSpriteD = new TextureByte(64, 64).FullSprite(IntVector2.one * 32);

        stampsp = new InstancePool<Stamp>(stampPrefab, stampParent);

        foreach (var sprite in testbrushes)
        {
            int width  = (int) sprite.rect.width;
            int height = (int) sprite.rect.height;

            var tex = new TextureByte(width, height);
            tex.SetPixels(sprite.GetPixels().Select(c => ((Color32) c).a).ToArray());
            tex.Apply();

            stamps.Add(new Stamp
            {
                brush = tex.FullSprite(sprite.pivot),
                thumbnail = sprite,
            });
        }

        stampsp.SetActive(stamps);
        SetStamp(stamps[0]);
        drawHUD.OnPaletteIndexSelected += i => RefreshBrushCursor();

        {
            test = new TextureByte(128, 128);
            test.Clear(0);

            var pixels = costumeTexture.GetPixels32();
            for (int i = 0; i < pixels.Length; ++i)
            {
                byte value = 0;

                if (pixels[i] == Color.white) value = 1;
                if (pixels[i] == Color.black) value = 2;

                test.pixels[i] = value;
            }

            test.Apply();
            test.uTexture.name = "Costume Texture";
        }

        //TestScripts();
    }
 private void Awake()
 {
     actorViews = actorsSetup.Finalise<Actor>(sort: false);
 }