/// <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); }
/// <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); }
/// <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 roomTemplate = (IRoomData)DataTemplate; BirthMark = Birthmarker.GetBirthmark(roomTemplate); Keywords = new string[] { roomTemplate.Name.ToLower() }; Birthdate = DateTime.Now; CurrentLocation = spawnTo; }
/// <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 bS = (IPathwayData)DataTemplate; var locationAssembly = Assembly.GetAssembly(typeof(Room)); MovementDirection = MessagingUtility.TranslateDegreesToDirection(bS.DegreesFromNorth); BirthMark = Birthmarker.GetBirthmark(bS); Keywords = new string[] { bS.Name.ToLower(), MovementDirection.ToString().ToLower() }; Birthdate = DateTime.Now; //paths need two locations ILocation fromLocation = null; var fromLocationType = locationAssembly.DefinedTypes.FirstOrDefault(tp => tp.Name.Equals(bS.FromLocationType)); if (fromLocationType != null && !string.IsNullOrWhiteSpace(bS.FromLocationID)) { if (fromLocationType.GetInterfaces().Contains(typeof(ISpawnAsSingleton))) { long fromLocationID = long.Parse(bS.FromLocationID); fromLocation = LiveCache.Get <ILocation>(fromLocationID, fromLocationType); } else { var cacheKey = new LiveCacheKey(fromLocationType, bS.FromLocationID); fromLocation = LiveCache.Get <ILocation>(cacheKey); } } ILocation toLocation = null; var toLocationType = locationAssembly.DefinedTypes.FirstOrDefault(tp => tp.Name.Equals(bS.ToLocationType)); if (toLocationType != null && !string.IsNullOrWhiteSpace(bS.ToLocationID)) { if (toLocationType.GetInterfaces().Contains(typeof(ISpawnAsSingleton))) { long toLocationID = long.Parse(bS.ToLocationID); toLocation = LiveCache.Get <ILocation>(toLocationID, toLocationType); } else { var cacheKey = new LiveCacheKey(toLocationType, bS.ToLocationID); toLocation = LiveCache.Get <ILocation>(cacheKey); } } FromLocation = fromLocation; ToLocation = toLocation; CurrentLocation = fromLocation; Enter = new MessageCluster(new string[] { bS.MessageToActor }, new string[] { "$A$ enters you" }, new string[] { }, new string[] { bS.MessageToOrigin }, new string[] { bS.MessageToDestination }); Enter.ToSurrounding.Add(bS.VisibleStrength, new Tuple <MessagingType, IEnumerable <string> >(MessagingType.Visible, new string[] { bS.VisibleToSurroundings })); Enter.ToSurrounding.Add(bS.AudibleStrength, new Tuple <MessagingType, IEnumerable <string> >(MessagingType.Visible, new string[] { bS.AudibleToSurroundings })); fromLocation.MoveInto <IPathway>(this); }