public void OnExecute(SitcomContext runtime)
 {
     if (mOper != null)
     {
         runtime.Push(mOper);
     }
 }
Exemple #2
0
 public override void OnExecute(SitcomContext runtime)
 {
     if (mContent != null)
     {
         runtime.Push(mContent);
     }
 }
        public ISitcomResult Dom_Unspawn(SitcomContext runtime, SitcomHeap target, string content, object[] args)
        {
            var names = new List <string>();

            if (!StringUtil.ParseArray(content, names, '\n') || names.Count == 0)
            {
                return(new SitcomValue(false));
            }
            if (args != null && args.Length > 0 && args[0] != null)
            {
                var goes = GameObject.FindGameObjectsWithTag(args[0].ToString());
                for (int i = 0; i < goes.Length; i++)
                {
                    if (names.Contains(goes[i].name))
                    {
                        GameObject.Destroy(goes[i]);
                    }
                }
            }
            else
            {
                for (int i = 0; i < names.Count; i++)
                {
                    var go = GameObject.Find(names[i]);
                    if (go != null)
                    {
                        GameObject.Destroy(go);
                    }
                }
            }
            return(new SitcomValue(true));
        }
 public ISitcomResult Dom_Alloc(SitcomContext runtime, SitcomHeap target, string content, object[] args)
 {
     if (args != null && args.Length > 0)
     {
         target.Alloc(args[0].ToString(), content);
     }
     return(new SitcomValue(content));
 }
        public override void OnStop(SitcomContext runtime)
        {
            var ret = mRight != null ? mRight.Result : null;

            if (ret != null && ret.State == ESitcomState.Success && mLeft != null)
            {
                runtime.Push(mLeft);
            }
        }
 public ISitcomResult Dom_Print(SitcomContext runtime, SitcomHeap target, string content, object[] args)
 {
     if (args[0] != null)
     {
         Debug.Log(args[0]);
     }
     if (!string.IsNullOrEmpty(content))
     {
         Debug.Log(content);
     }
     return(new SitcomDelay(args == null || args.Length < 1 ? 1 : SitcomUtil.ParseAsNumber(args[1])));
 }
Exemple #7
0
 public void OnStop(SitcomContext runtime)
 {
     if (!mFinish)
     {
         runtime.Push(this);
     }
     else
     {
         mExecuting = false;
         mFinish    = false;
         mIsReading = false;
         runtime.Heap.EndStack();
     }
 }
Exemple #8
0
 public void OnExecute(SitcomContext runtime)
 {
     if (!mExecuting)
     {
         mExecuting = true;
         mFinish    = false;
         if (!mIsReading)
         {
             BeginRead();
         }
         runtime.Heap.BeginStack();
     }
     if (SelectNextMark() && mCmd.Read(this))
     {
         runtime.Push(mCmd);
     }
     else
     {
         mFinish = true;
     }
 }
Exemple #9
0
 public override void OnExecute(SitcomContext runtime)
 {
     if (mLeft != null)
     {
         runtime.Push(mLeft);
     }
     if (mUseKV)
     {
         for (int i = 0; i < mKVs.Count; i++)
         {
             runtime.Push(mKVs[i].useKey ? mKVs[i].value : mKVs[i].key);
         }
     }
     else
     {
         for (int i = 0; i < mKVs.Count; i++)
         {
             runtime.Push(mKVs[i].key);
         }
     }
 }
        public ISitcomResult Dom_Spawn(SitcomContext runtime, SitcomHeap target, string content, object[] args)
        {
            var names = new List <string>();

            if (!StringUtil.ParseArray(content, names, '\n') || names.Count == 0)
            {
                return(new SitcomValue(false));
            }
            var ret = new SitcomAsyncOperator();

            AssetsUtil.GetAssetAsync <GameObject>(args[0].ToString(), (x) =>
            {
                float f;
                if (args[3] != null)
                {
                    f = SitcomUtil.AsNumber(args[3]);
                }
                else
                {
                    f = 0;
                }
                Vector3 pos   = args[1] == null ? Vector3.zero : StringUtil.ParseVector3(args[1].ToString());
                Vector3 euler = args[2] == null ? Vector3.zero : StringUtil.ParseVector3(args[2].ToString());
                for (int i = 0; i < names.Count; i++)
                {
                    var go  = GameObject.Instantiate(x);
                    go.name = names[i];
                    var rad = Random.insideUnitCircle * f;
                    go.transform.position         = pos + new Vector3(rad.x, 0, rad.y);
                    go.transform.localEulerAngles = euler;
                    ret.Result = go;
                }
                ret.State = ESitcomState.Success;
            }, (error) =>
            {
                ret.Result = error;
                ret.State  = ESitcomState.Failed;
            });
            return(ret);
        }
