Exemplo n.º 1
0
 // Token: 0x06001CE1 RID: 7393 RVA: 0x0007BB40 File Offset: 0x00079D40
 private static void ProcessCharacterUpdateEvents()
 {
     while (StatManager.characterUpdateEvents.Count > 0)
     {
         StatManager.CharacterUpdateEvent characterUpdateEvent = StatManager.characterUpdateEvents.Dequeue();
         if (characterUpdateEvent.statsComponent)
         {
             StatSheet currentStats = characterUpdateEvent.statsComponent.currentStats;
             if (currentStats != null)
             {
                 CharacterBody body = characterUpdateEvent.statsComponent.characterMaster.GetBody();
                 int           num  = (body != null) ? body.bodyIndex : -1;
                 currentStats.PushStatValue(StatDef.totalTimeAlive, (double)characterUpdateEvent.additionalTimeAlive);
                 currentStats.PushStatValue(StatDef.highestLevel, (ulong)((long)characterUpdateEvent.level));
                 currentStats.PushStatValue(StatDef.totalDistanceTraveled, (double)characterUpdateEvent.additionalDistanceTraveled);
                 if (num != -1)
                 {
                     currentStats.PushStatValue(PerBodyStatDef.totalTimeAlive, num, (double)characterUpdateEvent.additionalTimeAlive);
                     currentStats.PushStatValue(PerBodyStatDef.longestRun, num, (double)characterUpdateEvent.runTime);
                 }
                 EquipmentIndex currentEquipmentIndex = characterUpdateEvent.statsComponent.characterMaster.inventory.currentEquipmentIndex;
                 if (currentEquipmentIndex != EquipmentIndex.None)
                 {
                     currentStats.PushStatValue(PerEquipmentStatDef.totalTimeHeld.FindStatDef(currentEquipmentIndex), (double)characterUpdateEvent.additionalTimeAlive);
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
        private void ServerFixedUpdate()
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.Stats.PlayerStatsComponent::ServerFixedUpdate()' called on client");
                return;
            }
            float num     = 0f;
            float runTime = 0f;

            if (Run.instance && !Run.instance.isRunStopwatchPaused)
            {
                num     = Time.fixedDeltaTime;
                runTime = Run.instance.GetRunStopwatch();
            }
            StatManager.CharacterUpdateEvent e = default(StatManager.CharacterUpdateEvent);
            e.statsComponent = this;
            e.runTime        = runTime;
            GameObject bodyObject = this.characterMaster.GetBodyObject();

            if (bodyObject != this.cachedBodyObject)
            {
                this.cachedBodyObject    = bodyObject;
                this.cachedBodyObject    = bodyObject;
                this.cachedBodyTransform = ((bodyObject != null) ? bodyObject.transform : null);
                if (this.cachedBodyTransform)
                {
                    this.previousBodyPosition = this.cachedBodyTransform.position;
                }
                this.cachedCharacterBody      = ((bodyObject != null) ? bodyObject.GetComponent <CharacterBody>() : null);
                this.cachedBodyCharacterMotor = ((bodyObject != null) ? bodyObject.GetComponent <CharacterMotor>() : null);
            }
            if (this.cachedBodyTransform)
            {
                Vector3 position = this.cachedBodyTransform.position;
                e.additionalDistanceTraveled = Vector3.Distance(position, this.previousBodyPosition);
                this.previousBodyPosition    = position;
            }
            if (this.characterMaster.alive)
            {
                e.additionalTimeAlive += num;
            }
            if (this.cachedCharacterBody)
            {
                e.level = (int)this.cachedCharacterBody.level;
            }
            StatManager.PushCharacterUpdateEvent(e);
            this.serverTransmitTimer -= Time.fixedDeltaTime;
            if (this.serverTransmitTimer <= 0f)
            {
                this.serverTransmitTimer = this.serverTransmitInterval;
                this.SendUpdateToClient();
            }
        }
 // Token: 0x06001D01 RID: 7425 RVA: 0x00087354 File Offset: 0x00085554
 public static void PushCharacterUpdateEvent(StatManager.CharacterUpdateEvent e)
 {
     StatManager.characterUpdateEvents.Enqueue(e);
 }