コード例 #1
0
        /// <summary>
        /// Spawn this into the world and live cache
        /// </summary>
        /// <param name="spawnTo">Where this will go</param>
        public override void SpawnNewInWorld(IGlobalPosition spawnTo)
        {
            //We can't even try this until we know if the data is there
            IZoneTemplate bS = Template <IZoneTemplate>() ?? throw new InvalidOperationException("Missing backing data store on zone spawn event.");

            Keywords = bS.Keywords;

            if (string.IsNullOrWhiteSpace(BirthMark))
            {
                BirthMark = LiveCache.GetUniqueIdentifier(bS);
                Birthdate = DateTime.Now;
            }

            Qualities    = bS.Qualities;
            Descriptives = bS.Descriptives;

            WeatherEvents           = Enumerable.Empty <IWeatherEvent>();
            FloraNaturalResources   = new HashSet <INaturalResourceSpawn <IFlora> >();
            FaunaNaturalResources   = new HashSet <INaturalResourceSpawn <IFauna> >();
            MineralNaturalResources = new HashSet <INaturalResourceSpawn <IMineral> >();

            PopulateMap();

            UpsertToLiveWorldCache(true);

            KickoffProcesses();

            CurrentLocation = new GlobalPosition(this, null, null);
            UpsertToLiveWorldCache(true);

            Save();
        }
コード例 #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(IGlobalPosition spawnTo)
        {
            //We can't even try this until we know if the data is there
            IInanimateTemplate bS = Template <IInanimateTemplate>() ?? throw new InvalidOperationException("Missing backing data store on object spawn event.");

            Keywords = bS.Keywords;

            if (string.IsNullOrWhiteSpace(BirthMark))
            {
                BirthMark = LiveCache.GetUniqueIdentifier(bS);
                Birthdate = DateTime.Now;
            }

            Qualities       = bS.Qualities;
            AccumulationCap = bS.AccumulationCap;

            TryMoveTo(spawnTo);

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

            UpsertToLiveWorldCache(true);

            KickoffProcesses();
        }
コード例 #3
0
        /// <summary>
        /// Spawn this into the world and live cache
        /// </summary>
        public override void SpawnNewInWorld(IGlobalPosition spawnTo)
        {
            //We can't even try this until we know if the data is there
            ILocaleTemplate bS = Template <ILocaleTemplate>() ?? throw new InvalidOperationException("Missing backing data store on locale spawn event.");

            Keywords         = new string[] { bS.Name.ToLower() };
            AlwaysDiscovered = bS.AlwaysDiscovered;
            Descriptives     = bS.Descriptives;

            if (string.IsNullOrWhiteSpace(BirthMark))
            {
                BirthMark = LiveCache.GetUniqueIdentifier(bS);
                Birthdate = DateTime.Now;
            }

            UpsertToLiveWorldCache(true);

            ParentLocation = LiveCache.Get <IZone>(bS.ParentLocation.Id);

            if (spawnTo?.CurrentZone == null)
            {
                spawnTo = new GlobalPosition(ParentLocation, this);
            }

            CurrentLocation = spawnTo;

            UpsertToLiveWorldCache(true);
        }
コード例 #4
0
        /// <summary>
        /// Handles initial connection
        /// </summary>
        public override void OnOpen()
        {
            base.OnOpen();

            BirthMark = LiveCache.GetUniqueIdentifier(string.Format(cacheKeyFormat, WebSocketContext.AnonymousID));
            PersistToCache();

            UserManager = new ApplicationUserManager(new UserStore <ApplicationUser>(new ApplicationDbContext()));

            ValidateUser(WebSocketContext.CookieCollection[".AspNet.ApplicationCookie"]);

            LoggingUtility.Log(content: "Socket client accepted", channel: LogChannels.SocketCommunication);
        }
コード例 #5
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(IGlobalPosition position)
        {
            //We can't even try this until we know if the data is there
            IPathwayTemplate bS = Template <IPathwayTemplate>() ?? throw new InvalidOperationException("Missing backing data store on pathway spawn event.");

            Keywords = new string[] { bS.Name.ToLower(), DirectionType.ToString().ToLower() };

            if (string.IsNullOrWhiteSpace(BirthMark))
            {
                BirthMark = LiveCache.GetUniqueIdentifier(bS);
                Birthdate = DateTime.Now;
            }

            DegreesFromNorth = bS.DegreesFromNorth;
            InclineGrade     = bS.InclineGrade;
            DirectionType    = Utilities.TranslateToDirection(DegreesFromNorth, InclineGrade);
            Descriptives     = bS.Descriptives;

            //paths need two locations
            if (bS.Origin.GetType() == typeof(RoomTemplate))
            {
                Origin = ((IRoomTemplate)bS.Origin).GetLiveInstance();
            }
            else
            {
                Origin = ((IZoneTemplate)bS.Origin).GetLiveInstance();
            }

            if (bS.Destination.GetType() == typeof(RoomTemplate))
            {
                Destination = ((IRoomTemplate)bS.Destination).GetLiveInstance();
            }
            else
            {
                Destination = ((IZoneTemplate)bS.Destination).GetLiveInstance();
            }


            CurrentLocation = (IGlobalPosition)Origin.CurrentLocation.Clone();
            Model           = bS.Model;

            //Enter = new Message(new string[] { bS.MessageToActor }, new string[] { "$A$ enters you" }, new string[] { }, new string[] { bS.MessageToOrigin }, new string[] { bS.MessageToDestination });
            //Enter.ToSurrounding.Add(MessagingType.Visible, new Tuple<int, IEnumerable<string>>(bS.VisibleStrength, new string[] { bS.VisibleToSurroundings }));
            //Enter.ToSurrounding.Add(MessagingType.Audible, new Tuple<int, IEnumerable<string>>(bS.AudibleStrength, new string[] { bS.AudibleToSurroundings }));

            UpsertToLiveWorldCache(true);

            Save();
        }
