public static int check(GlobalState globalstate)
 {
     if (check (globalstate as Conditions))
         return GlobalStateCondition.GS_SATISFIED;
     else
         return GlobalStateCondition.GS_NOT_SATISFIED;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Updates the state machine. Should be called every simulation step after the game state is loaded and before the
 /// entity's action is retrieved.
 /// </summary>
 public void Update()
 {
     if (GlobalState != null)
     {
         GlobalState.Run();
     }
     if (CurrentState != null)
     {
         CurrentState.Run();
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a new <see cref="CodeScript"/> with the kusto globals changed.
        /// </summary>
        public CodeScript WithGlobals(GlobalState newGlobals)
        {
            var kustoFactory = this.Factory.GetFactory <KustoCodeServiceFactory>();

            if (kustoFactory != null)
            {
                return(WithFactory(this.Factory.WithFactory(kustoFactory.WithGlobals(newGlobals))));
            }

            return(this);
        }
Exemplo n.º 4
0
        public int CheckGlobalState(string globalState)
        {
            int         ret = GlobalStateCondition.GS_SATISFIED;
            GlobalState gs  = data.getChapters()[currentChapter].getGlobalState(globalState);

            if (gs != null)
            {
                ret = ConditionChecker.check(gs);
            }
            return(ret);
        }
Exemplo n.º 5
0
    public void Update()
    {
        if (GlobalState != null)
        {
            GlobalState.Execute(Owner);
        }

        if (CurrentState != null)
        {
            CurrentState.Execute(Owner);
        }
    }
Exemplo n.º 6
0
        public GlobalState this[GlobalState.StateType i]
        {
            get
            {
                return fStates[(int)i];
            }

            set
            {
                fStates[(int)i] = value;
            }
        }
Exemplo n.º 7
0
 private void Awake()
 {
     if (_state != null && _state != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         // DontDestroyOnLoad(this);
         _state = this;
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// Processes the specified message.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <param name="message">The message.</param>
        public void ProcessMessage(TEntity entity, IMessage message)
        {
            if (CurrentState != null && CurrentState.ProcessMessage(message))
            {
                return;
            }

            if (GlobalState != null)
            {
                GlobalState.ProcessMessage(message);
            }
        }
Exemplo n.º 9
0
        private static void MarkMT(GlobalState g)
        {
            int i;

            for (i = 0; i < NUMTAGS; i++)
            {
                if (g.mt[i] != null)
                {
                    MarkObject(g, g.mt[i]);
                }
            }
        }
Exemplo n.º 10
0
        private static void markmt(GlobalState g)
        {
            int i;

            for (i = 0; i < NUM_TAGS; i++)
            {
                if (g.mt[i] != null)
                {
                    markobject(g, g.mt[i]);
                }
            }
        }
Exemplo n.º 11
0
 protected override void innerInit()
 {
     manager_.startBtn_.enabled    = false;
     manager_.continueBtn_.enabled = false;
     manager_.autoBtn_.enabled     = false;
     GlobalState.time(2.0f, (sec, t) => {
         manager_.group_.alpha = t;
         return(true);
     }).finish(() => {
         bFinish_ = true;
     });
 }
Exemplo n.º 12
0
 void debuter()
 {
     // on verifie qu'on ne lance pas deux fois le niveau 1 (qui reviendrait a lancer le niveau 2)
     if (!aDebute)
     {
         aDebute = true;
         // et on lance le niveau 1.
         GlobalState gs = globalState.GetComponent <GlobalState>();
         gs.currentScene++;
         SceneManager.LoadScene(gs.currentScene);
     }
 }
        private KustoCodeService(string text, GlobalState globals, KustoCode code)
            : base(text)
        {
            if (globals == null)
            {
                throw new ArgumentNullException(nameof(globals));
            }

            this.kind          = KustoCode.GetKind(text);
            this.globals       = globals;
            this.lazyBoundCode = code;
        }
Exemplo n.º 14
0
 // 1フレーム
 public GlobalState oneFrame(System.Action action)
 {
     nextState_ = new GlobalState(
         () => {
         action();
         return(false);
     },
         null
         );
     nextState_.preState_ = this;
     return(nextState_);
 }
Exemplo n.º 15
0
        public static void LuaCFreeAll(LuaState L)
        {
            GlobalState g = G(L);
            int         i;

            g.currentwhite = (byte)(WHITEBITS | BitMask(SFIXEDBIT)); /* mask to collect all elements */
            SweepWholeList(L, new RootGCRef(g));
            for (i = 0; i < g.strt.size; i++)                        /* free all string lists */
            {
                SweepWholeList(L, new ArrayRef(g.strt.hash, i));
            }
        }
Exemplo n.º 16
0
        public override void Execute(ResolutionSessionRuntimeContext ctx)
        {
            try
            {
                var sw = Stopwatch.StartNew();

                var allReached = false;

                while (true)
                {
                    allReached = true;

                    int timeout;

                    using (var state = GlobalState.GetState())
                    {
                        if (state.Simulated)
                        {
                            System.Threading.Thread.Sleep(200);
                            return;
                        }
                        foreach (var m in state.Motors.Motors)
                        {
                            var targetPos = ctx.GetTargetPosition(m.Courronne, m.Axe);
                            if (targetPos != null && targetPos != m.Position)
                            {
                                allReached = false;
                            }
                        }

                        timeout = state.HardwareConfigGlobal.WaitTargetReachedInstructionTimeoutMilliseconds;
                    }

                    if (allReached || ctx.CancelAsked)
                    {
                        return;
                    }
                    else if (sw.ElapsedMilliseconds > timeout)
                    {
                        throw new Exception("Tous les moteurs n'ont pas atteint leur position dans le temps imparti");
                    }
                    else
                    {
                        System.Threading.Thread.Sleep(10);
                    }
                }
            }
            finally
            {
                ctx.ResetTargetPositions();
            }
        }
Exemplo n.º 17
0
        public static void Init(GlobalState state)
        {
            if (state != null)
            {
                _state = state;
                BaseRenderer.UpdateState((BaseRenderer)BackgroundRenderer, state);
                BaseRenderer.UpdateState((BaseRenderer)MagicRenderer, state);
            }

            if (IsInitialized)
            {
                return;
            }

            _deviceManager1 = new CommonDX.DeviceManager();
            _deviceManager2 = new CommonDX.DeviceManager();

            _renderer1 = new DxRenderer.BackgroundComposer()
            {
                State = _state
            };
            _renderer2 = new DxRenderer.MagicComposer()
            {
                State = _state
            };


            BackgroundSIS = new SumoNinjaMonkey.Framework.Controls.DrawingSurfaceSIS(
                (gt) => { _renderer1.Update(gt); },
                (tb) => { _renderer1.Render(tb); },
                (dm) => { _renderer1.Initialize(dm); },
                (e1, e2) => { _renderer1.InitializeUI(e1, e2); },
                (uri) => { _renderer1.LoadLocalAsset(uri); },
                () => { _renderer1.Unload(); },
                _deviceManager1);
            //_renderer1, _deviceManager1);



            MagicSIS = new SumoNinjaMonkey.Framework.Controls.DrawingSurfaceSIS(
                (gt) => { _renderer2.Update(gt); },
                (tb) => { _renderer2.Render(tb); },
                (dm) => { _renderer2.Initialize(dm); },
                (e1, e2) => { _renderer2.InitializeUI(e1, e2); },
                (uri) => { _renderer2.LoadLocalAsset(uri); },
                () => { _renderer2.Unload(); },
                _deviceManager2);
            //_renderer2, _deviceManager2);


            IsInitialized = true;
        }
Exemplo n.º 18
0
 public static void load_stat()
 {
     try {
         StreamReader reader = new StreamReader(ResManager.data_path());
         string       json   = reader.ReadToEnd();
         m_state = JsonUtility.FromJson <GlobalState>(json);
         reader.Close();
         loaded = true;
     }
     catch (Exception e) {
         Debug.LogError(e);
     }
 }
Exemplo n.º 19
0
        private static void RemarkUpVals(GlobalState g)
        {
            UpVal uv;

            for (uv = g.uvhead.u.l.next; uv != g.uvhead; uv = uv.u.l.next)
            {
                LuaAssert(uv.u.l.next.u.l.prev == uv && uv.u.l.prev.u.l.next == uv);
                if (IsGray(obj2gco(uv)))
                {
                    MarkValue(g, uv.v);
                }
            }
        }
Exemplo n.º 20
0
        public CNCViewModel()
        {
            Gs = GlobalState.Load();

            InitializeHID(Gs.CNCDeviceHIDPath);
            //Log
            Gs.Log = new FixedSizedQueue <string> {
                Limit = 7
            };
            Gs.ProcessingGCode   = new Queue <string>();
            Gs.Log.QueueChanged += Log_QueueChanged;
            PropertyChanged     += CNCViewModel_PropertyChanged;
        }
Exemplo n.º 21
0
 void Start()
 {
     if (instance != null &&
         instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         DontDestroyOnLoad(this.gameObject);
         instance = this;
     }
 }
        public void ClearEmptiesInventory()
        {
            IGlobalState state = new GlobalState();

            state.Add("test", 8);
            state.Add("test2", "Steve");

            Assert.AreEqual(2, state.Count());

            state.Clear();

            Assert.AreEqual(0, state.Count());
        }
Exemplo n.º 23
0
 public BioFilm(EntityPreset preset, Player p) : base(preset.Position, "biofilm", 32, 32, Drawing.DrawOrder.BG_ENTITIES)
 {
     _preset = preset;
     if (!preset.Activated)
     {
         GlobalState.SpawnEntity(new DoorToggle(Position, 32, 32));
         SetFrame(0);
     }
     else
     {
         SetFrame(1);
     }
 }
Exemplo n.º 24
0
        ///////////////////////////////////////////////////////////////////////////////////////////////

        public StringPairList ToList(bool scrub)
        {
            StringPairList list = new StringPairList();

            list.Add("FileName", scrub ? PathOps.ScrubPath(
                         GlobalState.GetBasePath(), fileName) : fileName);

            list.Add("StartLine", startLine.ToString());
            list.Add("EndLine", endLine.ToString());
            list.Add("ViaSource", viaSource.ToString());

            return(list);
        }
Exemplo n.º 25
0
        private static void remarkupvals(GlobalState g)
        {
            UpVal uv;

            for (uv = g.uvhead.u.l.next; uv != g.uvhead; uv = uv.u.l.next)
            {
                lua_assert(uv.u.l.next.u.l.prev == uv && uv.u.l.prev.u.l.next == uv);
                if (isgray(obj2gco(uv)))
                {
                    markvalue(g, uv.v);
                }
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// Handle messages.
        /// </summary>
        /// <param name="msg">
        /// The message.
        /// </param>
        /// <returns>
        /// True if message was handled. Otherwise, false.
        /// </returns>
        public bool HandleMessage(Telegram msg)
        {
            // first see if the current state is valid and that it can handle
            // the message
            if (CurrentState != null && CurrentState.OnMessage(Owner, msg))
            {
                return(true);
            }

            // if not, and if a global state has been implemented, send
            // the message to the global state
            return(GlobalState != null && GlobalState.OnMessage(Owner, msg));
        }
Exemplo n.º 27
0
 public void LeaveFrom()
 {
     if (_capture != null)
     {
         _capture.Stop();
         _capture.Dispose();
         _capture = null;
     }
     using (var state = GlobalState.GetState())
     {
         MainForm.Instance.Viewer.RefreshCube(state.InitialCube);
     }
 }
Exemplo n.º 28
0
 void Start()
 {
     if (instance != null &&
         instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         DontDestroyOnLoad(this.gameObject);
         instance = this;
     }
 }
Exemplo n.º 29
0
    public void ContinueClicked()
    {
        Debug.Log("Continnue called");
        var curLevel       = GlobalState.CurrentLevel;
        var levelsUnlocked = GlobalState.LevelsUnlocked;

        if (curLevel + 1 > levelsUnlocked)
        {
            GlobalState.incrementLevelsUnlocked();
        }

        SceneManager.LoadScene("LevelSelectScene");
    }
Exemplo n.º 30
0
    public override void WhenSpawn()
    {
        ani_State = "isWalk";

        CurrentState = wolf_Wander;
        GlobalState  = wolf_Global;
        coroutine    = CurrentState.Excute(this);

        StartCoroutine(coroutine);
        ani.SetBool("isWalk", true);
        StartCoroutine(GlobalState.Excute(this));
        StartCoroutine(fov.DelayFieldOfView());
    }
Exemplo n.º 31
0
    new private void Start()
    {
        base.Start();
        if (player == null)
        {
            player = GlobalState.FindPlayer();
        }

        if (xRange == -1)
        {
            xRange = myCollider.bounds.extents.x;   //Get half of the collider
        }
    }
Exemplo n.º 32
0
        public GlobalStateManager(ServerCore server)
        {
            _server = server;

            GlobalState = _server.EntityStorage.LoadState();

            if (GlobalState == null)
            {
                GlobalState = new GlobalState();
            }

            _saveTimer = new Timer(o => Save(), null, 60 * 1000, 60 * 1000);
        }
Exemplo n.º 33
0
        public static void BackgroundSolve()
        {
            Task.Factory.StartNew(() =>
            {
                MainForm.Instance.Viewer.RefreshCube();

                try
                {
                    ColorCube cube;
                    using (var state = GlobalState.GetState())
                    {
                        cube = state.InitialCube.CloneCube();
                        state.SolutionInCalculation = true;
                        state.Solution = null;
                    }

                    Solution solution = null;

                    using (var task = Task.Factory.StartNew(() =>
                    {
                        solution = Modele.Solver.Solve(cube);
                    }))
                    {
                        if (!task.Wait(TimeSpan.FromSeconds(5)))
                        {
                            throw new Exception("Timeout à la résolution");
                        }
                    }
                    using (var state = GlobalState.GetState())
                    {
                        state.Solution = solution;
                    }
                    ResolutionSession.FromSolution();
                }
                catch (Exception ex)
                {
                    Logger.Log(ex);
                    using (var state = GlobalState.GetState())
                    {
                        state.Solution = null;
                    }
                }
                finally
                {
                    using (var state = GlobalState.GetState())
                    {
                        state.SolutionInCalculation = false;
                    }
                }
            });
        }
Exemplo n.º 34
0
 void Start()
 {
     // GlobalState[] objs = FindObjectsOfType(typeof(GlobalState)) as GlobalState[];
     if (instance != null &&
         instance != this)
     {
         Destroy(this.gameObject);
     }
     else
     {
         DontDestroyOnLoad(this.gameObject);
         instance = this;
     }
 }
Exemplo n.º 35
0
 public void ChangeOperationType(GlobalState state)
 {
     switch (state)
     {
         case GlobalState.DRAG_WHITEBALL:
             SetOpeartion(dragOperation);
             break;
         case GlobalState.IDLE:
             SetOpeartion(pointerOperation);
             break;
         default:
             SetOpeartion(m_DontDoAnyOperation);
             break;
     }
 }
Exemplo n.º 36
0
Arquivo: lgc.cs Projeto: NLua/KopiLua
 private static void RemarkUpVals(GlobalState g)
 {
     UpVal uv;
       for (uv = g.uvhead.u.l.next; uv != g.uvhead; uv = uv.u.l.next) {
     LuaAssert(uv.u.l.next.u.l.prev == uv && uv.u.l.prev.u.l.next == uv);
     if (IsGray(obj2gco(uv)))
       MarkValue(g, uv.v);
       }
 }
Exemplo n.º 37
0
Arquivo: lgc.cs Projeto: NLua/KopiLua
 private static void ReallyMarkObject(GlobalState g, GCObject o)
 {
     LuaAssert(IsWhite(o) && !IsDead(g, o));
       White2Gray(o);
       switch (o.gch.tt) {
     case LUA_TSTRING: {
       return;
     }
     case LUA_TUSERDATA: {
       Table mt = gco2u(o).metatable;
       Gray2Black(o);  /* udata are never gray */
       if (mt != null) MarkObject(g, mt);
       MarkObject(g, gco2u(o).env);
       return;
     }
     case LUATUPVAL: {
       UpVal uv = gco2uv(o);
       MarkValue(g, uv.v);
       if (uv.v == uv.u.value)  /* closed? */
         Gray2Black(o);  /* open upvalues are never black */
       return;
     }
     case LUA_TFUNCTION: {
       gco2cl(o).c.gclist = g.gray;
       g.gray = o;
       break;
     }
     case LUA_TTABLE: {
       gco2h(o).gclist = g.gray;
       g.gray = o;
       break;
     }
     case LUA_TTHREAD: {
       gco2th(o).gclist = g.gray;
       g.gray = o;
       break;
     }
     case LUATPROTO: {
       gco2p(o).gclist = g.gray;
       g.gray = o;
       break;
     }
     default: LuaAssert(0); break;
       }
 }
Exemplo n.º 38
0
        private void SetState(GlobalState state)
        {

            switch (state)
            {
                case GlobalState.AddingMass:
                    lblCurrentInstruction.Text = "Add Mass";
                    lblCurrentInstruction.Visible = true;
                    chkRunning.Checked = false;
                    break;

                case GlobalState.AddingThruster:
                    lblCurrentInstruction.Text = "Add Thrusters (" + _addThrusterTo.ToString() + ")";
                    lblCurrentInstruction.Visible = true;
                    chkRunning.Checked = false;
                    break;

                case GlobalState.Running:
                    lblCurrentInstruction.Text = "";
                    lblCurrentInstruction.Visible = false;
                    break;

                default:
                    throw new ApplicationException("Unknown GlobalState: " + state.ToString());
            }

            _state = state;

        }
Exemplo n.º 39
0
 internal static void CheckLiveness(GlobalState g, TValue obj)
 {
     LuaAssert(!IsCollectable(obj) ||
     ((TType(obj) == obj.value.gc.gch.tt) && !IsDead(g, obj.value.gc)));
 }
Exemplo n.º 40
0
 private static void preinit_state(LuaState L, GlobalState g)
 {
     G_set(L, g);
       L.stack = null;
       L.stacksize = 0;
       L.errorJmp = null;
       L.hook = null;
       L.hookmask = 0;
       L.basehookcount = 0;
       L.allowhook = 1;
       ResetHookCount(L);
       L.openupval = null;
       L.size_ci = 0;
       L.nCcalls = L.baseCcalls = 0;
       L.status = 0;
       L.base_ci = null;
       L.ci = null;
       L.savedpc = new InstructionPtr();
       L.errfunc = 0;
       SetNilValue(Gt(L));
 }
Exemplo n.º 41
0
 public RootGCRef(GlobalState g)
 {
     this.g = g;
 }
Exemplo n.º 42
0
Arquivo: lgc.cs Projeto: NLua/KopiLua
 private static void TraverseStack(GlobalState g, LuaState l)
 {
     StkId o, lim;
       CallInfo ci;
       MarkValue(g, Gt(l));
       lim = l.top;
       for (ci = l.base_ci[0]; ci < l.ci; CallInfo.Inc(ref ci)) {
     LuaAssert(ci.top <= l.stack_last);
     if (lim < ci.top) lim = ci.top;
       }
       for (o = l.stack[0]; o < l.top; StkId.Inc(ref o))
     MarkValue(g, o);
       for (; o <= lim; StkId.Inc(ref o))
     SetNilValue(o);
       CheckStackSizes(l, lim);
 }
Exemplo n.º 43
0
Arquivo: lgc.cs Projeto: NLua/KopiLua
 public static int OtherWhite(GlobalState g)
 {
     return g.currentwhite ^ WHITEBITS;
 }
Exemplo n.º 44
0
Arquivo: lgc.cs Projeto: NLua/KopiLua
 public static void MarkValue(GlobalState g, TValue o)
 {
     CheckConsistency(o);
     if (IsCollectable(o) && IsWhite(GCValue(o)))
         ReallyMarkObject(g,GCValue(o));
 }
Exemplo n.º 45
0
Arquivo: lgc.cs Projeto: NLua/KopiLua
 public static void MarkObject(GlobalState g, object t)
 {
     if (IsWhite(obj2gco(t)))
         ReallyMarkObject(g, obj2gco(t));
 }
Exemplo n.º 46
0
Arquivo: lgc.cs Projeto: NLua/KopiLua
 public static void MakeWhite(GlobalState g, GCObject x)
 {
     x.gch.marked = (byte)(x.gch.marked & maskmarks | LuaCWhite(g));
 }
Exemplo n.º 47
0
Arquivo: lgc.cs Projeto: NLua/KopiLua
 public static byte LuaCWhite(GlobalState g)
 {
     return (byte)(g.currentwhite & WHITEBITS);
 }
Exemplo n.º 48
0
Arquivo: lgc.cs Projeto: NLua/KopiLua
 public static bool IsDead(GlobalState g, GCObject v)
 {
     return (v.gch.marked & OtherWhite(g) & WHITEBITS) != 0;
 }
Exemplo n.º 49
0
 public static TValue gfasttm(GlobalState g, Table et, TMS e)
 {
     return (et == null) ? null :
     ((et.flags & (1 << (int)e)) != 0) ? null :
     luaT_gettm(et, e, g.tmname[(int)e]);
 }
Exemplo n.º 50
0
Arquivo: lgc.cs Projeto: NLua/KopiLua
 private static void TraverseClosure(GlobalState g, Closure cl)
 {
     MarkObject(g, cl.c.env);
       if (cl.c.isC != 0) {
     int i;
     for (i=0; i<cl.c.nupvalues; i++)  /* mark its upvalues */
       MarkValue(g, cl.c.upvalue[i]);
       }
       else {
     int i;
     LuaAssert(cl.l.nupvalues == cl.l.p.nups);
     MarkObject(g, cl.l.p);
     for (i=0; i<cl.l.nupvalues; i++)  /* mark its upvalues */
       MarkObject(g, cl.l.upvals[i]);
       }
 }
Exemplo n.º 51
0
Arquivo: lgc.cs Projeto: NLua/KopiLua
 /*
 ** All marks are conditional because a GC may happen while the
 ** prototype is still being created
 */
 private static void TraverseProto(GlobalState g, Proto f)
 {
     int i;
       if (f.source != null) StringMark(f.source);
       for (i=0; i<f.sizek; i++)  /* mark literals */
     MarkValue(g, f.k[i]);
       for (i=0; i<f.sizeupvalues; i++) {  /* mark upvalue names */
     if (f.upvalues[i] != null)
       StringMark(f.upvalues[i]);
       }
       for (i=0; i<f.sizep; i++) {  /* mark nested protos */
     if (f.p[i] != null)
       MarkObject(g, f.p[i]);
       }
       for (i=0; i<f.sizelocvars; i++) {  /* mark local-variable names */
     if (f.locvars[i].varname != null)
       StringMark(f.locvars[i].varname);
       }
 }
Exemplo n.º 52
0
Arquivo: lgc.cs Projeto: NLua/KopiLua
 public static void SetThreshold(GlobalState g)
 {
     g.GCthreshold = (uint)((g.estimate / 100) * g.gcpause);
 }
Exemplo n.º 53
0
Arquivo: lgc.cs Projeto: NLua/KopiLua
 private static int TraverseTable(GlobalState g, Table h)
 {
     int i;
       int weakkey = 0;
       int weakvalue = 0;
       /*const*/ TValue mode;
       if (h.metatable != null)
     MarkObject(g, h.metatable);
       mode = gfasttm(g, h.metatable, TMS.TM_MODE);
       if ((mode != null) && TTIsString(mode)) {  /* is there a weak mode? */
       weakkey = (strchr(SValue(mode), 'k') != null) ? 1 : 0 ;
       weakvalue = (strchr(SValue(mode), 'v') != null) ? 1 : 0;
     if ((weakkey!=0) || (weakvalue!=0)) {  /* is really weak? */
       h.marked &= (byte)~(KEYWEAK | VALUEWEAK);  /* clear bits */
       h.marked |= CastByte((weakkey << KEYWEAKBIT) |
                              (weakvalue << VALUEWEAKBIT));
       h.gclist = g.weak;  /* must be cleared after GC, ... */
       g.weak = obj2gco(h);  /* ... so put in the appropriate list */
     }
       }
       if ((weakkey!=0) && (weakvalue!=0)) return 1;
       if (weakvalue==0) {
     i = h.sizearray;
     while ((i--) != 0)
       MarkValue(g, h.array[i]);
       }
       i = SizeNode(h);
       while ((i--) != 0) {
     Node n = gnode(h, i);
     LuaAssert(TType(gkey(n)) != LUATDEADKEY || TTIsNil(gval(n)));
     if (TTIsNil(gval(n)))
       RemoveEntry(n);  /* remove empty entries */
     else {
       LuaAssert(!TTIsNil(gkey(n)));
       if (weakkey==0) MarkValue(g, gkey(n));
       if (weakvalue==0) MarkValue(g, gval(n));
     }
       }
       return ((weakkey != 0) || (weakvalue != 0)) ? 1 : 0;
 }
Exemplo n.º 54
0
Arquivo: lgc.cs Projeto: NLua/KopiLua
 private static void MarkMT(GlobalState g)
 {
     int i;
       for (i=0; i<NUMTAGS; i++)
     if (g.mt[i] != null) MarkObject(g, g.mt[i]);
 }
Exemplo n.º 55
0
    public override void startElement(string namespaceURI, string sName, string qName, Dictionary<string, string> attrs)
    {
        // If no element is being subparsed, check if we must subparse something
        if (subParsing == NONE)
        {

            //Parse eAdventure attributes
            if (qName.Equals("eAdventure"))
            {
                foreach (KeyValuePair<string, string> entry in attrs)
                {
                    if (entry.Key.Equals("adaptProfile"))
                    {
                        chapter.setAdaptationName(entry.Value.ToString());
                    }
                    if (entry.Key.Equals("assessProfile"))
                    {
                        chapter.setAssessmentName(entry.Value.ToString());
                    }
                }
            }
            // Subparse scene
            else if (qName.Equals("scene"))
            {
                subParser = new SceneSubParser(chapter);
                subParsing = SCENE;
            }

            // Subparse slidescene
            else if (qName.Equals("slidescene") || qName.Equals("videoscene"))
            {
                subParser = new CutsceneSubParser(chapter);
                subParsing = CUTSCENE;
            }

            // Subparse book
            else if (qName.Equals("book"))
            {
                subParser = new BookSubParser(chapter);
                subParsing = BOOK;
            }

            // Subparse object
            else if (qName.Equals("object"))
            {
                subParser = new ItemSubParser(chapter);
                subParsing = OBJECT;
            }

            // Subparse player
            else if (qName.Equals("player"))
            {
                subParser = new PlayerSubParser(chapter);
                subParsing = PLAYER;
            }

            // Subparse character
            else if (qName.Equals("character"))
            {
                subParser = new CharacterSubParser(chapter);
                subParsing = CHARACTER;
            }

            // Subparse conversacion (tree conversation)
            else if (qName.Equals("tree-conversation"))
            {
                subParser = new TreeConversationSubParser(chapter);
                subParsing = CONVERSATION;
            }

            // Subparse conversation (graph conversation)
            else if (qName.Equals("graph-conversation"))
            {
                subParser = new GraphConversationSubParser(chapter);
                subParsing = CONVERSATION;
            }

            // Subparse timer
            else if (qName.Equals("timer"))
            {
                subParser = new TimerSubParser(chapter);
                subParsing = TIMER;
            }

            // Subparse global-state
            else if (qName.Equals("global-state"))
            {
                string id = null;
                foreach (KeyValuePair<string, string> entry in attrs)
                {
                    if (entry.Key.Equals("id"))
                        id = entry.Value.ToString();
                }
                currentGlobalState = new GlobalState(id);
                currentString = string.Empty;
                chapter.addGlobalState(currentGlobalState);
                subParser = new ConditionSubParser(currentGlobalState, chapter);
                subParsing = GLOBAL_STATE;
            }

            // Subparse macro
            else if (qName.Equals("macro"))
            {
                string id = null;
                foreach (KeyValuePair<string, string> entry in attrs)
                {
                    if (entry.Key.Equals("id"))
                        id = entry.Value.ToString();
                }
                currentMacro = new Macro(id);
                currentString = string.Empty;
                chapter.addMacro(currentMacro);
                subParser = new EffectSubParser(currentMacro, chapter);
                subParsing = MACRO;
            }
            // Subparse atrezzo object
            else if (qName.Equals("atrezzoobject"))
            {
                subParser = new AtrezzoSubParser(chapter);
                subParsing = ATREZZO;
            }// Subparse assessment profile
            else if (qName.Equals("assessment"))
            {
                subParser = new AssessmentSubParser(chapter);
                subParsing = ASSESSMENT;
            }// Subparse adaptation profile
            else if (qName.Equals("adaptation"))
            {
                subParser = new AdaptationSubParser(chapter);
                subParsing = ADAPTATION;
            }

        }

        // If an element is being subparsed, spread the call
        if (subParsing != NONE)
        {
            //try {
            subParser.startElement(namespaceURI, sName, qName, attrs);
            //} catch (Exception e) { Debug.LogError(e); }{
            //	System.out.println("Marihuanhell es muy malo pero hemos capturado la excepción");
            //e.printStackTrace();
            //}

        }
    }
Exemplo n.º 56
0
Arquivo: lgc.cs Projeto: NLua/KopiLua
 private static void MarkTMU(GlobalState g)
 {
     GCObject u = g.tmudata;
       if (u != null) {
     do {
       u = u.gch.next;
       MakeWhite(g, u);  /* may be marked, if left from previous GC */
       ReallyMarkObject(g, u);
     } while (u != g.tmudata);
       }
 }
Exemplo n.º 57
0
 public static void G_set(LuaState L, GlobalState s)
 {
     L.l_G = s;
 }
Exemplo n.º 58
0
Arquivo: lgc.cs Projeto: NLua/KopiLua
 private static uint PropagateAll(GlobalState g)
 {
     uint m = 0;
       while (g.gray != null) m += (uint)PropagateMark(g);
       return m;
 }
Exemplo n.º 59
0
 /**
  * Adds a global state to the list of global states in the game
  *
  * @param globalState
  *            the global state to add
  */
 public void addGlobalState(GlobalState globalState)
 {
     globalStates.Add(globalState);
 }
Exemplo n.º 60
0
Arquivo: lgc.cs Projeto: NLua/KopiLua
 /*
 ** traverse one gray object, turning it to black.
 ** Returns `quantity' traversed.
 */
 private static l_mem PropagateMark(GlobalState g)
 {
     GCObject o = g.gray;
       LuaAssert(IsGray(o));
       Gray2Black(o);
       switch (o.gch.tt) {
     case LUA_TTABLE: {
       Table h = gco2h(o);
       g.gray = h.gclist;
       if (TraverseTable(g, h) != 0)  /* table is weak? */
         Black2Gray(o);  /* keep it gray */
         return	GetUnmanagedSize(typeof(Table)) +
                 GetUnmanagedSize(typeof(TValue)) * h.sizearray +
                 GetUnmanagedSize(typeof(Node)) * SizeNode(h);
     }
     case LUA_TFUNCTION: {
       Closure cl = gco2cl(o);
       g.gray = cl.c.gclist;
       TraverseClosure(g, cl);
       return (cl.c.isC != 0) ? SizeCclosure(cl.c.nupvalues) :
                            SizeLclosure(cl.l.nupvalues);
     }
     case LUA_TTHREAD: {
       LuaState th = gco2th(o);
       g.gray = th.gclist;
       th.gclist = g.grayagain;
       g.grayagain = o;
       Black2Gray(o);
       TraverseStack(g, th);
       return	GetUnmanagedSize(typeof(LuaState)) +
                 GetUnmanagedSize(typeof(TValue)) * th.stacksize +
                 GetUnmanagedSize(typeof(CallInfo)) * th.size_ci;
     }
     case LUATPROTO: {
       Proto p = gco2p(o);
       g.gray = p.gclist;
       TraverseProto(g, p);
       return	GetUnmanagedSize(typeof(Proto)) +
                 GetUnmanagedSize(typeof(Instruction)) * p.sizecode +
                 GetUnmanagedSize(typeof(Proto)) * p.sizep +
                 GetUnmanagedSize(typeof(TValue)) * p.sizek +
                 GetUnmanagedSize(typeof(int)) * p.sizelineinfo +
                 GetUnmanagedSize(typeof(LocVar)) * p.sizelocvars +
                 GetUnmanagedSize(typeof(TString)) * p.sizeupvalues;
     }
     default: LuaAssert(0); return 0;
       }
 }