public override void Update() { base.Update(); MyCharacterStatComponent statComponent = null; if (MySession.LocalCharacter != null) statComponent = MySession.LocalCharacter.StatComp; if (statComponent != m_statComponent) { m_statComponent = statComponent; m_sortedStats.Clear(); if(m_statComponent != null) { foreach (var stat in m_statComponent.Stats) m_sortedStats.Add(stat); m_sortedStats.Sort((leftStat, rightStat) => { return rightStat.StatDefinition.GuiDef.Priority - leftStat.StatDefinition.GuiDef.Priority; }); } RecreateControls(); } }
public override void Update() { base.Update(); MyCharacterStatComponent statComponent = null; if (MySession.Static.LocalCharacter != null) statComponent = MySession.Static.LocalCharacter.StatComp; if (statComponent != null && statComponent != m_statComponent && statComponent.Stats.Count > 0) // statComponent can be changed during the update, however, it may not be filled up with stats yet in that time.. { m_statComponent = statComponent; m_sortedStats.Clear(); if(m_statComponent != null) { foreach (var stat in m_statComponent.Stats) m_sortedStats.Add(stat); m_sortedStats.Sort((leftStat, rightStat) => { return rightStat.StatDefinition.GuiDef.Priority - leftStat.StatDefinition.GuiDef.Priority; }); } RecreateControls(); } }