19 #ifndef BUFFABLE_HEADER 20 #define BUFFABLE_HEADER 26 #include <csutil/list.h> 27 #include <csutil/tuple.h> 76 values.PushBack(csTuple2<const ActiveSpell*,T>(NULL, x));
83 return values.Front().second;
88 CS_ASSERT(values.Last().first == NULL);
89 return values.Last().second;
94 CS_ASSERT(values.Last().first == NULL);
96 const T &old = Current();
99 values.PushBack(csTuple2<const ActiveSpell*,T>(NULL, x));
107 const T &old = Current();
109 values.PushFront(csTuple2<const ActiveSpell*,T>(owner, x));
117 const T &old = Current();
119 typename csList< csTuple2<const ActiveSpell*, T> >::Iterator it(values);
122 csTuple2<const ActiveSpell*, T> &curr = it.Next();
123 if(curr.first == owner)
139 csList< csTuple2<const ActiveSpell*, T> >
values;
149 template <
typename T>
186 buffs.Push(csTuple2<const ActiveSpell*,T>(owner, x));
193 bool changed =
false;
196 for(
size_t i = buffs.GetSize() - 1; i != (size_t) -1; i--)
198 if(buffs[i].first == owner)
200 cached -= buffs[i].second;
201 buffs.DeleteIndexFast(i);
218 csArray< csTuple2<const ActiveSpell*, T> >
buffs;
246 buffs.PushBack(csTuple2<const ActiveSpell*, float>(owner, x));
254 csList< csTuple2<const ActiveSpell*, float> >::Iterator it(buffs);
257 csTuple2<const ActiveSpell*, float> &curr = it.Next();
258 if(curr.first == owner)
264 cached *= curr.second;
271 csList< csTuple2<const ActiveSpell*, float> >
buffs;
277 template <
typename T>
285 return cached > 0 ? cached : 0;
csList< csTuple2< const ActiveSpell *, float > > buffs
csList< csTuple2< const ActiveSpell *, T > > values
virtual void Cancel(const ActiveSpell *owner)
virtual void OnChange()
Called whenever the current value changes; implemented in derived classes.
A special form of buffable that is clamped to always return a positive number.
void Buff(const ActiveSpell *owner, T x)
virtual void OnChange()
Called whenever the value changes; implemented in derived classes.
virtual void Cancel(const ActiveSpell *owner)=0
virtual ~iSpellModifier()
void Buff(const ActiveSpell *owner, float x)
csArray< csTuple2< const ActiveSpell *, T > > buffs
void Override(const ActiveSpell *owner, T x)
virtual void Cancel(const ActiveSpell *owner)
virtual void Cancel(const ActiveSpell *owner)