// mount/unmount buff public static SkBuffInst MountBuff(SkEntity target, int buffId, List <int> idxList, List <float> valList) // To save memory ,idxList should be increase step by step { int maxIdx = 0; int n = idxList != null ? idxList.Count : 0; for (int i = 0; i < n; i++) { if (idxList[i] > maxIdx) { maxIdx = idxList[i]; } } SkAttribs buffAttribs = new SkAttribs(null, maxIdx + 1); for (int i = 0; i < n; i++) { int idx = idxList[i]; buffAttribs.sums[idx] = buffAttribs.raws[idx] = valList[i]; } //lz-2016.08.22 引导检测玩家进入buff Pathea.PeEntity entity = target.GetComponent <Pathea.PeEntity>(); if (null != entity && entity.IsMainPlayer) { InGameAidData.CheckInBuff(buffId); } return(SkBuffInst.Mount(target._attribs.pack as SkPackage, SkBuffInst.Create(buffId, buffAttribs, target._attribs))); }
public void Compile() { int t = Environment.TickCount; #if DBG_ExpEvaluate //var method = Mono.CSharp.Evaluator.Compile("System.Console.WriteLine(\"dynamic compiled\");"); // or with return value. var method = Mono.CSharp.Evaluator.Compile("new System.Action<ISkAttribs, ISkAttribs, ISkAttribsModPara>((caster, target, para) => {" + "caster.raws[0] += target.sums[0];" + // "caster.sums[0] += target.raws[0];" + // "caster.raws[1] += target.sums[1];" + // "caster.sums[1] += target.raws[1];" + //"caster.pack += 12;" + // "caster.mask[0] = true;" + "});"); object value = null; method(ref value); bool[] masks = new bool[32]; masks[0] = true; masks[1] = false; SkAttribs casterBaseAttrib = new SkAttribs(); SkAttribs caster = new SkAttribs(casterBaseAttrib, masks); SkAttribs targetBaseAttrib = new SkAttribs(); SkAttribs target = new SkAttribs(casterBaseAttrib, masks); System.Action <ISkAttribs, ISkAttribs, ISkAttribs> action = value as System.Action <ISkAttribs, ISkAttribs, ISkAttribsModPara>; action(caster, target, null); #elif CompileOnce4ActionArray string allprogs = "new System.Action<ISkAttribs, ISkAttribs, ISkAttribsModPara>[]{"; for (int i = 0; i < _progs.Count; i++) { allprogs += _progs[i]; } allprogs += "};"; var method = Mono.CSharp.Evaluator.Compile(allprogs); object allActions = null; method(ref allActions); System.Action <ISkAttribs, ISkAttribs, ISkAttribsModPara>[] actions = allActions as System.Action <ISkAttribs, ISkAttribs, ISkAttribsModPara>[]; for (int i = 0; i < _reqers.Count; i++) { _reqers[i].OnCompiled(actions[i]); } #else for (int i = 0; i < _reqers.Count; i++) { var method = Mono.CSharp.Evaluator.Compile(_progs[i]); object action = null; method(ref action); _reqers[i].OnCompiled((System.Action <ISkAttribs, ISkAttribs, ISkAttribsModPara>)action); //System.Action<ISkAttribs, ISkAttribs, ISkAttribsModPara> action = (System.Action<ISkAttribs, ISkAttribs, ISkAttribsModPara>)Mono.CSharp.Evaluator.Evaluate(_progs[i]); //_reqer[i].OnCompiled(action); } #endif _reqers.Clear(); _progs.Clear(); Debug.Log("[EXP]All Compiled:" + (Environment.TickCount - t)); }
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 void Init(SkAttribs attribs, Action <int, float, float> onAlterAttribs, Action <List <ItemToPack> > onPutinPackage) { _attribs = attribs; SkEntityAttribsUpdater.Instance.Register(this); if (onAlterAttribs != null) { _attribs._OnAlterNumAttribs += onAlterAttribs; } if (onPutinPackage != null) { _attribs._OnPutInPakAttribs += onPutinPackage; } //for net _attribs._OnAlterNumAttribs += OnNetAlterAttribs; }
public void Init(Action <int, float, float> onAlterAttribs, Action <List <ItemToPack> > onPutinPackage, SkEntity parent, bool[] useParentMasks) { _attribs = new SkAttribs(this, parent._attribs, useParentMasks); SkEntityAttribsUpdater.Instance.Register(this); if (onAlterAttribs != null) { _attribs._OnAlterNumAttribs += onAlterAttribs; } if (onPutinPackage != null) { _attribs._OnPutInPakAttribs += onPutinPackage; } //for net _attribs._OnAlterNumAttribs += OnNetAlterAttribs; }
public void Compile() { int t = Environment.TickCount; #if DBG_ExpCompile _srcCode = "public static class Func0{ public static void func(ISkAttribs caster, ISkAttribs target, ISkAttribsModPara para){ " + "caster.raws[0] += target.sums[0];" + "caster.sums[0] += target.raws[0];" + "caster.raws[1] += target.sums[1];" + "caster.sums[1] += target.raws[1];" + //"caster.pack += 12;" + "caster.mask[0] = true;" + "}}"; Assembly asm0 = CompileExpressionToMethod(_srcCode); _reqs[0].OnCompiled(asm0); bool[] masks = new bool[32]; masks[0] = true; masks[1] = false; SkAttribsOpEXP op = (SkAttribsOpEXP)_reqs[0]; SkAttribs casterBaseAttrib = new SkAttribs(); SkAttribs casterAttrib = new SkAttribs(casterBaseAttrib, masks); SkAttribs targetBaseAttrib = new SkAttribs(); SkAttribs targetAttrib = new SkAttribs(casterBaseAttrib, masks); op.Exec(targetAttrib, casterAttrib, targetAttrib, null); #else Assembly asm = CompileExpressionToMethod(_srcCode); int n = _reqs.Count; for (int i = 0; i < n; i++) { MethodInfo method = asm.GetType("Func" + i).GetMethod("func"); System.Action <ISkAttribs, ISkAttribs, ISkAttribsModPara> action = (System.Action <ISkAttribs, ISkAttribs, ISkAttribsModPara>)Delegate.CreateDelegate(typeof(System.Action <ISkAttribs, ISkAttribs, ISkAttribsModPara>), null, method); _reqs[i].OnCompiled(action); } #endif Debug.Log("[EXP]All Compiled:" + (Environment.TickCount - t)); _reqs.Clear(); _srcCode = ""; }
internal List <SkBuffInst> _buffs = new List <SkBuffInst>(); // Spcial code for buffs public SkPackage(SkAttribs parentAttribs) { _parentAttribs = parentAttribs; }