当前位置: 首页>>代码示例>>C#>>正文


C# Level.IntToBlockPos方法代码示例

本文整理汇总了C#中Level.IntToBlockPos方法的典型用法代码示例。如果您正苦于以下问题:C# Level.IntToBlockPos方法的具体用法?C# Level.IntToBlockPos怎么用?C# Level.IntToBlockPos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Level的用法示例。


在下文中一共展示了Level.IntToBlockPos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Physics

        public override void Physics(Level level, int pos)
        {
            BlockPos blockPos = level.IntToBlockPos(pos);
            BlockPos belowBlockPos = blockPos.Diff(0, -1, 0);

            if (!level.Physics.OtherData.ContainsKey(pos)) return;

            var current = (byte)(level.Physics.OtherData[pos] - 1);
            if (current == 0) return;

            int belowPos = level.PosToInt(belowBlockPos);
            byte type = level.BlockData[belowPos];

            if (type == (byte)MCBlocks.LavaStill)
            {
                if (level.Physics.OtherData[belowPos] < current)
                {
                    level.Physics.OtherData.Remove(belowPos);
                    level.Physics.OtherData.Add(belowPos, current);
                }
            }
            else if (Crushable.Contains(type))
            {
                level.Physics.OtherData.Remove(belowPos);
                level.Physics.OtherData.Add(belowPos, current);
                level.PhysicsBlockChange(belowBlockPos, MCBlocks.LavaStill);
            }
            else
            {
                for (int x = -1; x < 2; ++x)
                    for (int z = -1; z < 2; ++z)
                    {
                        if (Math.Abs(x) == 1 && Math.Abs(z) == 1) continue;
                        if (blockPos.X + x < 0 || blockPos.Z + z < 0) continue;

                        BlockPos aroundPos = blockPos.Diff(x, 0, z);

                        if (level.NotInBounds(aroundPos)) continue;

                        int newPos = level.PosToInt(aroundPos);
                        byte newType = level.BlockData[newPos];

                        if (newType == (byte)MCBlocks.LavaStill)
                        {
                            if (level.Physics.OtherData.ContainsKey(newPos))
                            {
                                if (level.Physics.OtherData[newPos] >= current) continue;
                                level.Physics.OtherData[newPos] = current;
                            }
                            else
                            {
                                level.Physics.OtherData.Add(newPos, current);
                            }
                        }
                        else if (Crushable.Contains(newType))
                        {
                            level.Physics.OtherData.Remove(newPos);
                            level.Physics.OtherData.Add(newPos, current);
                            level.PhysicsBlockChange(aroundPos, MCBlocks.LavaStill);
                            //if (level.physics.PhysicsUpdates.Contains(level.PosToInt(aroundBelowPos))) return;
                            //level.physics.PhysicsUpdates.Add(level.PosToInt(aroundBelowPos));
                            return;
                        }
                    }
            }
        }
开发者ID:Merlin33069,项目名称:MineFrog,代码行数:66,代码来源:DefaultBlocks.cs


注:本文中的Level.IntToBlockPos方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。