Exemplo n.º 1
0
        public IAmbientScope  GetScope(ScopeMode mode)
        {
            var scope = new AmbientScope(ContextFactory.CreateContext(), mode);

            ScopeContainer.SetCurrent(scope, scope.instanceIdentifier);
            return(scope);
        }
Exemplo n.º 2
0
 public DefineNode(NameExpression name, IEnumerable<NameExpression> arguments, INode body, ScopeMode mode)
 {
     this.arguments = new List<NameExpression> (arguments);
     this.body = body;
     this.mode = mode;
     this.name = name;
 }
Exemplo n.º 3
0
        public void Add(string name, Value val, ScopeMode mode = ScopeMode.Local)
        {
            switch (mode)
            {
                case ScopeMode.Local:
                    Local.Add(name, val);
                    break;

                case ScopeMode.Public:
                case ScopeMode.Private:
                    if (HasStatic)
                        (mode == ScopeMode.Public ? Public : Private).Add(name, val);
                    else
                    {
                        foreach (var p in Parents)
                            try
                            {
                                p.Add(name, val, mode);
                                return;
                            }
                            catch (InvalidOperationException)
                            {
                                continue;
                            }

                        // End of list reached
                        throw new InvalidOperationException("Cannot add a static variable to an orphan scope");
                    }
                    break;
            }
        }
Exemplo n.º 4
0
        private IEnumerable <ObjectType> GetRelevantObjects(ScopeMode scope)
        {
            // Rooms
            if (scope == ScopeMode.Everything || scope == ScopeMode.Rooms)
            {
                foreach (Room room in _editor.Level.Rooms.Where(room => room != null))
                {
                    yield return(room);
                }
            }

            // Objects
            if (scope == ScopeMode.Everything || scope == ScopeMode.AllObjects)
            {
                foreach (Room room in _editor.Level.Rooms.Where(room => room != null))
                {
                    foreach (ObjectInstance instance in room.AnyObjects)
                    {
                        yield return(instance);
                    }
                }
            }
            else if (scope == ScopeMode.ObjectsInSelectedRooms)
            {
                foreach (ObjectInstance instance in _editor.SelectedRooms.SelectMany(room => room.AnyObjects))
                {
                    yield return(instance);
                }
            }

            // Item types
            if (scope == ScopeMode.Everything || scope == ScopeMode.ItemTypes)
            {
                foreach (WadStatic obj in _editor.Level.Settings.WadGetAllStatics().Values)
                {
                    yield return(new ItemType(obj.Id, _editor.Level.Settings));
                }
                foreach (WadMoveable obj in _editor.Level.Settings.WadGetAllMoveables().Values)
                {
                    yield return(new ItemType(obj.Id, _editor.Level.Settings));
                }
            }

            // Triggers
            if (scope == ScopeMode.Triggers)
            {
                foreach (Room room in _editor.Level.Rooms.Where(room => room != null))
                {
                    foreach (ObjectInstance instance in room.AnyObjects.Where(o => o is TriggerInstance))
                    {
                        yield return(instance);
                    }
                }
            }
        }
Exemplo n.º 5
0
 private void Init(CompilerFrontEnd cfe, ScopeMode scope)
 {
     Stage = Stages.Init;
     Cfe   = cfe;
     Scope = scope;
     Steps = new Dictionary <Stages, Tuple <Func <Boolean>, Func <float> > >();
     Steps.Add(Stages.Init, new Tuple <Func <bool>, Func <float> >(OnInit, InitProg));
     Steps.Add(Stages.Tokening, new Tuple <Func <bool>, Func <float> >(OnTokenStep, TokenProg));
     Steps.Add(Stages.Syntaxing, new Tuple <Func <bool>, Func <float> >(OnSyntaxStep, SyntaxProg));
     Fs = null;
 }
Exemplo n.º 6
0
 void Update()
 {
     //Handle mode controls
     if (Input.GetKeyDown(StationaryModeKeycode))
     {
         Mode = ScopeMode.Stationary;
         SetStationaryMode();
     }
     if (Input.GetKeyDown(LockedModeKeycode))
     {
         Mode = ScopeMode.Locked;
         SetLockedMode();
     }
 }
