Пример #1
0
        public static void Insert(this NumericComponent self, int numericType, long value, bool isPublicEvent = true)
        {
            long oldValue = self.GetByKey(numericType);

            if (oldValue == value)
            {
                return;
            }

            self.NumericDic[numericType] = value;

            if (numericType >= NumericType.Max)
            {
                self.Update(numericType, isPublicEvent);
                return;
            }

            if (isPublicEvent)
            {
                Game.EventSystem.Publish(self.DomainScene(),
                                         new EventType.NumbericChange()
                {
                    Unit = self.GetParent <Unit>(), New = value, Old = oldValue, NumericType = numericType
                });
            }
        }
Пример #2
0
        public static void Insert(this NumericComponent self, int numericType, long value, bool isPublicEvent = true)
        {
            long oldValue = self.GetByKey(numericType);

            if (oldValue == value)
            {
                return;
            }

            self.NumericDic[numericType] = value;

            if (numericType >= NumericType.Max)
            {
                self.Update(numericType, isPublicEvent);
                return;
            }

            if (isPublicEvent)
            {
                EventType.NumbericChange args = EventType.NumbericChange.Instance;
                args.Parent      = self.Parent;
                args.NumericType = numericType;
                args.Old         = oldValue;
                args.New         = value;
                Game.EventSystem.PublishClass(args);
            }
        }