/// <summary> /// Copy Function /// </summary> /// <returns>new copy</returns> public Functions ShallowCopy() { Functions newAOF = new Functions(); foreach (Requirements aor in this.Requirements) { Requirements newAOR = new Requirements(); newAOR.ChildOperator = aor.ChildOperator; newAOR.Operator = aor.Operator; newAOR.Statnumber = aor.Statnumber; newAOR.Target = aor.Target; newAOR.Value = aor.Value; newAOF.Requirements.Add(newAOR); } foreach (object ob in this.Arguments.Values) { if (ob.GetType() == typeof(string)) { string z = (string)ob; newAOF.Arguments.Values.Add(z); } if (ob.GetType() == typeof(int)) { int i = (int)ob; newAOF.Arguments.Values.Add(i); } if (ob.GetType() == typeof(Single)) { float s = (Single)ob; newAOF.Arguments.Values.Add(s); } } newAOF.dolocalstats = this.dolocalstats; newAOF.FunctionType = this.FunctionType; newAOF.Target = this.Target; newAOF.TickCount = this.TickCount; newAOF.TickInterval = this.TickInterval; return newAOF; }
/// <summary> /// </summary> /// <param name="aof"> /// </param> /// <param name="checkAll"> /// </param> /// <returns> /// </returns> /// <exception cref="NotImplementedException"> /// </exception> public bool CheckRequirements(Functions aof, bool checkAll) { throw new NotImplementedException(); }
/// <summary> /// </summary> /// Methods to do: /// Read Item /// Write Item /// Return Dynel Item (placing on the ground) /// <returns> /// </returns> public NanoFormula ShallowCopy() { NanoFormula nanoFormula = new NanoFormula(); nanoFormula.ID = this.ID; foreach (KeyValuePair<int, int> nanoFormulaAttribute in this.Attack) { nanoFormula.Attack.Add(nanoFormulaAttribute.Key, nanoFormulaAttribute.Value); } foreach (KeyValuePair<int, int> nanoFormulaAttribute in this.Defend) { nanoFormula.Defend.Add(nanoFormulaAttribute.Key, nanoFormulaAttribute.Value); } foreach (KeyValuePair<int, int> nanoFormulaAttribute in this.Stats) { nanoFormula.Stats.Add(nanoFormulaAttribute.Key, nanoFormulaAttribute.Value); } foreach (Events aoEvents in this.Events) { Events newEvent = new Events(); foreach (Functions aoFunctions in aoEvents.Functions) { Functions newAOFunctions = new Functions(); foreach (Requirements aor in aoFunctions.Requirements) { Requirements newRequirement = new Requirements(); newRequirement.ChildOperator = aor.ChildOperator; newRequirement.Operator = aor.Operator; newRequirement.Statnumber = aor.Statnumber; newRequirement.Target = aor.Target; newRequirement.Value = aor.Value; newAOFunctions.Requirements.Add(newRequirement); } foreach (object argument in aoFunctions.Arguments.Values) { if (argument.GetType() == typeof(string)) { string z = (string)argument; newAOFunctions.Arguments.Values.Add(z); } if (argument.GetType() == typeof(int)) { int i = (int)argument; newAOFunctions.Arguments.Values.Add(i); } if (argument.GetType() == typeof(Single)) { float s = (Single)argument; newAOFunctions.Arguments.Values.Add(s); } } newAOFunctions.dolocalstats = aoFunctions.dolocalstats; newAOFunctions.FunctionType = aoFunctions.FunctionType; newAOFunctions.Target = aoFunctions.Target; newAOFunctions.TickCount = aoFunctions.TickCount; newAOFunctions.TickInterval = aoFunctions.TickInterval; newEvent.Functions.Add(newAOFunctions); } newEvent.EventType = aoEvents.EventType; nanoFormula.Events.Add(newEvent); } nanoFormula.flags = this.flags; nanoFormula.Instance = this.Instance; nanoFormula.ItemType = this.ItemType; return nanoFormula; }
/// <summary> /// The parse shop hash. /// </summary> /// <param name="events"> /// The events. /// </param> private void ParseShopHash(List<Events> events) { int eventNum = this.br.ReadInt32(); int num = this.br.Read3F1(); int arg_2D_0 = 1; int num2 = num; int num3 = arg_2D_0; Events aoe = new Events(); aoe.EventType = eventNum; checked { while (true) { int arg_151_0 = num3; int num4 = num2; if (arg_151_0 > num4) { break; } string text = this.br.ReadString(4); int num5 = this.br.ReadByte(); int num6 = this.br.ReadByte(); bool flag = num5 == 0 && num6 == 0; if (flag) { num5 = this.br.ReadInt16(); num6 = this.br.ReadInt16(); } int count = Math.Min(11, this.br.Buffer.Length - this.br.Ptr); this.br.Skip(count); Functions aof = new Functions(); aof.Arguments.Values.Add(text); aof.Arguments.Values.Add(num5); aof.Arguments.Values.Add(num6); aof.Target = 255; aof.TickCount = 1; aof.TickInterval = 0; aof.FunctionType = Constants.FunctiontypeShophash; aoe.Functions.Add(aof); num3++; } } if (events == null) { events = new List<Events>(); } events.Add(aoe); }
/// <summary> /// The parse function set. /// </summary> /// <param name="retlist"> /// The retlist. /// </param> private void ParseFunctionSet(List<Events> retlist) { int eventNum = this.br.ReadInt32(); int num = this.br.Read3F1(); List<Functions> list = new List<Functions>(); int arg_2F_0 = 0; bool R; int num2 = num - 1; int num3 = arg_2F_0; while (true) { int arg_1C3_0 = num3; int num4 = num2; if (arg_1C3_0 > num4) { break; } Functions func = new Functions(); func.FunctionType = this.br.ReadInt32(); this.br.Skip(8); int num5 = this.br.ReadInt32(); // Reqs bool flag = num5 > 0; if (flag) { foreach (Requirements ur in this.ReadReqs(num5)) { func.Requirements.Add(ur); } } func.TickCount = this.br.ReadInt32(); func.TickInterval = (uint)this.br.ReadInt32(); func.Target = this.br.ReadInt32(); this.br.Skip(4); R = false; foreach (object oo in this.ParseArgs(func.FunctionType, ref R)) { func.Arguments.Values.Add(oo); } list.Add(func); num3++; } Events aoe = new Events(); aoe.EventType = eventNum; foreach (Functions ff in list) { aoe.Functions.Add(ff); } if (retlist == null) { retlist = new List<Events>(); } retlist.Add(aoe); }
/// <summary> /// </summary> /// <param name="aof"> /// </param> /// <param name="checkAll"> /// </param> /// <returns> /// </returns> public bool CheckRequirements(Functions aof, bool checkAll) { bool requirementsMet = true; int childOperator = -1; // Starting value bool foundCharRelated = (aof.FunctionType == Constants.FunctiontypeHairMesh) || (aof.FunctionType == Constants.FunctiontypeBackMesh) || (aof.FunctionType == Constants.FunctiontypeTexture) || (aof.FunctionType == Constants.FunctiontypeAttractorMesh) || (aof.FunctionType == Constants.FunctiontypeCatMesh) || (aof.FunctionType == Constants.FunctiontypeChangeBodyMesh) || (aof.FunctionType == Constants.functiontype_shouldermesh) || (aof.FunctionType == Constants.FunctiontypeHeadMesh); Identity RequirementTargetIdentity = new Identity(); foreach (Requirements aor in aof.Requirements) { switch (aor.Target) { case Constants.ItemtargetUser: { RequirementTargetIdentity = this.identity; break; } case Constants.ItemtargetWearer: { // TODO: Subject to change, not sure about this one RequirementTargetIdentity = this.identity; break; } case Constants.ItemtargetTarget: { // TODO: pass on target break; } case Constants.ItemtargetFightingtarget: { var temp = this as ITargetingEntity; if (temp != null) { RequirementTargetIdentity = temp.FightingTarget; } break; } case Constants.ItemtargetSelectedtarget: { var temp = this as ITargetingEntity; if (temp != null) { RequirementTargetIdentity = temp.SelectedTarget; } break; } case Constants.ItemtargetSelf: { RequirementTargetIdentity = this.Identity; break; } default: { RequirementTargetIdentity = new Identity(); break; } } if (RequirementTargetIdentity.Type == IdentityType.None) { return false; // Target not found, cant check reqs -> FALSE } IStats reqTargetStatholder = ((IInstancedEntity)this).Playfield.FindByIdentity( RequirementTargetIdentity); int statval = reqTargetStatholder.Stats[aor.Statnumber].Value; bool reqresult = true; switch (aor.Operator) { case Constants.OperatorAnd: { reqresult = (statval & aor.Value) != 0; break; } case Constants.OperatorOr: { reqresult = (statval | aor.Value) != 0; break; } case Constants.OperatorEqualTo: { reqresult = statval == aor.Value; break; } case Constants.OperatorLessThan: { reqresult = statval < aor.Value; break; } case Constants.OperatorGreaterThan: { reqresult = statval > aor.Value; break; } case Constants.OperatorUnequal: { reqresult = statval != aor.Value; break; } case Constants.OperatorTrue: { reqresult = true; break; } case Constants.OperatorFalse: { reqresult = false; break; } case Constants.OperatorBitAnd: { reqresult = (statval & aor.Value) != 0; break; } case Constants.OperatorBitOr: { reqresult = (statval | aor.Value) != 0; break; } default: { // TRUE for now reqresult = true; break; } } switch (childOperator) { case Constants.OperatorAnd: { requirementsMet &= reqresult; break; } case Constants.OperatorOr: { requirementsMet &= reqresult; break; } case -1: { requirementsMet = reqresult; break; } default: break; } childOperator = aor.ChildOperator; } if (!checkAll) { if (foundCharRelated) { requirementsMet &= foundCharRelated; } else { requirementsMet = true; } } return requirementsMet; }
/// <summary> /// </summary> /// <param name="function"> /// </param> /// <param name="user"> /// </param> public IMExecuteFunction(Functions function, Identity user) { this.User = user; this.Function = function; }