Пример #1
0
        /// <summary>
        /// Spawn this new into the live world into a specified container
        /// </summary>
        /// <param name="spawnTo">the location/container this should spawn into</param>
        public override void SpawnNewInWorld(IContains spawnTo)
        {
            var ch = (ICharacter)DataTemplate;

            BirthMark = Birthmarker.GetBirthmark(ch);
            Keywords  = new string[] { ch.Name.ToLower(), ch.SurName.ToLower() };
            Birthdate = DateTime.Now;

            if (spawnTo == null)
            {
                spawnTo = GetBaseSpawn();
            }

            CurrentLocation = spawnTo;

            //Set the data context's stuff too so we don't have to do this over again
            ch.LastKnownLocation     = spawnTo.DataTemplate.ID.ToString();
            ch.LastKnownLocationType = spawnTo.GetType().Name;
            ch.Save();

            spawnTo.MoveInto <IPlayer>(this);

            Inventory = new EntityContainer <IInanimate>();

            LiveCache.Add(this);
        }
Пример #2
0
        /// <summary>
        /// Spawn this new into the live world into a specified container
        /// </summary>
        /// <param name="spawnTo">the location/container this should spawn into</param>
        public override void SpawnNewInWorld(IContains spawnTo)
        {
            //We can't even try this until we know if the data is there
            if (DataTemplate == null)
            {
                throw new InvalidOperationException("Missing backing data store on object spawn event.");
            }

            var backingStore = (IInanimateData)DataTemplate;

            BirthMark = Birthmarker.GetBirthmark(backingStore);
            Keywords  = new string[] { backingStore.Name.ToLower() };
            Birthdate = DateTime.Now;

            if (spawnTo == null)
            {
                throw new NotImplementedException("Objects can't spawn to nothing");
            }

            CurrentLocation = spawnTo;

            spawnTo.MoveInto <IInanimate>(this);

            Contents = new EntityContainer <IInanimate>();

            LiveCache.Add(this);
        }
Пример #3
0
        /// <summary>
        /// Executes this command
        /// </summary>
        public override void Execute()
        {
            var       sb    = new List <string>();
            var       thing = (IEntity)Subject;
            var       actor = (IContains)Actor;
            IContains place = (IContains)OriginLocation;

            actor.MoveFrom(thing);
            place.MoveInto(thing);

            sb.Add("You drop $S$.");

            var messagingObject = new MessageCluster(sb, new string[] { }, new string[] { }, new string[] { "$A$ drops $S$." }, new string[] { });

            messagingObject.ExecuteMessaging(Actor, thing, null, OriginLocation, null);
        }
Пример #4
0
        /// <summary>
        /// Executes this command
        /// </summary>
        internal override bool ExecutionBody()
        {
            List <string> sb    = new List <string>();
            IEntity       thing = (IEntity)Subject;
            IContains     actor = (IContains)Actor;
            IContains     place;

            string toRoomMessage = "$A$ gets $S$.";

            if (Target != null)
            {
                place         = (IContains)Target;
                toRoomMessage = "$A$ gets $S$ from $T$.";
                sb.Add("You get $S$ from $T$.");
            }
            else
            {
                place = (IContains)OriginLocation;
                sb.Add("You get $S$.");
            }

            place.MoveFrom(thing);
            actor.MoveInto(thing);

            ILexicalParagraph toActor = new LexicalParagraph(sb.ToString());

            ILexicalParagraph toOrigin = new LexicalParagraph(toRoomMessage);

            Message messagingObject = new Message(toActor)
            {
                ToOrigin = new List <ILexicalParagraph> {
                    toOrigin
                }
            };

            messagingObject.ExecuteMessaging(Actor, thing, (IEntity)Target, OriginLocation.CurrentRoom, null);

            return(true);
        }
Пример #5
0
        /// <summary>
        /// Executes this command
        /// </summary>
        public override void Execute()
        {
            IEntity   thing = (IEntity)Subject;
            IContains actor = (IContains)Actor;
            IContains place = (IContains)OriginLocation;

            actor.MoveFrom(thing);
            place.MoveInto(thing);

            ILexicalParagraph toActor = new LexicalParagraph("You drop $S$.");

            ILexicalParagraph toOrigin = new LexicalParagraph("$A$ drops $S$.");

            IMessage messagingObject = new Message(toActor)
            {
                ToOrigin = new List <ILexicalParagraph> {
                    toOrigin
                }
            };

            messagingObject.ExecuteMessaging(Actor, thing, null, OriginLocation.CurrentRoom, null);
        }
Пример #6
0
        /// <summary>
        /// Spawn this new into the live world into a specified container
        /// </summary>
        /// <param name="spawnTo">the location/container this should spawn into</param>
        public override void SpawnNewInWorld(IContains spawnTo)
        {
            //We can't even try this until we know if the data is there
            if (DataTemplate<IInanimateData>() == null)
                throw new InvalidOperationException("Missing backing data store on object spawn event.");

            var bS = DataTemplate<IInanimateData>();

            BirthMark = LiveCache.GetUniqueIdentifier(bS);
            Keywords = new string[] { bS.Name.ToLower() };
            Birthdate = DateTime.Now;

            if (spawnTo == null)
            {
                throw new NotImplementedException("Objects can't spawn to nothing");
            }

            InsideOf = spawnTo;

            spawnTo.MoveInto<IInanimate>(this);

            Contents = new EntityContainer<IInanimate>();

            LiveCache.Add(this);
        }
Пример #7
0
 /// <summary>
 /// Spawn this new into the live world into a specified container
 /// </summary>
 /// <param name="spawnTo">the location/container this should spawn into</param>
 public override void SpawnNewInWorld(IContains spawnTo)
 {
     spawnTo.MoveInto(this);
     UpsertToLiveWorldCache();
 }
Пример #8
0
 /// <summary>
 /// Move this inside of something
 /// </summary>
 /// <param name="container">The container to move into</param>
 /// <returns>was this thing moved?</returns>
 public override bool TryMoveInto(IContains container)
 {
     return(container.MoveInto(this));
 }