예제 #1
0
        public override void AddComponent(IComponent c)
        {
            base.AddComponent(c);
            ServerCharacterComponent com = c as ServerCharacterComponent;

            if (com != null)
            {
                Stats.UpdateWithValues(com.AddedStats);

                if (com.AddedProperties != null)
                {
                    // initial copy of properties
                    Properties.UpdateWithValues(com.AddedProperties);

                    // be notified of future updates. Two-way binding
                    com.AddedProperties.SubscribeToChangeNotifications(this);
                    Properties.SubscribeToChangeNotifications(com);
                }

                if (com.AddedStats != null)
                {
                    // initial copy of properties
                    Stats.UpdateWithValues(com.AddedStats);

                    // be notified of future updates. Two-way binding.
                    com.AddedStats.SubscribeToChangeNotifications(this);
                    Stats.SubscribeToChangeNotifications(com);
                }
            }
        }
예제 #2
0
        public override void RemoveComponent(IComponent c)
        {
            base.RemoveComponent(c);
            ServerCharacterComponent com = c as ServerCharacterComponent;

            if (com != null)
            {
                com.AddedStats.UnSubscribeToChangeNotifications(this);
                com.AddedProperties.UnSubscribeToChangeNotifications(this);

                if (Components.Count < 1)
                {
                    Properties.UnSubscribeToChangeNotifications(com);
                    Stats.UnSubscribeToChangeNotifications(com);
                }

                Stats.RemoveStats(com.AddedStats);
                Properties.RemoveProperties(com.AddedProperties);
            }
        }