Beispiel #1
0
 internal BlockInfo(BlockType blockType, TBlock block, Tag tag, bool isSection)
     : this()
 {
     this.BlockType = blockType;
     this.Block     = block;
     this.Tag       = tag;
     this.IsSection = isSection;
 }
Beispiel #2
0
        public void MoveBlock(int index_y, int index_x)
        {
            TBlock nextblock = BlockList[index_y][index_x];

            if (index_x > X_len || index_y > Y_len || index_y < 0 || index_x < 0)
            {
                BlockList[index_y][index_x] = nextblock;
            }
        }
Beispiel #3
0
            public void SetExceptionFinallyState(TBlock block, TValue state)
            {
                if (!cfg.TryGetEnclosingFinally(block, out _))
                {
                    throw new InvalidOperationException();
                }

                exceptionFinallyState[block] = state;
            }
Beispiel #4
0
 public static void resetColors()
 {
     OBlock.resetColor();
     IBlock.resetColor();
     TBlock.resetColor();
     JBlock.resetColor();
     LBlock.resetColor();
     SBlock.resetColor();
     ZBlock.resetColor();
 }
Beispiel #5
0
            public bool TryGetExceptionState(TBlock block, out Box <TValue>?state)
            {
                state = null;
                if (!cfg.TryGetEnclosingTryOrCatchOrFilter(block, out TRegion? tryOrCatchOrFilterRegion))
                {
                    return(false);
                }

                state = GetExceptionState(tryOrCatchOrFilterRegion);
                return(true);
            }
Beispiel #6
0
        private void DiscardColors(OptionArgs args)
        {
            OBlock.resetColor();
            IBlock.resetColor();
            TBlock.resetColor();
            JBlock.resetColor();
            LBlock.resetColor();
            SBlock.resetColor();
            ZBlock.resetColor();

            ColorData.saveColors();
        }
Beispiel #7
0
        private void Reset(OptionArgs args)
        {
            BlockType.textureAsset = "Game/Bricks/Cat-Eye Brick";

            OBlock.resetColor();
            IBlock.resetColor();
            TBlock.resetColor();
            JBlock.resetColor();
            LBlock.resetColor();
            SBlock.resetColor();
            ZBlock.resetColor();

            ColorData.saveColors();
        }
Beispiel #8
0
        private void GenerateProperties()
        {
            blockMembers.Clear();
            blockProperties.Clear();

            GetScrollableProps();
            GetScrollableActions();

            tick = 0;
            Update();

            duplicator.UpdateBlockMembers();
            prioritizer.SetBlockMembers(TBlock.GetType(), blockMembers);
        }
Beispiel #9
0
            public bool TryGetExceptionFinallyState(TBlock block, out TValue state)
            {
                state = default;
                if (!cfg.TryGetEnclosingFinally(block, out _))
                {
                    return(false);
                }

                if (!exceptionFinallyState.TryGetValue(block, out state))
                {
                    state = lattice.Top;
                    exceptionFinallyState.Add(block, state);
                }
                return(true);
            }
Beispiel #10
0
 public TState Get(TBlock block)
 {
     if (!blockOutput.TryGetValue(block, out TState? state))
     {
         TryGetExceptionState(block, out Box <TValue>?exceptionState);
         state = new TState()
         {
             Lattice   = lattice,
             Current   = lattice.Top,
             Exception = exceptionState
         };
         blockOutput.Add(block, state);
     }
     return(state);
 }
Beispiel #11
0
        BlockType randomize()
        {
            BlockType randomBlock;

            switch (random.Next(1, 8))
            {
            case 1:
                randomBlock = new OBlock();
                break;

            case 2:
                randomBlock = new IBlock();
                break;

            case 3:
                randomBlock = new TBlock();
                break;

            case 4:
                randomBlock = new LBlock();
                break;

            case 5:
                randomBlock = new JBlock();
                break;

            case 6:
                randomBlock = new SBlock();
                break;

            case 7:
                randomBlock = new ZBlock();
                break;

            default:
                randomBlock = new LBlock();
                break;
            }

            randomBlock.load(Game.Content);

            return(randomBlock);
        }
        public void initialize()
        {
            loadingGrid = new GridType(new Vector2(100, 220), new Vector2(20), 3, 3);

            loadingGrid.initialize();

            block = new TBlock();

            SpawnData spawnPoint = new SpawnData();

            spawnPoint.brick1Vector = new Vector2(0, 1);
            spawnPoint.brick2Vector = new Vector2(1, 1);
            spawnPoint.brick3Vector = new Vector2(2, 1);
            spawnPoint.brick4Vector = new Vector2(1, 2);

            block.SpawnPoint = spawnPoint;

            block.initialize();

            block.normal(loadingGrid);
        }