Exemplo n.º 7
0
        private void _editor_EditorEventRaised(IEditorEvent obj)
        {
            // Rebuild object list if necessary
            if (_cachedRelevantObjects != null)
            {
                ScopeMode scope = (ScopeMode)comboScope.SelectedItem;
                if (obj is Editor.LoadedWadsChangedEvent && (scope == ScopeMode.ItemTypes || scope == ScopeMode.Everything))
                {
                    ResetCompletely();
                }
                if (obj is Editor.RoomListChangedEvent) // Always rebuild completely when rooms change for now.
                {
                    ResetCompletely();                  // We don't get precise object messages for objects removed with rooms otherwise.
                }
                else if (obj is Editor.SelectedRoomChangedEvent && scope == ScopeMode.ObjectsInSelectedRooms)
                {
                    ResetCompletely();
                }
                else if (obj is IEditorObjectChangedEvent && (scope == ScopeMode.AllObjects || scope == ScopeMode.Everything ||
                                                              scope == ScopeMode.ObjectsInSelectedRooms && ((IEditorObjectChangedEvent)obj).Room == _editor.SelectedRoom ||
                                                              scope == ScopeMode.Triggers && ((IEditorObjectChangedEvent)obj).Object is TriggerInstance))
                {
                    var @event = (IEditorObjectChangedEvent)obj;
                    switch (@event.ChangeType)
                    {
                    case ObjectChangeType.Add:
                        AddObject(@event.Object);
                        break;

                    case ObjectChangeType.Change:
                        UpdateObject(@event.Object);
                        break;

                    case ObjectChangeType.Remove:
                        RemoveObject(@event.Object);
                        break;
                    }
                }
            }
        }
Exemplo n.º 8
0
        void Replication()
        {
            RuntimeSettings settings = RuntimeSettings.Instance;

            DEditorGUI.WithLabel("Simulation Rate", () => {
                settings.framesPerSecond = DEditorGUI.IntFieldOverlay(settings.framesPerSecond, "FixedUpdate Calls / Second");
            });

            DEditorGUI.WithLabel("Network Rate", () => {
                settings.serverSendRate = Mathf.Clamp(settings.serverSendRate, 1, settings.framesPerSecond);

                var ssr = settings.serverSendRate;
                var fps = settings.framesPerSecond;

                string legend = "";

                if (fps == ((fps / ssr) * ssr))
                {
                    legend = (fps / ssr).ToString();
                }
                else
                {
                    legend = System.Math.Round((float)fps / (float)ssr, 2).ToString();
                }

                settings.serverSendRate = Mathf.Clamp(DEditorGUI.IntFieldOverlay(settings.serverSendRate, string.Format("{0} Packets / Second", legend)), 1, fps);
            });

            DEditorGUI.WithLabel("Sendrate Throttling? ", () =>
            {
                settings.allowSendRateThrottling = DEditorGUI.ToggleButton("On", "Off", settings.allowSendRateThrottling);
            });

            DEditorGUI.WithLabel("Disable Dejitter Buffer", () => {
                settings.disableDejitterBuffer = EditorGUILayout.Toggle(settings.disableDejitterBuffer);
            });

            UnityEditor.EditorGUI.BeginDisabledGroup(settings.disableDejitterBuffer);

            DEditorGUI.WithLabel("Dejitter Delay", () => {
                settings.serverDejitterDelayMin = Mathf.Max(0, DEditorGUI.IntFieldOverlay(settings.serverDejitterDelayMin, "Min"));
                settings.serverDejitterDelay    = Mathf.Max(1, DEditorGUI.IntFieldOverlay(settings.serverDejitterDelay, "Frames"));
                settings.serverDejitterDelayMax = Mathf.Max(settings.serverDejitterDelay + 1, DEditorGUI.IntFieldOverlay(settings.serverDejitterDelayMax, "Max"));
            });

            UnityEditor.EditorGUI.EndDisabledGroup();

            DEditorGUI.WithLabel("Scoping Mode", () => {
                ScopeMode previous = settings.scopeMode;
                settings.scopeMode = (ScopeMode)EditorGUILayout.EnumPopup(settings.scopeMode);

                if (previous != settings.scopeMode)
                {
                    settings.scopeModeHideWarningInGui = false;
                    Save();
                }
            });

            DEditorGUI.WithLabel("Instantiate Mode", () => {
                settings.clientCanInstantiateAll = DEditorGUI.ToggleDropdown("Client Can Instantiate Everything", "Individual Setting On Each Prefab", settings.clientCanInstantiateAll);
            });

            if ((settings.scopeMode == ScopeMode.Manual) && (settings.scopeModeHideWarningInGui == false))
            {
                EditorGUILayout.HelpBox("When manual scoping is enabled you are required to call AscensionEntity.SetScope for each connection that should receive a replicated copy of the entity.", UnityEditor.MessageType.Warning);

                if (GUILayout.Button("I understand, hide this warning", EditorStyles.miniButton))
                {
                    settings.scopeModeHideWarningInGui = true;
                    Save();
                }
            }

            DEditorGUI.WithLabel("Override Timescale? ", () => {
                settings.overrideTimeScale = DEditorGUI.ToggleButton("On", "Off", settings.overrideTimeScale);
            });

            DEditorGUI.WithLabel("Max Connections", () => {
                settings.maxDefaultConnections = DEditorGUI.IntFieldOverlay(settings.maxDefaultConnections, "");
            });

            //Set the client and server settings the same
            settings.clientSendRate         = settings.serverSendRate;
            settings.clientDejitterDelay    = settings.serverDejitterDelay;
            settings.clientDejitterDelayMin = settings.serverDejitterDelayMin;
            settings.clientDejitterDelayMax = settings.serverDejitterDelayMax;
        }
