public static SkBuffInst Mount(SkPackage buffPak, SkBuffInst inst) { if (inst == null) { return(null); } int id = inst._buff._id; int type = inst._buff._type; int prior = inst._buff._priority; int maxStack = inst._buff._stackLimit; List <SkBuffInst> stackBuffs = buffPak._buffs.FindAll((SkBuffInst it) => it._buff._id == id); if (stackBuffs.Count == 0) { if (buffPak._buffs.Exists((SkBuffInst it) => (it._buff._type == type && it._buff._priority > prior))) { return(null); // Failed to add this buff because there are hi-prior buff(s) } // Unmount lo-prior buffs Unmount(buffPak, (SkBuffInst it) => (it._buff._type == type && it._buff._priority < prior)); } else if (stackBuffs.Count >= maxStack) { // Unmount same id buffs to fit stack limit Unmount(buffPak, stackBuffs[0]); } buffPak._buffs.Add(inst); return(inst); }
public SkAttribs(ISkEntity ent, List <int> idxList, List <float> valList) { _entity = ent; _expFunc = new ExpFuncSet(this); int maxIdx = 0; int cnt = idxList.Count; for (int j = 0; j < cnt; j++) { if (idxList[j] > maxIdx) { maxIdx = idxList[j]; } } _nAttribs = maxIdx + 1; _dirties = new ModFlags(_nAttribs); _raws = new NumList(_nAttribs, (n, i, v) => RawSetter(i, v)); _sums = new NumList(_nAttribs, (n, i, v) => SumSetter(i, v)); _pack = new SkPackage(this); for (int j = 0; j < cnt; j++) { int idx = idxList[j]; _sums[idx] = _raws[idx] = valList[j]; } AddToSendDValue(Pathea.AttribType.Hp); }
public static void Unmount(SkPackage buffPak, SkBuffInst inst, bool force = true) { bool ret = inst.OnDiscard(buffPak._parentAttribs); if (ret || force) { buffPak._buffs.Remove(inst); } }
public static void Unmount(SkPackage buffPak, System.Predicate <SkBuffInst> match) { for (int i = buffPak._buffs.Count - 1; i >= 0; i--) { if (match(buffPak._buffs[i])) { Unmount(buffPak, buffPak._buffs[i]); } } }
public SkAttribs(ISkEntity ent, int nAttribs) { _entity = ent; _expFunc = new ExpFuncSet(this); _nAttribs = nAttribs; _dirties = new ModFlags(nAttribs); _raws = new NumList(nAttribs, (n, i, v) => RawSetter(i, v)); _sums = new NumList(nAttribs, (n, i, v) => SumSetter(i, v)); _pack = new SkPackage(this); AddToSendDValue(Pathea.AttribType.Hp); }
public SkAttribs(ISkEntity ent, SkAttribs baseAttribs, bool[] masks) { _entity = ent; _expFunc = new ExpFuncSet(this); int nAttribs = baseAttribs._raws.Count; _nAttribs = nAttribs; _dirties = new ModFlags(nAttribs); _raws = new NumListWithParent(baseAttribs._raws as NumList, masks, nAttribs, (n, i, v) => RawSetter(i, v)); _sums = new NumListWithParent(baseAttribs._sums as NumList, masks, nAttribs, (n, i, v) => SumSetter(i, v)); _pack = new SkPackage(this); AddToSendDValue(Pathea.AttribType.Hp); }
public SkBuffInst GetSkBuffInst(int id) { SkPackage pack = _attribs.pack as SkPackage; if (pack != null) { for (int i = 0; i < pack._buffs.Count; i++) { if (pack._buffs[i]._buff._id == id) { return(pack._buffs[i]); } } // return pack._buffs.Find((inst)=>{ return inst._buff._id==id; }); } return(null); }
// Get first matched buff public static SkBuffInst GetBuff(SkPackage buffPak, Func <SkBuffInst, bool> match) { return(buffPak._buffs.Find((SkBuffInst inst) => match(inst))); }