Exemple #11
0
 public virtual ISitcomResult Sit_ToString(SitcomContext context, T target, string content, object[] args)
 {
     return(new SitcomValue(target.ToString()));
 }
 public ISitcomResult Dom_Deactive(SitcomContext runtime, SitcomHeap target, string content, object[] args)
 {
     return(Dom_SetActive(false, runtime, target, content, args));
 }
 public ISitcomResult Dom_End(SitcomContext runtime, SitcomHeap target, string content, object[] args)
 {
     runtime.SetNextMark(SitcomCmdSequence.EndMarkId);
     return(null);
 }
 public ISitcomResult Dom_Delay(SitcomContext runtime, SitcomHeap target, string content, object[] args)
 {
     return(new SitcomDelay((float)SitcomUtil.ParseAsNumber(args[0])));
 }
Exemple #15
0
 public override void OnExecute(SitcomContext runtime)
 {
     runtime.Push(mLeft);
     runtime.Push(mRight);
 }
Exemple #16
0
 public override void OnStop(SitcomContext runtime)
 {
 }
Exemple #17
0
 public virtual ISitcomResult Sit_HashCode(SitcomContext context, T target, string content, object[] args)
 {
     return(new SitcomValue(target.GetHashCode()));
 }
Exemple #18
0
        public override void OnStop(SitcomContext runtime)
        {
            object target;

            if (mLeft == null)
            {
                target = runtime.Heap;
            }
            else if (mLeft.Result != null)
            {
                target = mLeft.Result.Result;
            }
            else
            {
                target = null;
            }
            if (target == null)
            {
                throw new SitcomNullReferenceExpception(keyword);
            }
            var meta = runtime.Heap.GetMeta(target.GetType());

            if (!mWaitContent)
            {
                mResult = new SitcomValue(meta.GetProperty(mRight.id, target));
                return;
            }
            var domain = meta.GetDomain(mRight.id);

            if (domain == null)
            {
                throw new SitcomNullReferenceExpception(keyword);
            }
            object[] args;
            if (domain.ArgLength > 0)
            {
                args = new object[domain.ArgLength];
            }
            else
            {
                args = new object[mKVs.Count];
            }
            if (mUseKV)
            {
                for (int i = 0; i < mKVs.Count; i++)
                {
                    var index = mKVs[i].useKey ? domain.ArgIndex(mKVs[i].key.keyword.id) : i;
                    if (index >= 0 && index < args.Length)
                    {
                        args[index] = mKVs[i].GetValue();
                    }
                }
            }
            else
            {
                var len = Mathf.Min(args.Length, mKVs.Count);
                for (int i = 0; i < len; i++)
                {
                    var ret = mKVs[i].key.Result;
                    args[i] = ret.Result;
                }
            }
            mResult = domain.Call(runtime, target, mContent.text, args);
        }
 public ISitcomResult Dom_Result(SitcomContext runtime, SitcomHeap target, string content, object[] args)
 {
     return(new SitcomValue(args == null || args.Length < 1 ? content : args[0]));
 }
 public void OnStop(SitcomContext runtime)
 {
 }
 public override void OnStop(SitcomContext runtime)
 {
     throw new SitcomCompileException(keyword);
 }
 public abstract void OnExecute(SitcomContext runtime);
 public abstract void OnStop(SitcomContext runtime);
        public ISitcomResult Call(SitcomContext runtime, object target, string content, object[] args)
        {
            var t = ((SitcomHeap)target).GetValue(id);

            return(domain.Call(runtime, t, content, args));
        }
Exemple #25
0
 public ISitcomResult Call(SitcomContext context, object target, string content, object[] args)
 {
     return(callback(context, (T)target, content, args));
 }