Exemplo n.º 9
0
 void Start()
 {
     Mode = ScopeMode.Stationary;
     _stationaryScopeTransform = transform;
 }
Exemplo n.º 10
0
        public bool Set(Value name, Value value, ScopeMode set)
        {
            HashSet<Value>  level;
            Stack<Value>    stack;

            if (!this.stacks.TryGetValue (name, out stack))
            {
                stack = new Stack<Value> ();

                this.stacks[name] = stack;
            }

            level = this.levels.Peek ();

            switch (set)
            {
                case ScopeMode.Closest:
                    if (stack.Count > 0)
                        stack.Pop ();

                    break;

                case ScopeMode.Local:
                    if (!level.Add (name))
                        stack.Pop ();

                    break;
            }

            stack.Push (value);

            return true;
        }
Exemplo n.º 11
0
 public SyntaxBuilder(CompilerFrontEnd cfe, StreamReader stream, ScopeMode scope = ScopeMode.Module)
 {
     Init(cfe, scope);
     Fs = stream;
 }
Exemplo n.º 12
0
            public static Bitmap ResizeByScope(Bitmap OriginalImage, int ScopeWidth, int ScopeHeight, ScopeMode ScopeMode = ScopeMode.InScope)
            {
                Bitmap ScopeBitmap = new Bitmap(ScopeWidth, ScopeHeight);

                double WidthPercentage = (double)OriginalImage.Width / (double)ScopeWidth;
                double HeightPercentage = (double)OriginalImage.Height / (double)ScopeHeight;

                //確定縮放模式
                Bitmap ResizedBitmap = null;
                switch (ScopeMode)
                {
                    case ScopeMode.InScope:
                        if (WidthPercentage > HeightPercentage)
                        { ResizedBitmap = Resize(OriginalImage, ScopeWidth, ResizeMode.ByWidth); }
                        else
                        { ResizedBitmap = Resize(OriginalImage, ScopeHeight, ResizeMode.ByHeight); }
                        break;

                    case ScopeMode.OutScope:
                        if (WidthPercentage > HeightPercentage)
                        { ResizedBitmap = Resize(OriginalImage, ScopeHeight, ResizeMode.ByHeight); }
                        else
                        { ResizedBitmap = Resize(OriginalImage, ScopeWidth, ResizeMode.ByWidth); }
                        break;
                }

                //置中座標補償
                int LeftX = (ScopeBitmap.Width - ResizedBitmap.Width) / 2;
                int TopY = (ScopeBitmap.Height - ResizedBitmap.Height) / 2;

                //Graphics
                System.Drawing.Graphics gr = System.Drawing.Graphics.FromImage(ScopeBitmap);
                gr.Clear(Color.Black);
                gr.DrawImage(ResizedBitmap, LeftX, TopY, ResizedBitmap.Width, ResizedBitmap.Height);

                return ScopeBitmap;
            }
Exemplo n.º 13
0
 public SyntaxBuilder(CompilerFrontEnd cfe, String path, ScopeMode scope = ScopeMode.Module)
 {
     Init(cfe, scope);
     FileName = path;
 }
Exemplo n.º 14
0
 public Declaration(string name, IExpression body = null, ScopeMode mode = ScopeMode.Local)
 {
     this.Name = name;
     this.Body = body ?? GTVoid.Void;
     this.Mode = mode;
 }
Exemplo n.º 15
0
 public bool Set(Scope scope, Value value, ScopeMode mode)
 {
     return scope.Set (this.name, value, mode);
 }
Exemplo n.º 16
0
 public SetNode(NameExpression name, IExpression expression, ScopeMode mode)
 {
     this.expression = expression;
     this.mode = mode;
     this.name = name;
 }
Exemplo n.º 17
0
 /// <summary>
 /// OAuthでQiitaに接続します
 /// </summary>
 /// <param name="client_id">クライアントID</param>
 /// <param name="client_secret">クライアントシークレット</param>
 /// <param name="mode">Qiita権限)</param>
 public Auth(string client_id, string client_secret, ScopeMode mode = ScopeMode.READ_WRITE)
 {
     AuthURL           = $"{Url.BASE_URL}api/v2/oauth/authorize?client_id={client_id}&scope={scopemode[(int)mode]}";
     this.ClientID     = client_id;
     this.ClientSecret = client_secret;
 }