Beispiel #1
0
            void Process(Entity ea, Entity eb)
            {
                Entity self, other;

                if (ea.Index > eb.Index)
                {
                    var tmp = ea;
                    ea = eb;
                    eb = tmp;
                }

                if (ThisMask.Matches(ea) && OtherMask.Matches(eb))
                {
                    self  = ea;
                    other = eb;
                }
                else if (ThisMask.Matches(eb) && OtherMask.Matches(ea))
                {
                    self  = eb;
                    other = ea;
                }
                else
                {
                    return;
                }

                bool found = false;

                if (CollInfos.TryGetFirstValue(self, out var collInfo, out var it))
                {
                    do
                    {
                        if (collInfo.Other != other)// || (collInfo.EventType & EventType) == 0)
                        {
                            continue;
                        }

                        found = true;
                        if (collInfo.Frame == Frame - 1) // had a collision during the prev frame
                        {
                            collInfo.State = CollisionState.Stay;
                            collInfo.Frame = Frame;
                            CollInfos.SetValue(collInfo, it);
                        }

                        break;
                    }while (CollInfos.TryGetNextValue(out collInfo, ref it));
                }

                if (!found) // new collision
                {
                    CollInfos.Add(self, new CollisionTriggerData {
                        Other = other, Frame = Frame, State = CollisionState.Enter, EventType = EventType
                    });
                    CollInfos.Add(other, new CollisionTriggerData {
                        Other = self, Frame = Frame, State = CollisionState.Enter, EventType = EventType
                    });
                }
            }
Beispiel #2
0
 /// <summary>
 /// データ置き換え
 /// </summary>
 /// <param name="func">trueを返せば置換</param>
 /// <param name="rdata">引数にデータを受け取り、修正したデータを返し置換する</param>
 public void Replace(Func <TKey, TValue, bool> func, Func <TValue, TValue> datafunc)
 {
     foreach (var key in useKeyDict.Keys)
     {
         TValue data;
         NativeMultiHashMapIterator <TKey> iterator;
         if (nativeMultiHashMap.TryGetFirstValue(key, out data, out iterator))
         {
             do
             {
                 // 置換判定
                 if (func(key, data))
                 {
                     // 置き換え
                     nativeMultiHashMap.SetValue(datafunc(data), iterator);
                     return;
                 }
             }while (nativeMultiHashMap.TryGetNextValue(out data, ref iterator));
         }
     }
     nativeLength = NativeCount;
 }