Beispiel #13
0
        /// <summary>
        /// Retrieves all block ITerminalProperty values.
        /// </summary>
        private List <IScrollableProp> GetScrollableProps()
        {
            List <ITerminalProperty> properties = new List <ITerminalProperty>(12);
            List <IScrollableProp>   scrollables;
            IMyBatteryBlock          battery = TBlock as IMyBatteryBlock;
            IMyTerminalControl       terminalControl;
            string name;

            TBlock.GetProperties(properties);
            scrollables = new List <IScrollableProp>(properties.Count);

            foreach (ITerminalProperty prop in properties)
            {
                name            = GetTooltipName(prop);
                terminalControl = prop as IMyTerminalControl;

                if (name.Length > 0 && terminalControl != null && terminalControl.Visible(TBlock))
                {
                    if (prop is ITerminalProperty <bool> )
                    {
                        scrollables.Add(new BoolProperty(name, (ITerminalProperty <bool>)prop, this));
                    }
                    else if (prop is ITerminalProperty <float> )
                    {
                        scrollables.Add(new FloatProperty(name, (ITerminalProperty <float>)prop, this));
                    }
                    else if (prop is ITerminalProperty <Color> )
                    {
                        scrollables.AddRange(ColorProperty.GetColorProperties(name, this, (ITerminalProperty <Color>)prop));
                    }
                }
            }

            if (battery != null)
            {
                scrollables.Add(new BattProperty(battery));
            }

            return(scrollables);
        }
            public void Dispose()
            {
                if (Builder != null)
                {
                    BlockParser.ReturnStringBuilder(Builder);
                    Builder = null;
                }

                if (ContentBuilder != null)
                {
                    BlockParser.ReturnStringBuilder(ContentBuilder);
                    ContentBuilder = null;
                }

                PrefixPriorities = null;
                Rules            = null;
                Generator        = null;
                TagDelimiters    = null;
                Cache            = null;

                Package      = null;
                CurrentBlock = null;
            }
Beispiel #15
0
        /// <summary>
        /// Generates a random block
        /// </summary>
        /// <param name="block">A reference to the Block object that will be affected</param>
        private void GenerateBlock(ref Block block)
        {
            switch (random.Next(0, 7))
            {
            case 0:
                block = new IBlock();
                break;

            case 1:
                block = new LBlock();
                break;

            case 2:
                block = new RLBlock();
                break;

            case 3:
                block = new SBlock();
                break;

            case 4:
                block = new SquareBlock();
                break;

            case 5:
                block = new TBlock();
                break;

            case 6:
                block = new ZBlock();
                break;

            default:
                throw new ArgumentException("Bad block type!");
            }
        }
Beispiel #16
0
 protected abstract void OnExecuting(TBlock block);
Beispiel #17
0
        /// <summary>
        /// Retrieves all block ITerminalProperty values.
        /// </summary>
        private void GetScrollableProps()
        {
            propBuf.Clear();
            TextProperty argProperty = null;

            TBlock.GetProperties(propBuf);

            foreach (ITerminalProperty prop in propBuf)
            {
                var control = prop as IMyTerminalControl;

                if (control != null && control.CanUseControl(TBlock))
                {
                    nameBuilder.Clear();
                    GetTooltipName(prop, nameBuilder);

                    if (nameBuilder.Length > 0)
                    {
                        if (prop is ITerminalProperty <StringBuilder> )
                        {
                            var textProp = prop as ITerminalProperty <StringBuilder>;

                            if (textProp.CanAccessValue(TBlock))
                            {
                                if (prop.Id == "ConsoleCommand")
                                {
                                    argProperty = TextProperty.GetProperty(nameBuilder, textProp, this);
                                }
                                else if (prop.Id == "Name" || prop.Id == "CustomName")
                                {
                                    blockProperties.Insert(0, TextProperty.GetProperty(nameBuilder, textProp, this));
                                }
                                else
                                {
                                    blockProperties.Add(TextProperty.GetProperty(nameBuilder, textProp, this));
                                }
                            }
                        }
                        if (prop is IMyTerminalControlCombobox)
                        {
                            var comboBox = prop as IMyTerminalControlCombobox;

                            if (comboBox.CanAccessValue(TBlock, comboItemBuffer))
                            {
                                blockProperties.Add(ComboBoxProperty.GetProperty(nameBuilder, comboBox, comboItemBuffer, this));
                            }
                        }
                        else if (prop is ITerminalProperty <bool> )
                        {
                            var boolProp = prop as ITerminalProperty <bool>;

                            if (boolProp.CanAccessValue(TBlock))
                            {
                                blockProperties.Add(BoolProperty.GetProperty(nameBuilder, boolProp, this));
                            }
                        }
                        else if (prop is ITerminalProperty <float> )
                        {
                            var floatProp = prop as ITerminalProperty <float>;

                            if (floatProp.CanAccessValue(TBlock))
                            {
                                blockProperties.Add(FloatProperty.GetProperty(nameBuilder, floatProp, this));
                            }
                        }
                        else if (prop is ITerminalProperty <Color> )
                        {
                            var colorProp = prop as ITerminalProperty <Color>;

                            if (colorProp.CanAccessValue(TBlock))
                            {
                                blockProperties.Add(ColorProperty.GetProperty(nameBuilder, colorProp, this));
                            }
                        }
                        else if (prop is ITerminalProperty <Vector3> && prop.Id.Contains("Color"))
                        {
                            var colorProp = prop as ITerminalProperty <Vector3>;

                            if (colorProp.CanAccessValue(TBlock))
                            {
                                blockProperties.Add(HsvColorProperty.GetProperty(nameBuilder, colorProp, this));
                            }
                        }
                    }
                }
            }

            if (argProperty != null)
            {
                blockProperties.Add(argProperty);
            }

            blockMembers.AddRange(blockProperties);
            comboItemBuffer.Clear();
        }
