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


C# IntVec3.GetSlotGroup方法代码示例

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


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

示例1: IsValidStorageFor

 // duplicated to make changes
 public bool IsValidStorageFor(IntVec3 c, Thing storable)
 {
     // call duplicated to make changes
     if (!WorkGiver_HaulGeneral.NoStorageBlockersIn(c, storable))
     {
         return false;
     }
     SlotGroup slotGroup = c.GetSlotGroup();
     return slotGroup != null && slotGroup.Settings.AllowedToAccept(storable);
 }
开发者ID:Wivex,项目名称:ContainersForStuff,代码行数:11,代码来源:JobDriver_HaulToCell.cs

示例2: TryPlaceDirect

        // duplicated to make changes (added container support)
        public bool TryPlaceDirect(Thing thing, IntVec3 loc, out Thing resultingThing)
        {
            // boolean success indicator
            bool flag = false;

            // container code part
            List<Thing> list = Find.ThingGrid.ThingsListAt(loc);
            if (list.Exists(storage => storage.TryGetComp<CompContainer>() != null))
            {
                resultingThing = null;

                // stackables (like resources)
                if (thing.def.stackLimit > 1)
                {
                    foreach (Thing item in list)

                    {
                        if (!item.CanStackWith(thing))
                        {
                            continue;
                        }
                        // if item can stack with another
                        else
                        {
                            // Required, because thing reference is changed to the absorber, if absorbed
                            Thing t = thing;
                            if (item.TryAbsorbStack(thing, true))
                            {
                                // Clean up to prevent haulables lists overflow
                                RemoveHaulableFromLists(t);
                                // it gets absorbed and destroyed
                                resultingThing = item;
                                return !flag;
                            }
                        }
                    }
                }

                resultingThing = GenSpawn.Spawn(thing, loc);

                // Clean up to prevent haulables lists overflow
                RemoveHaulableFromLists(thing);

                return !flag;
            }

            // vanilla code part
            if (thing.stackCount > thing.def.stackLimit)
            {
                thing = thing.SplitOff(thing.def.stackLimit);
                flag = true;
            }
            if (thing.def.stackLimit > 1)
            {
                List<Thing> thingList = loc.GetThingList();
                int i = 0;
                while (i < thingList.Count)
                {
                    Thing thing2 = thingList[i];
                    if (!thing2.CanStackWith(thing))
                    {
                        i++;
                    }
                    else
                    {
                        // Required, because thing reference is changed to the absorber, if absorbed
                        Thing t = thing;
                        if (thing2.TryAbsorbStack(thing, true))
                        {
                            // Clean up to prevent haulables lists overflow
                            RemoveHaulableFromLists(t);
                            resultingThing = thing2;
                            return !flag;
                        }
                        resultingThing = null;
                        return false;
                    }
                }
            }

            resultingThing = GenSpawn.Spawn(thing, loc);
            // Clean up to prevent haulables lists overflow
            RemoveHaulableFromLists(thing);

            SlotGroup slotGroup1 = loc.GetSlotGroup();
            if (slotGroup1 != null && slotGroup1.parent != null)
            {
                slotGroup1.parent.Notify_ReceivedThing(resultingThing);
            }
            return !flag;
        }
开发者ID:Wivex,项目名称:ContainersForStuff,代码行数:92,代码来源:JobDriver_HaulToCell.cs

示例3: TryPlaceDirect

        // allows to place items to container stacks
        public static bool TryPlaceDirect(Thing thing, IntVec3 loc, out Thing resultingThing,
            Action<Thing, int> placedAction = null)
        {
            #region CONTAINER CASE

            var container =
                Find.ThingGrid.ThingsListAt(loc).Find(building => building is Container && building.Spawned) as
                    Container;
            if (container != null)
            {
                // stackables (like resources)
                if (thing.def.stackLimit > 1)
                {
                    foreach (var item in container.StoredItems)
                    {
                        // if item can stack with another
                        // Required, because thing reference is changed to the absorber, if absorbed
                        if (item.TryAbsorbStack(thing, true))
                        {
                            // former item gets absorbed and destroyed
                            resultingThing = item;
                            // hide texture and label of the stored item
                            container.HideItem(resultingThing);
                            return true;
                        }
                    }
                }

                resultingThing = GenSpawn.Spawn(thing, loc);
                // hide texture and label of the stored item
                container.HideItem(resultingThing);

                return true;
            }

            #endregion

            #region VANILLA CASE

            // used to keep original thing reference
            var initialThing = thing;
            var flag = false;
            if (thing.stackCount > thing.def.stackLimit)
            {
                thing = thing.SplitOff(thing.def.stackLimit);
                flag = true;
            }
            if (thing.def.stackLimit > 1)
            {
                var thingList = loc.GetThingList();
                var i = 0;
                while (i < thingList.Count)
                {
                    var thing3 = thingList[i];
                    if (!thing3.CanStackWith(thing))
                    {
                        i++;
                    }
                    else
                    {
                        var stackCount = thing.stackCount;
                        if (thing3.TryAbsorbStack(thing, true))
                        {
                            resultingThing = thing3;
                            placedAction?.Invoke(thing3, stackCount);
                            return !flag;
                        }
                        resultingThing = null;
                        if (placedAction != null && stackCount != thing.stackCount)
                        {
                            placedAction(thing3, stackCount - thing.stackCount);
                        }
                        if (initialThing != thing)
                        {
                            initialThing.TryAbsorbStack(thing, false);
                        }
                        return false;
                    }
                }
            }
            resultingThing = GenSpawn.Spawn(thing, loc);
            placedAction?.Invoke(thing, thing.stackCount);
            var slotGroup = loc.GetSlotGroup();
            slotGroup?.parent?.Notify_ReceivedThing(resultingThing);
            return !flag;

            #endregion
        }
开发者ID:RWA-Team,项目名称:RimworldAscension,代码行数:89,代码来源:RA_GenPlace.cs


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