示例#1
0
        // #NOTE_BLAM: up to concrete implementations to serialize References
        public override void Serialize <TDoc, TCursor>(MegaloScriptModel model, IO.TagElementStream <TDoc, TCursor, string> s)
        {
            SerializeIdOpt(model, s);
            s.StreamAttributeEnumOpt("trigType", ref mTriggerType, e => e != MegaloScriptTriggerType.Normal);
            s.StreamAttributeEnumOpt("execMode", ref mExecutionMode, e => e != MegaloScriptTriggerExecutionMode.General);
            SerializeNameOpt(s);

            if (ExecutionMode == MegaloScriptTriggerExecutionMode.OnObjectFilter)
            {
                s.StreamAttributeIdAsString("objectFilter", ref mObjectFilterIndex, model,
                                            (_model, name) => model.FromIndexName(Proto.MegaloScriptValueIndexTarget.ObjectFilter, name),
                                            (_model, id) => model.ToIndexName(Proto.MegaloScriptValueIndexTarget.ObjectFilter, id));
            }
            else
            {
                ObjectFilterIndex = -1;
            }

            if (ExecutionMode == MegaloScriptTriggerExecutionMode.OnCandySpawnerFilter)
            {
                using (s.EnterCursorBookmark("GameObject"))
                {
                    s.StreamAttributeEnum("type", ref mGameObjectType);

                    s.StreamAttributeIdAsString("filter", ref mGameObjectFilterIndex, model,
                                                (_model, name) => model.FromIndexName(Proto.MegaloScriptValueIndexTarget.GameObjectFilter, name),
                                                (_model, id) => model.ToIndexName(Proto.MegaloScriptValueIndexTarget.GameObjectFilter, id));
                }
            }
            else
            {
                GameObjectFilterIndex = -1;
            }

            if (TriggerType == MegaloScriptTriggerType.Normal)
            {
                s.StreamAttributeOpt("commentOut", ref mCommentOut, Predicates.IsTrue);
            }
        }
        static int SerializeObjectTypeReference <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s,
                                                                Collections.BitSet bitset, int bitIndex, MegaloScriptModel model)
            where TDoc : class
            where TCursor : class
        {
            if (s.IsReading)
            {
                string object_name = null;
                s.ReadCursor(ref object_name);
                bitIndex = model.FromIndexName(Proto.MegaloScriptValueIndexTarget.ObjectType, object_name);
            }
            else if (s.IsWriting)
            {
                string object_name = model.ToIndexName(Proto.MegaloScriptValueIndexTarget.ObjectType, bitIndex);
                s.WriteCursor(object_name);
            }

            return(bitIndex);
        }