Exemplo n.º 1
0
    public override MomentSingletonComponent DeepCopy()
    {
        TestSingleComponent tc = new TestSingleComponent();

        tc.testValue = testValue;

        return(tc);
    }
Exemplo n.º 2
0
    public override MomentSingletonComponent DeepCopy()
    {
        TestSingleComponent tc = HeapObjectPool <TestSingleComponent> .GetObject();// new TestSingleComponent();

        tc.testValue = testValue;

        return(tc);
    }
        public void SingleComponentValueRollbackTest()
        {
            ResourcesConfigManager.Initialize();
            WorldManager.IntervalTime = 100;

            LockStepEntityTestWorld world = (LockStepEntityTestWorld)WorldManager.CreateWorld <LockStepEntityTestWorld>();

            world.IsClient = true;
            world.IsStart  = true;
            world.IsLocal  = true;

            ConnectStatusComponent csc = world.GetSingletonComp <ConnectStatusComponent>();

            csc.confirmFrame = 0; //从目标帧之后开始计算

            SelfComponent sc = new SelfComponent();

            /*EntityBase c1 =*/ world.CreateEntityImmediately("1", sc);

            world.CallRecalc();
            world.FixedLoop(WorldManager.IntervalTime);

            TestSingleComponent tc = world.GetSingletonComp <TestSingleComponent>();

            Assert.AreEqual(0, tc.testValue);

            TestCommandComponent cmd = new TestCommandComponent();

            cmd.frame  = 1;
            cmd.id     = 1;
            cmd.isFire = true;
            GlobalEvent.DispatchTypeEvent(cmd);

            world.CallRecalc();
            world.FixedLoop(WorldManager.IntervalTime);

            tc = world.GetSingletonComp <TestSingleComponent>();
            Assert.AreEqual(1, tc.testValue);

            world.CallRecalc();
            world.FixedLoop(WorldManager.IntervalTime);

            tc = world.GetSingletonComp <TestSingleComponent>();
            Assert.AreEqual(1, tc.testValue);

            cmd        = new TestCommandComponent();
            cmd.frame  = 2;
            cmd.id     = 1;
            cmd.isFire = true;
            GlobalEvent.DispatchTypeEvent(cmd);

            world.CallRecalc();
            world.FixedLoop(WorldManager.IntervalTime);

            tc = world.GetSingletonComp <TestSingleComponent>();
            Assert.AreEqual(2, tc.testValue);
        }
    public override void FixedUpdate(int deltaTime)
    {
        List <EntityBase> list = GetEntityList();

        for (int i = 0; i < list.Count; i++)
        {
            TestCommandComponent cc = list[i].GetComp <TestCommandComponent>();
            if (cc.isFire)
            {
                //Debug.Log("Fire " + m_world.FrameCount);

                TestSingleComponent tc = m_world.GetSingletonComp <TestSingleComponent>();
                tc.testValue++;

                TestLifeSpanComponent lsc = new TestLifeSpanComponent();
                lsc.lifeTime = 500;

                m_world.CreateEntity("FireObject" + cc.Entity.ID, lsc);
            }
        }
    }