Beispiel #18
0
 public override void SetBlock(TerminalGrid grid, IMyTerminalBlock tBlock)
 {
     base.SetBlock(grid, tBlock);
     ModelOffset = tBlock.WorldAABB.Center - TBlock.GetPosition();
 }
Beispiel #19
0
 /// <summary>
 /// Gets the block's current position.
 /// </summary>
 public Vector3D GetPosition() =>
 TBlock.GetPosition();
Beispiel #20
0
 public Predecessor(TBlock block, ImmutableArray <TRegion> finallyRegions)
 {
     (Block, FinallyRegions) = (block, finallyRegions);
 }
Beispiel #21
0
 public void SetBlock(int _x, int _y, TBlock block)
 {
     BlockList[_y][_x] = block;
 }
Beispiel #22
0
        void tick(double delt)
        {
            lock (TickLock)
            {
                Delta = delt * CVars.g_timescale.ValueD;
                GlobalTickTimeLocal += Delta;
                try
                {
                    opsat += Delta;
                    if (opsat >= 1)
                    {
                        opsat -= 1;
                        OncePerSecondActions();
                    }
                    Schedule.RunAllSyncTasks(Delta);
                    Textures.Update(GlobalTickTimeLocal);
                    TBlock.Tick(Delta);
                    Shaders.Update(GlobalTickTimeLocal);
                    Models.Update(GlobalTickTimeLocal);
                    KeyHandler.Tick();
                    if (RawGamePad != null)
                    {
                        for (int i = 0; i < 4; i++)
                        {
                            if (GamePad.GetCapabilities(i).IsConnected)
                            {
                                RawGamePad.SetVibration(i, GamePadVibration, GamePadVibration);
                            }
                        }
                    }
                    GamePadHandler.Tick(Delta);
                    MouseHandler.Tick();
                    UIConsole.Tick();
                    Commands.Tick();
                    TickWorld(Delta);
                    TickChatSystem();
                    TickInvMenu();
                    CScreen.FullTick(Delta);
                    Sounds.Update(MainWorldView.CameraPos, MainWorldView.CameraTarget - MainWorldView.CameraPos, MainWorldView.CameraUp(), Player.GetVelocity(), Window.Focused);
                    Schedule.RunAllSyncTasks(0);
                    Player.PostTick();
                    TheRegion.SolveJoints();
                    //ProcessChunks();
                }
                catch (Exception ex)
                {
                    SysConsole.Output(OutputType.ERROR, "Ticking: " + ex.ToString());
                }
                PlayerEyePosition = Player.GetCameraPosition();
                RayCastResult rcr;
                Location      forw = Player.ForwardVector();
                bool          h    = TheRegion.SpecialCaseRayTrace(PlayerEyePosition, forw, 100, MaterialSolidity.ANY, IgnorePlayer, out rcr);
                CameraFinalTarget  = h ? new Location(rcr.HitData.Location) - new Location(rcr.HitData.Normal).Normalize() * 0.01: PlayerEyePosition + forw * 100;
                CameraImpactNormal = h ? new Location(rcr.HitData.Normal).Normalize() : Location.Zero;
                CameraDistance     = h ? rcr.HitData.T: 100;
            }
            double cping = Math.Max(LastPingValue, GlobalTickTimeLocal - LastPingTime);

            AveragePings.Push(new KeyValuePair <double, double>(GlobalTickTimeLocal, cping));
            while ((GlobalTickTimeLocal - AveragePings.Peek().Key) > 1)
            {
                AveragePings.Pop();
            }
            APing = 0;
            for (int i = 0; i < AveragePings.Length; i++)
            {
                APing += AveragePings[i].Value;
            }
            APing /= (double)AveragePings.Length;
        }
 public void SetBlock(int _X, int _Y, TBlock _block)
 {
     BlockList[_Y][_X] = _block;
 }