예제 #1
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);
        }
예제 #2
0
        public virtual int CompareTo(BTriggerSystem ts, TriggerScriptObjectWithArgs 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);
        }
예제 #3
0
        protected TriggerSystemProtoObject(BTriggerSystem root, TriggerScriptObjectWithArgs instance)
        {
            Name = instance.Name;

            mDbId    = instance.DbId;
            mVersion = instance.Version;
            Params   = BTriggerParam.BuildDefinition(root, instance.Args);
        }
예제 #4
0
 static bool ContainsUserClassTypeVar(BTriggerSystem ts, TriggerScriptObjectWithArgs obj)
 {
     foreach (var arg in obj.Args)
     {
         if (arg.IsInvalid)
         {
             continue;
         }
         if (arg.GetVarType(ts) == BTriggerVarType.UserClassType)
         {
             return(true);
         }
     }
     return(false);
 }
예제 #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);
             }
         }
     }
 }
예제 #6
0
        void TryUpdate(BTriggerSystem ts, BTriggerEffect effe)
        {
            TriggerSystemProtoObject 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);
                }
            }
        }
예제 #7
0
        void TryUpdate(BTriggerSystem ts, BTriggerCondition cond)
        {
            TriggerSystemProtoObject 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);
                }
            }
        }
예제 #8
0
 static void TraceUpdate(BTriggerSystem ts, TriggerSystemProtoObject dbo)
 {
     Debug.Trace.Engine.TraceInformation(
         "TriggerProtoDbObject: {0} - Updated {1}/{2}",
         ts, dbo.DbId.ToString(), dbo.Name);
 }
예제 #9
0
 public BTriggerVarType GetVarType(BTriggerSystem root)
 {
     return(root.GetVar(mVarID).Type);
 }