コード例 #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(IGlobalPosition spawnTo)
        {
            //We can't even try this until we know if the data is there
            IRoomTemplate bS = Template <IRoomTemplate>() ?? throw new InvalidOperationException("Missing backing data store on room spawn event.");

            Keywords     = new string[] { bS.Name.ToLower() };
            Model        = bS.Model;
            Descriptives = bS.Descriptives;
            Qualities    = bS.Qualities;

            if (FloraNaturalResources == null)
            {
                FloraNaturalResources = new HashSet <INaturalResourceSpawn <IFlora> >();
            }

            if (FaunaNaturalResources == null)
            {
                FaunaNaturalResources = new HashSet <INaturalResourceSpawn <IFauna> >();
            }

            if (MineralNaturalResources == null)
            {
                MineralNaturalResources = new HashSet <INaturalResourceSpawn <IMineral> >();
            }

            if (string.IsNullOrWhiteSpace(BirthMark))
            {
                BirthMark = LiveCache.GetUniqueIdentifier(bS);
                Birthdate = DateTime.Now;
            }

            UpsertToLiveWorldCache(true);

            ParentLocation        = LiveCache.Get <ILocale>(bS.ParentLocation.Id);
            spawnTo.CurrentLocale = ParentLocation;
            spawnTo.CurrentZone   = ParentLocation.ParentLocation;

            if (spawnTo?.CurrentLocale == null || spawnTo?.CurrentZone == null)
            {
                spawnTo = new GlobalPosition(this);
            }

            CurrentLocation = spawnTo;

            UpsertToLiveWorldCache(true);

            Save();
        }
コード例 #7
0
        public override void SpawnNewInWorld(IGlobalPosition spawnTo)
        {
            //We can't even try this until we know if the data is there
            IGaiaTemplate bS = Template <IGaiaTemplate>() ?? throw new InvalidOperationException("Missing backing data store on gaia spawn event.");

            Keywords = bS.Keywords;

            if (CelestialPositions == null || CelestialPositions.Count() == 0)
            {
                HashSet <ICelestialPosition> celestials = new HashSet <ICelestialPosition>();

                foreach (ICelestial body in bS.CelestialBodies)
                {
                    celestials.Add(new CelestialPosition(body, 0));
                }

                CelestialPositions = celestials;
            }

            RotationalAngle = bS.RotationalAngle;
            Qualities       = bS.Qualities;

            //gotta spawn 2 per hemisphere
            if (MeterologicalFronts == null || MeterologicalFronts.Count() == 0)
            {
                MeterologicalFronts = AddFronts();
            }

            CurrentTimeOfDay = new TimeOfDay(bS.ChronologicalSystem);

            if (string.IsNullOrWhiteSpace(BirthMark))
            {
                BirthMark = LiveCache.GetUniqueIdentifier(bS);
                Birthdate = DateTime.Now;
            }

            Macroeconomy = new Economy(bS);

            UpsertToLiveWorldCache(true);

            CurrentLocation = new GlobalPosition(null, null, null);
            KickoffProcesses();

            UpsertToLiveWorldCache(true);

            Save();
        }
コード例 #8
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(IGlobalPosition position)
        {
            INonPlayerCharacterTemplate bS = Template <INonPlayerCharacterTemplate>() ?? throw new InvalidOperationException("Missing backing data store on NPC spawn event.");

            Keywords = bS.Keywords;

            if (string.IsNullOrWhiteSpace(BirthMark))
            {
                BirthMark = LiveCache.GetUniqueIdentifier(bS);
                Birthdate = DateTime.Now;
            }

            CurrentHealth  = bS.TotalHealth;
            CurrentStamina = bS.TotalStamina;

            Qualities             = bS.Qualities;
            TotalHealth           = bS.TotalHealth;
            TotalStamina          = bS.TotalStamina;
            Race                  = bS.Race;
            Personality           = bS.Personality;
            SurName               = bS.SurName;
            Gender                = bS.Gender;
            WillPurchase          = bS.WillPurchase;
            WillSell              = bS.WillSell;
            InventoryRestock      = bS.InventoryRestock;
            TeachableProficencies = bS.TeachableProficencies;

            TryMoveTo(position);

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

            UpsertToLiveWorldCache(true);

            KickoffProcesses();
        }