Пример #1
0
 private static void Drop(Drop msg, IActorRef Self, IActorRef MyContainer)
 {
     Self
     .FindContainedObjectByName(msg.Name, findResult =>
     {
         if (!findResult.HasValue)
         {
             Self.Tell(new Notify($"Could not find {msg.Name}"));
         }
         else
         {
             Self.Tell(new Notify($"You drop {findResult.Name}"));
             findResult.Item.Tell(new SetContainer(MyContainer), Self);
         }
     });
 }
Пример #2
0
 private static void StartFight(StartFight msg, string Name, IActorRef Self, IActorRef MyContainer)
 {
     MyContainer.FindContainedObjectByName(msg.TargetName, found =>
     {
         if (found.Item == null)
         {
             Self.Tell(new Notify($"Could not find {msg.TargetName}"));
             return;
         }
         else
         {
             MyContainer.Tell(new ContainerNotify($"{Name} attacks {found.Name}", Self));
             Self.Tell(new Notify($"You start attacking {found.Name}"));
             Self.Tell(new SetTarget(found.Item));
         }
     });
 }
Пример #3
0
        private static void Take(Take msg, IActorRef Self, IActorRef MyContainer)
        {
            MyContainer
            .FindContainedObjectByName(msg.NameToFind, findResult =>
            {
                if (!findResult.HasValue)
                {
                    Self.Tell(new Notify($"Could not find {msg.NameToFind}"));
                }
                else
                {
                    //TODO: this actor should negotiate with the target if the target can be taken
                    //TODO: this actor should check if the object can fit into ContainerVolume
                    //TODO: this actor should check if you are strong enough to take the target

                    Self.Tell(new Notify($"You take {findResult.Name}"));
                    //TODO: this is racy, potentially two people could take the same item at the same time
                    //SetContainer should probably even contan the current Container.
                    //if the objects container is different from the passed in value, there is a race condition
                    findResult.Item.Tell(new SetContainer(Self), Self);
                }
            });
        }