Exemplo n.º 1
0
        public virtual int CompareTo(BTriggerSystem ts, TriggerScriptDbObjectWithArgs obj)
        {
            if (Name != obj.Name)
            {
                Debug.Trace.Engine.TraceInformation(
                    "TriggerProtoDbObject: '{0}' - Encountered different names for {1}, '{2}' != '{3}'",
                    ts, this.DbId.ToString(), this.Name, obj.Name);
            }

            if (ContainsUserClassTypeVar(ts, obj))
            {
                Debug.Trace.Engine.TraceInformation(
                    "TriggerProtoDbObject: {0} - Encountered {1}/{2} which has a UserClassType Var, skipping comparison",
                    ts, DbId.ToString(), Name);
                return(0);
            }

            Contract.Assert(Version == obj.Version);
            Contract.Assert(Params.Count == obj.Args.Count);

            int diff = 0;

            for (int x = 0; x < Params.Count; x++)
            {
                int sig     = Params[x].SigID;
                int obj_sig = obj.Args[x].SigID;
                sig     = sig < 0 ? 0 : sig;
                obj_sig = obj_sig < 0 ? 0 : obj_sig;

                diff += sig - obj_sig;
            }

            return(diff);
        }
Exemplo n.º 2
0
        public static Collections.BListExplicitIndex <BTriggerParam> BuildDefinition(
            BTriggerSystem root, Collections.BListExplicitIndex <BTriggerArg> args)
        {
            var p = new Collections.BListExplicitIndex <BTriggerParam>(kBListExplicitIndexParams);

            p.ResizeCount(args.Count);

            foreach (var arg in args)
            {
                if (arg.IsInvalid)
                {
                    continue;
                }

                var param = new BTriggerParam();
                param.mType     = arg.Type;
                param.mName     = arg.Name;
                param.mSigID    = arg.SigID;
                param.mOptional = arg.Optional;
                param.mVarType  = arg.GetVarType(root);

                p[param.mSigID - 1] = param;
            }

            p.OptimizeStorage();
            return(p);
        }
Exemplo n.º 3
0
        protected TriggerProtoDbObject(BTriggerSystem root, TriggerScriptDbObjectWithArgs instance)
        {
            mName = instance.Name;

            mDbId    = instance.DbId;
            mVersion = instance.Version;
            Params   = BTriggerParam.BuildDefinition(root, instance.Args);
        }
Exemplo n.º 4
0
 static bool ContainsUserClassTypeVar(BTriggerSystem ts, TriggerScriptDbObjectWithArgs obj)
 {
     foreach (var arg in obj.Args)
     {
         if (arg.IsInvalid)
         {
             continue;
         }
         if (arg.GetVarType(ts) == BTriggerVarType.UserClassType)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 5
0
 internal void UpdateFromGameData(BTriggerSystem ts)
 {
     lock (LookupTable)
     {
         foreach (var t in ts.Triggers)
         {
             foreach (var c in t.Conditions)
             {
                 TryUpdate(ts, c);
             }
             foreach (var e in t.EffectsOnTrue)
             {
                 TryUpdate(ts, e);
             }
             foreach (var e in t.EffectsOnFalse)
             {
                 TryUpdate(ts, e);
             }
         }
     }
 }
Exemplo n.º 6
0
        void TryUpdate(BTriggerSystem ts, BTriggerEffect effe)
        {
            TriggerProtoDbObject dbo;

            if (!LookupTableContains(effe, out dbo))
            {
                var dbo_effe = new BTriggerProtoEffect(ts, effe);

                Effects.DynamicAdd(dbo_effe, dbo_effe.Name);
                LookupTableAdd(dbo_effe);
            }
            else
            {
                int diff = dbo.CompareTo(ts, effe);
                if (diff < 0)
                {
                    var dbo_effe = new BTriggerProtoEffect(ts, effe);
                    LookupTable[GenerateHandle(effe)] = dbo_effe;
                    TraceUpdate(ts, dbo_effe);
                }
            }
        }
Exemplo n.º 7
0
        void TryUpdate(BTriggerSystem ts, BTriggerCondition cond)
        {
            TriggerProtoDbObject dbo;

            if (!LookupTableContains(cond, out dbo))
            {
                var dbo_cond = new BTriggerProtoCondition(ts, cond);

                Conditions.DynamicAdd(dbo_cond, dbo_cond.Name);
                LookupTableAdd(dbo_cond);
            }
            else
            {
                int diff = dbo.CompareTo(ts, cond);
                if (diff < 0)
                {
                    var dbo_cond = new BTriggerProtoCondition(ts, cond);
                    LookupTable[GenerateHandle(cond)] = dbo_cond;
                    TraceUpdate(ts, dbo_cond);
                }
            }
        }
Exemplo n.º 8
0
 public BTriggerVarType GetVarType(BTriggerSystem root)
 {
     return(root.GetVar(mVarID).Type);
 }
Exemplo n.º 9
0
 static void TraceUpdate(BTriggerSystem ts, TriggerProtoDbObject dbo)
 {
     Debug.Trace.Engine.TraceInformation(
         "TriggerProtoDbObject: {0} - Updated {1}/{2}",
         ts, dbo.DbId.ToString(), dbo.Name);
 }
 public BTriggerProtoCondition(BTriggerSystem root, BTriggerCondition instance) : base(root, instance)
 {
     mAsync             = instance.Async;
     mAsyncParameterKey = instance.AsyncParameterKey;
 }
Exemplo n.º 11
0
 public BTriggerProtoEffect(BTriggerSystem root, BTriggerEffect instance) : base(root, instance)
 {
 }