public DumpWrapper Dump() { var ret = new DumpWrapper(); ret.name = Name; ret.minimalPLMDump = minimalPlayablePLM; ret.canvasDump = CanvasConfig.StaticSerialize(canvasConfig); ret.matchRuleDumps = matchRules.SchemeStyleMap <RuleMatchBasic, string>((r) => { return(RuleMatchBasic.StaticSerialize(r)); }); ret.operationRuleDumps = operationRules.SchemeStyleMap <RuleOperation, string>((r) => { return(RuleOperation.StaticSerialize(r)); }); ret.extensionRuleDumps = extensionRules.SchemeStyleMap <RuleMatchExtension, string>((r) => { return(RuleMatchExtension.StaticSerialize(r)); }); ret.scoreRuleDumps = scoreRules.SchemeStyleMap <RuleScore, string>((r) => { return(RuleScore.StaticSerialize(r)); }); ret.refillRuleDump = RuleRefill.StaticSerialize(refillRule); ret.traitDumps = slotConfig.Traits.SchemeStyleMap <SlotTrait, string>((t) => { return(SlotTrait.StaticSerialize(t)); }); ret.specialDumps = new List <string>(); foreach (var kvp in slotConfig.Specials) { ret.specialDumps.Add(SlotSpecialty.StaticSerialize(kvp.Value)); } return(ret); }
public virtual void Init(List <string> traitDumps, List <string> specialDumps) { traits = traitDumps.SchemeStyleMap <string, SlotTrait>((str) => { return(SlotTrait.StaticDeserialize(str)); }); var tmp = specialDumps.SchemeStyleMap <string, SlotSpecialty>((str) => { return(SlotSpecialty.StaticDeserialize(str)); }); specials = new Dictionary <string, SlotSpecialty>(); foreach (var s in tmp) { specials.Add(s.Name, s); } }
private void ProcessSlot(SlotTrait slotTrait) { switch (slotTrait.ValKind) { case ConstantKind.ConInt: this.intMarshal.Register((int)slotTrait.Val); break; case ConstantKind.ConUInt: this.uintMarshal.Register((uint)slotTrait.Val); break; case ConstantKind.ConDouble: this.doubleMarshal.Register((ulong)slotTrait.Val); break; case ConstantKind.ConUtf8: this.stringMarshal.Register((string)slotTrait.Val); break; case ConstantKind.ConTrue: case ConstantKind.ConFalse: case ConstantKind.ConNull: case ConstantKind.ConUndefined: /* We need not do anything with these universal constants. */ break; case ConstantKind.ConNamespace: case ConstantKind.ConPackageNamespace: case ConstantKind.ConPackageInternalNs: case ConstantKind.ConProtectedNamespace: case ConstantKind.ConExplicitNamespace: case ConstantKind.ConStaticProtectedNs: case ConstantKind.ConPrivateNs: /*(void)*/ this.NamespaceID((Namespace)slotTrait.Val); break; default: /* ISSUE 73 */ throw new SWFModellerException( SWFModellerError.UnimplementedFeature, "Unsupported slot value kind " + slotTrait.ValKind.ToString()); } }
private static bool JudgeOperable(SlotTrait matchingTrait, Container2D_Rectangular container, int xMask, int yMask, int xInMask, int yInMask, RuleMatchBasic2D_Rectangular match, RuleOperation2D_Rectangular operation, bool inverse) { int xRelative = inverse ? -operation.xRelative : operation.xRelative; int yRelative = inverse ? -operation.yRelative : operation.yRelative; int xTouch = xInMask + xRelative; int yTouch = yInMask + yRelative; if (yTouch >= 0 && yTouch < match.maskHeight && xTouch >= 0 && xTouch < match.maskWidth && match.PeekMask(xTouch, yTouch)) { return(false); } var sniffX = xMask + xInMask + xRelative; var sniffY = yMask + yInMask + yRelative; if (!container.IsLegalPosition(sniffX, sniffY)) { return(false); } var sniff = container.GetSlot(sniffX, sniffY); if (!sniff.IsTarget) { return(false); } return(matchingTrait.AbsoluteEqual(sniff.slotAttribute.trait)); }
public bool AbsoluteEqual(SlotTrait other) { Assert.AssertNotNull(other); return other.Identifer == Identifer; }
public static string StaticSerialize(SlotTrait t) { return JsonHelper.Serialize(new Tuple<string, string>(t.SerializeUID, t.Serialize())); }
public static bool AbsoluteEqual(SlotTrait a, SlotTrait b) { return a.Identifer == b.Identifer; }
public static string StaticSerialize(SlotTrait t) { return(JsonHelper.Serialize(new Tuple <string, string>(t.SerializeUID, t.Serialize()))); }
public static bool AbsoluteEqual(SlotTrait a, SlotTrait b) { return(a.Identifer == b.Identifer); }
public bool AbsoluteEqual(SlotTrait other) { Assert.AssertNotNull(other); return(other.Identifer == Identifer); }
/// <summary> /// Read in a trait, which are like object properties. /// </summary> /// <returns>A trait.</returns> private Trait ReadTrait() { Trait t = null; Multiname traitName = this.code.GetMultiname((int)this.abcdtr.ReadU30()); int traitCode = this.abcdtr.ReadUI8(); TraitKind kind = (TraitKind)(traitCode & 0xF); switch (kind) { case TraitKind.Slot: case TraitKind.Const: SlotTrait st = new SlotTrait(); st.Name = traitName; st.Kind = kind; st.SlotID = this.abcdtr.ReadU30(); st.TypeName = this.code.GetMultiname((int)this.abcdtr.ReadU30()); uint vindex = this.abcdtr.ReadU30(); if (vindex != 0) { st.ValKind = (ConstantKind)this.abcdtr.ReadUI8(); switch (st.ValKind) { case ConstantKind.ConInt: st.Val = this.code.IntConsts[vindex]; break; case ConstantKind.ConUInt: st.Val = this.code.UIntConsts[vindex]; break; case ConstantKind.ConDouble: st.Val = this.code.DoubleConsts[vindex]; break; case ConstantKind.ConUtf8: st.Val = this.code.StringConsts[vindex]; break; case ConstantKind.ConTrue: case ConstantKind.ConFalse: case ConstantKind.ConNull: case ConstantKind.ConUndefined: break; case ConstantKind.ConNamespace: case ConstantKind.ConPackageNamespace: case ConstantKind.ConPackageInternalNs: case ConstantKind.ConProtectedNamespace: case ConstantKind.ConExplicitNamespace: case ConstantKind.ConStaticProtectedNs: case ConstantKind.ConPrivateNs: st.Val = this.code.GetNamespace((int)vindex); break; default: throw new SWFModellerException( SWFModellerError.Internal, "Unsupported constant kind: " + st.ValKind.ToString()); } } t = st; break; case TraitKind.Class: ClassTrait ct = new ClassTrait(); ct.Name = traitName; ct.Kind = kind; ct.SlotID = this.abcdtr.ReadU30(); this.LateResolutions.Add(ct, (int)this.abcdtr.ReadU30()); /* We'll resolve the class ref later. */ t = ct; break; case TraitKind.Function: FunctionTrait ft = new FunctionTrait(); ft.Name = traitName; ft.Kind = kind; ft.SlotID = this.abcdtr.ReadU30(); ft.Fn = this.code.GetMethod((int)this.abcdtr.ReadU30()); t = ft; break; case TraitKind.Method: case TraitKind.Getter: case TraitKind.Setter: default: MethodTrait mt = new MethodTrait(); mt.Name = traitName; mt.Kind = kind; uint dispID = this.abcdtr.ReadU30(); if (dispID != 0) { mt.OverriddenMethod = this.code.GetMethod((int)dispID); } mt.Fn = this.code.GetMethod((int)this.abcdtr.ReadU30()); t = mt; break; } return(t); }
private void WriteTraitInfo(ABCDataTypeWriter writer, Trait t) { writer.WriteU30Packed((uint)this.MultinameID(t.Name)); writer.WriteUI8((uint)t.Kind); switch (t.Kind) { case TraitKind.Slot: case TraitKind.Const: SlotTrait st = (SlotTrait)t; writer.WriteU30Packed(st.SlotID); writer.WriteU30Packed((uint)this.MultinameID(st.TypeName)); if (st.Val == null) { writer.WriteU30Packed(0); } else { switch (st.ValKind) { case ConstantKind.ConInt: writer.WriteU30Packed((uint)this.intMarshal.GetIDFor((int)st.Val)); break; case ConstantKind.ConUInt: writer.WriteU30Packed((uint)this.uintMarshal.GetIDFor((uint)st.Val)); break; case ConstantKind.ConDouble: writer.WriteU30Packed((uint)this.doubleMarshal.GetIDFor((ulong)st.Val)); break; case ConstantKind.ConUtf8: writer.WriteU30Packed((uint)this.stringMarshal.GetIDFor((string)st.Val)); break; case ConstantKind.ConTrue: /* Through observation, this always gets set to 11, I do not know why. It * seems though that it should be any non-zero number. */ writer.WriteU30Packed(11); break; case ConstantKind.ConFalse: /* Through observation, this always gets set to 11, I do not know why. It * seems though that it should be any non-zero number. */ writer.WriteU30Packed(10); break; case ConstantKind.ConNull: /* Through observation, this always gets set to 11, I do not know why. It * seems though that it should be any non-zero number. */ writer.WriteU30Packed(12); break; case ConstantKind.ConUndefined: /* Through observation, true, false and null all seem to have ignored but * specific values. I haven't seen one for undefined, but I'm guessing it's * 13. Really want to know what these number are. The don't seem to relate * the string or multiname tables. */ writer.WriteU30Packed(13); break; case ConstantKind.ConNamespace: case ConstantKind.ConPackageNamespace: case ConstantKind.ConPackageInternalNs: case ConstantKind.ConProtectedNamespace: case ConstantKind.ConExplicitNamespace: case ConstantKind.ConStaticProtectedNs: case ConstantKind.ConPrivateNs: writer.WriteU30Packed((uint)this.NamespaceID((Namespace)st.Val)); break; default: throw new SWFModellerException( SWFModellerError.Internal, "Unsupported constant type: " + st.ValKind.ToString()); } writer.WriteUI8((uint)st.ValKind); } break; case TraitKind.Method: case TraitKind.Getter: case TraitKind.Setter: MethodTrait mt = (MethodTrait)t; if (mt.OverriddenMethod != null) { writer.WriteU30Packed((uint)this.methodMarshal.GetIDFor(mt.OverriddenMethod)); } else { writer.WriteU30Packed(0); } writer.WriteU30Packed((uint)this.methodMarshal.GetIDFor(mt.Fn)); break; case TraitKind.Class: ClassTrait ct = (ClassTrait)t; writer.WriteU30Packed((uint)ct.SlotID); writer.WriteU30Packed((uint)this.classMarshal.GetIDFor(ct.As3class)); break; case TraitKind.Function: FunctionTrait ft = (FunctionTrait)t; writer.WriteU30Packed((uint)ft.SlotID); writer.WriteU30Packed((uint)this.methodMarshal.GetIDFor(ft.Fn)); break; default: /* ISSUE 73 */ throw new SWFModellerException( SWFModellerError.UnimplementedFeature, "Unsupported trait kind: " + t.Kind.ToString()); } }