Пример #1
0
        static void useExit(ISession s, Physical p, Exit x)
        {
            if (x == null) return;
            var origin = p.Location;
            var destination = Exit.GetDestination(s, x);

            // todo: event messages
            using (var tx = s.BeginTransaction())
            {
                foreach (var lis in origin.Contents<Listen>(s))
                {
                    if (lis.Entity != p.Entity)
                    {
                        Event.AddEvent(s, lis.Entity, string.Format("{0} leaves.", p.Name));
                    }
                }
                foreach (var lis in destination.Contents<Listen>(s))
                {
                    if (lis.Entity != p.Entity)
                    {
                        Event.AddEvent(s, lis.Entity, string.Format("{0} enters.", p.Name));
                    }
                }
                MoveToLocation(s, p, destination);
                tx.Commit();
            }
        }
Пример #2
0
 static void MoveToLocation(ISession s, Physical p, Location loc)
 {
     // other components to move with Physicals:
     // Listen
     foreach (var lis in p.Entity.GetComponents<Listen>(s.CreateCriteria<Listen>().Add(Expression.Eq("Location", p.Location))))
     {
         lis.Location = loc;
         s.Update(lis);
     }
     p.Location = loc;
     s.Update(p);
 }