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


C# Building.CalculatePosition方法代码示例

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


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

示例1: HandleWaterSource

        private int HandleWaterSource(ushort buildingID, ref Building data, bool output, int rate, int max, float radius)
        {
            uint num = (uint)(Mathf.Min(rate, max) >> 1);
            if (num == 0u)
            {
                return 0;
            }
            TerrainManager instance = Singleton<TerrainManager>.instance;
            WaterSimulation waterSimulation = instance.WaterSimulation;
            if (data.m_waterSource != 0)
            {
                bool flag = false;
                WaterSource sourceData = waterSimulation.LockWaterSource(data.m_waterSource);
                try
                {
                    if (output)
                    {
                        uint num2 = num;
                        if (num2 < sourceData.m_water >> 3)
                        {
                            num2 = sourceData.m_water >> 3;
                        }
                        sourceData.m_outputRate = num2 + 3u >> 2;
                        sourceData.m_water += num;
                    }
                    else
                    {
                        uint num3 = num;
                        if (num3 < sourceData.m_water >> 3)
                        {
                            num3 >>= 1;
                        }
                        sourceData.m_inputRate = num3 + 3u >> 2;
                        if (num > sourceData.m_water)
                        {
                            num = sourceData.m_water;
                        }
                        if (sourceData.m_water != 0u)
                        {
                            data.m_waterPollution = (byte)Mathf.Min(255f, 255u * sourceData.m_pollution / sourceData.m_water);
                            sourceData.m_pollution = (uint)((ulong)sourceData.m_pollution * (ulong)(sourceData.m_water - num) / (ulong)sourceData.m_water);
                        }
                        else
                        {
                            data.m_waterPollution = 0;
                        }
                        sourceData.m_water -= num;
                        Vector3 vector = sourceData.m_inputPosition;
                        if (!instance.HasWater(VectorUtils.XZ(vector)))
                        {
                            vector = data.CalculatePosition(this.m_waterLocationOffset);
                            if (instance.GetClosestWaterPos(ref vector, radius))
                            {
                                sourceData.m_inputPosition = vector;
                                sourceData.m_outputPosition = vector;
                            }
                            else
                            {
                                flag = true;
                            }
                        }
                    }
                }
                finally
                {
                    waterSimulation.UnlockWaterSource(data.m_waterSource, sourceData);
                }
                if (flag)
                {
                    waterSimulation.ReleaseWaterSource(data.m_waterSource);
                    data.m_waterSource = 0;
                }
            }
            else
            {
                Vector3 vector2 = data.CalculatePosition(this.m_waterLocationOffset);

                WaterSource sourceData2 = default(WaterSource);
                sourceData2.m_type = 2;
                sourceData2.m_inputPosition = vector2;
                sourceData2.m_outputPosition = vector2;

                if (output)
                {
                    sourceData2.m_outputRate = num + 3u >> 2;
                    sourceData2.m_water = num;
                    //  sourceData2.m_pollution = num * (uint)this.m_outletPollution / (uint)Mathf.Max(100, waterSimulation.GetPollutionDisposeRate() * 100);
                    if (!waterSimulation.CreateWaterSource(out data.m_waterSource, sourceData2))
                    {
                        num = 0u;
                    }
                }
                else
                {
                    sourceData2.m_inputRate = num + 3u >> 2;
                    waterSimulation.CreateWaterSource(out data.m_waterSource, sourceData2);
                    num = 0u;
                }

            }
//.........这里部分代码省略.........
开发者ID:firefrorefiddle,项目名称:SkylinesTerraform,代码行数:101,代码来源:WaterOutletAI.cs


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