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


C# Thing.TryAbsorbStack方法代码示例

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


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

示例1: PlaceSpotQualityAt

        // overhauled version (vanilla is bugged)
        public static PlaceSpotQuality PlaceSpotQualityAt(IntVec3 c, Thing thing, IntVec3 center)
        {
            if (!c.InBounds() || !c.Walkable())
            {
                return PlaceSpotQuality.Unusable;
            }

            List<Thing> list = Find.ThingGrid.ThingsListAt(c);

            // if other things on cell
            int i = 0;
            while (i < list.Count)
            {
                Thing thing2 = list[i];
                if (thing.def.saveCompressible && thing2.def.saveCompressible)
                {
                    return PlaceSpotQuality.Unusable;
                }
                // same thing type
                if (thing2.def.category == ThingCategory.Item)
                {
                    // can stack with
                    if (thing2.def == thing.def && thing2.stackCount < thing.def.stackLimit)
                    {
                        // can absorb
                        // Required, because thing reference is changed to the absorber, if absorbed
                        Thing t = thing2;
                        if (thing.TryAbsorbStack(thing2, true))
                        {
                            // Clean up to prevent haulables lists overflow
                            RemoveHaulableFromLists(t);
                            return PlaceSpotQuality.Perfect;
                        }
                        // cannot absorb all/anything
                        else
                            return PlaceSpotQuality.Unusable;
                    }
                    return PlaceSpotQuality.Unusable;
                }
                else
                {
                    i++;
                }
            }
            // if in same room
            if (c.GetRoom() == center.GetRoom())
            {
                PlaceSpotQuality placeSpotQuality = PlaceSpotQuality.Perfect;
                for (int j = 0; j < list.Count; j++)
                {
                    Thing thing3 = list[j];
                    if (thing3.def.thingClass == typeof(Building_Door))
                    {
                        return PlaceSpotQuality.Bad;
                    }
                    Pawn pawn = thing3 as Pawn;
                    if (pawn != null)
                    {
                        if (pawn.Downed)
                        {
                            return PlaceSpotQuality.Bad;
                        }
                        if (placeSpotQuality > PlaceSpotQuality.Okay)
                        {
                            placeSpotQuality = PlaceSpotQuality.Okay;
                        }
                    }
                    if (thing3.def.category == ThingCategory.Plant && thing3.def.selectable && placeSpotQuality > PlaceSpotQuality.Okay)
                    {
                        placeSpotQuality = PlaceSpotQuality.Okay;
                    }
                }
                return placeSpotQuality;
            }
            if (!center.CanReach(c, PathEndMode.OnCell, TraverseMode.PassDoors, Danger.Deadly))
            {
                return PlaceSpotQuality.Awful;
            }
            return PlaceSpotQuality.Okay;
        }
开发者ID:Wivex,项目名称:ContainersForStuff,代码行数:81,代码来源:JobDriver_HaulToCell.cs


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