Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Players are written to their own private directories, with the full current/dated backup cycle for each dude
        /// </summary>
        /// <returns>whether or not it succeeded</returns>
        public bool WritePlayers()
        {
            PlayerData playerAccessor = new PlayerData();

            try
            {
                LoggingUtility.Log("All Players backup INITIATED.", LogChannels.Backup, true);

                //Get all the players
                IEnumerable <IPlayer> entities = LiveCache.GetAll <IPlayer>();

                foreach (IPlayer entity in entities)
                {
                    playerAccessor.WriteOnePlayer(entity);
                }

                LoggingUtility.Log("All players written.", LogChannels.Backup, true);
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Message handling
        /// </summary>
        /// <param name="message">See <see cref="Message"/></param>
        internal override void Handle(Message message)
        {
            // TODO: Tests for LiveCache
            this._Parse();

            int nodeId = message.Node.Id;

            if (!string.IsNullOrEmpty(channelId))
            {
                LiveCache.AddOrReplace($"channelIdToYRtpId-{nodeId}-{this.channelId}", this.rtpChannelId);
            }

            if (!string.IsNullOrEmpty(remoteRtpIp))
            {
                LiveCache.AddOrReplace($"yRtpIdToRemoteRtpIp-{nodeId}-{this.rtpChannelId}", this.remoteRtpIp);
            }

            if (!string.IsNullOrEmpty(callBillId))
            {
                LiveCache.AddOrReplace($"yRtpIdToBillId-{nodeId}-{this.rtpChannelId}", this.callBillId);
            }

            if (!string.IsNullOrEmpty(this.remoteRtpPort))
            {
                LiveCache.AddOrReplace($"yRtpIdToRemoteRtpPort-{nodeId}-{this.rtpChannelId}", this.remoteRtpPort);
            }

            this._Reset();
        }
Exemplo n.º 4
0
        public ActionResult RestartGossipServer()
        {
            IEnumerable <WebSocket> gossipServers = LiveCache.GetAll <WebSocket>();

            foreach (WebSocket server in gossipServers)
            {
                server.Abort();
            }

            IGossipConfig   gossipConfig = ConfigDataCache.Get <IGossipConfig>(new ConfigDataCacheKey(typeof(IGossipConfig), "GossipSettings", ConfigDataType.GameWorld));
            Func <Member[]> playerList   = () => LiveCache.GetAll <IPlayer>()
                                           .Where(player => player.Descriptor != null && player.Template <IPlayerTemplate>().Account.Config.GossipSubscriber)
                                           .Select(player => new Member()
            {
                Name           = player.AccountHandle,
                WriteTo        = (message) => player.WriteTo(new string[] { message }),
                BlockedMembers = player.Template <IPlayerTemplate>().Account.Config.Acquaintences.Where(acq => !acq.IsFriend).Select(acq => acq.PersonHandle),
                Friends        = player.Template <IPlayerTemplate>().Account.Config.Acquaintences.Where(acq => acq.IsFriend).Select(acq => acq.PersonHandle)
            }).ToArray();

            void exceptionLogger(Exception ex) => LoggingUtility.LogError(ex);
            void activityLogger(string message) => LoggingUtility.Log(message, LogChannels.GossipServer);

            GossipClient gossipServer = new GossipClient(gossipConfig, exceptionLogger, activityLogger, playerList);

            Task.Run(() => gossipServer.Launch());

            LiveCache.Add(gossipServer, "GossipWebClient");

            return(RedirectToAction("Index", new { Message = "Gossip Server Restarted" }));
        }
Exemplo n.º 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(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);
        }
Exemplo n.º 6
0
        private static void FillRoomDimensions(string[,,] coordinatePlane)
        {
            if (coordinatePlane == null)
            {
                return;
            }

            int x, y, z;

            for (x = 0; x <= coordinatePlane.GetUpperBound(0); x++)
            {
                for (y = 0; y <= coordinatePlane.GetUpperBound(1); y++)
                {
                    for (z = 0; z <= coordinatePlane.GetUpperBound(2); z++)
                    {
                        if (string.IsNullOrWhiteSpace(coordinatePlane[x, y, z]))
                        {
                            continue;
                        }

                        IRoom room = LiveCache.Get <IRoom>(new LiveCacheKey(typeof(IRoom), coordinatePlane[x, y, z]));

                        if (room == null)
                        {
                            continue;
                        }

                        room.Coordinates = new Coordinate(x, y, z);
                    }
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Tries to find this entity in the world based on its ID or gets a new one from the db and puts it in the world
        /// </summary>
        public void GetFromWorldOrSpawn()
        {
            //Try to see if they are already there
            var me = LiveCache.Get <Player>(DataTemplate.ID);

            //Isn't in the world currently
            if (me == default(IPlayer))
            {
                SpawnNewInWorld();
            }
            else
            {
                BirthMark    = me.BirthMark;
                Birthdate    = me.Birthdate;
                DataTemplate = me.DataTemplate;
                Inventory    = me.Inventory;
                Keywords     = me.Keywords;

                if (me.CurrentLocation == null)
                {
                    var newLoc = GetBaseSpawn();
                    newLoc.MoveInto <IPlayer>(this);
                }
                else
                {
                    me.CurrentLocation.MoveInto <IPlayer>(this);
                }
            }
        }
Exemplo n.º 8
0
        public ActionResult RemoveZoneDescriptive(string id = "", string authorize = "")
        {
            string message = string.Empty;
            string zoneId  = "";

            if (string.IsNullOrWhiteSpace(authorize))
            {
                message = "You must check the proper authorize radio button first.";
            }
            else
            {
                ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());
                string[]        values     = authorize.Split(new string[] { "|||" }, StringSplitOptions.RemoveEmptyEntries);

                if (values.Count() != 2)
                {
                    message = "You must check the proper authorize radio button first.";
                }
                else
                {
                    string type   = values[0];
                    string phrase = values[1];

                    IZone obj = LiveCache.Get <IZone>(new LiveCacheKey(typeof(IZone), id));

                    if (obj == null)
                    {
                        message = "That does not exist";
                    }
                    else
                    {
                        GrammaticalType grammaticalType    = (GrammaticalType)Enum.Parse(typeof(GrammaticalType), type);
                        ISensoryEvent   existingOccurrence = obj.Descriptives.FirstOrDefault(occurrence => occurrence.Event.Role == grammaticalType &&
                                                                                             occurrence.Event.Phrase.Equals(phrase, StringComparison.InvariantCultureIgnoreCase));
                        zoneId = obj.BirthMark;

                        if (existingOccurrence != null)
                        {
                            obj.Descriptives.Remove(existingOccurrence);

                            if (obj.Save())
                            {
                                LoggingUtility.LogAdminCommandUsage("*WEB* - LIVE DATA - RemoveDescriptive[" + id.ToString() + "|" + type.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                                message = "Delete Successful.";
                            }
                            else
                            {
                                message = "Error; Removal failed.";
                            }
                        }
                        else
                        {
                            message = "That does not exist";
                        }
                    }
                }
            }

            return(RedirectToAction("Zone", new { Message = message, birthMark = id }));
        }
Exemplo n.º 9
0
        public void GetFromWorldOrSpawn()
        {
            //Try to see if they are already there
            IGaia me = LiveCache.Get <IGaia>(TemplateId, typeof(GaiaTemplate));

            //Isn't in the world currently
            if (me == default(IGaia))
            {
                SpawnNewInWorld();
            }
            else
            {
                BirthMark           = me.BirthMark;
                Birthdate           = me.Birthdate;
                TemplateId          = me.TemplateId;
                Keywords            = me.Keywords;
                CurrentLocation     = null;
                CurrentTimeOfDay    = me.CurrentTimeOfDay;
                MeterologicalFronts = me.MeterologicalFronts;
                Macroeconomy        = me.Macroeconomy;
                CelestialPositions  = me.CelestialPositions;
                RotationalAngle     = me.RotationalAngle;

                Qualities = me.Qualities;

                CurrentLocation = null;
                KickoffProcesses();
            }
        }
Exemplo n.º 10
0
        public ActionResult EditZone(string birthMark, ViewZoneViewModel vModel)
        {
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

            IZone  obj = LiveCache.Get <IZone>(new LiveCacheKey(typeof(Zone), birthMark));
            string message;

            if (obj == null)
            {
                message = "That does not exist";
                return(RedirectToAction("Index", new { Message = message }));
            }

            obj.BaseElevation = vModel.DataObject.BaseElevation;
            obj.Hemisphere    = vModel.DataObject.Hemisphere;
            obj.Humidity      = vModel.DataObject.Humidity;
            obj.Temperature   = vModel.DataObject.Temperature;

            //obj.NaturalResources = vModel.DataObject.NaturalResources;
            obj.Qualities = vModel.DataObject.Qualities;

            if (obj.Save())
            {
                LoggingUtility.LogAdminCommandUsage("*WEB* - LIVE DATA - EditZone[" + obj.BirthMark + "]", authedUser.GameAccount.GlobalIdentityHandle);
                message = "Edit Successful.";
            }
            else
            {
                message = "Error; Edit failed.";
            }

            return(RedirectToAction("Zone", new { Message = message, birthMark }));
        }
Exemplo n.º 11
0
        public ActionResult EditWorld(string birthMark, ViewGaiaViewModel vModel)
        {
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

            IGaia  obj = LiveCache.Get <IGaia>(new LiveCacheKey(typeof(Gaia), birthMark));
            string message;

            if (obj == null)
            {
                message = "That does not exist";
                return(RedirectToAction("Index", new { Message = message }));
            }

            obj.RotationalAngle     = vModel.DataObject.RotationalAngle;
            obj.OrbitalPosition     = vModel.DataObject.OrbitalPosition;
            obj.Macroeconomy        = vModel.DataObject.Macroeconomy;
            obj.CelestialPositions  = vModel.DataObject.CelestialPositions;
            obj.MeterologicalFronts = vModel.DataObject.MeterologicalFronts;
            obj.CurrentTimeOfDay    = vModel.DataObject.CurrentTimeOfDay;

            obj.Qualities = vModel.DataObject.Qualities;

            if (obj.Save())
            {
                LoggingUtility.LogAdminCommandUsage("*WEB* - LIVE DATA - EditGaia[" + obj.BirthMark + "]", authedUser.GameAccount.GlobalIdentityHandle);
                message = "Edit Successful.";
            }
            else
            {
                message = "Error; Edit failed.";
            }

            return(RedirectToAction("World", new { Message = message, birthMark }));
        }
Exemplo n.º 12
0
        /// <summary>
        /// Spawn this new into the live world
        /// </summary>
        public override void SpawnNewInWorld()
        {
            var ch = (ICharacter)DataTemplate;
            var locationAssembly = Assembly.GetAssembly(typeof(ILocation));

            if (ch.LastKnownLocationType == null)
            {
                ch.LastKnownLocationType = typeof(IRoom).Name;
            }

            var lastKnownLocType = locationAssembly.DefinedTypes.FirstOrDefault(tp => tp.Name.Equals(ch.LastKnownLocationType));

            ILocation lastKnownLoc = null;

            if (lastKnownLocType != null && !string.IsNullOrWhiteSpace(ch.LastKnownLocation))
            {
                if (lastKnownLocType.GetInterfaces().Contains(typeof(ISpawnAsSingleton)))
                {
                    long lastKnownLocID = long.Parse(ch.LastKnownLocation);
                    lastKnownLoc = LiveCache.Get <ILocation>(lastKnownLocID, lastKnownLocType);
                }
                else
                {
                    var cacheKey = new LiveCacheKey(lastKnownLocType, ch.LastKnownLocation);
                    lastKnownLoc = LiveCache.Get <ILocation>(cacheKey);
                }
            }

            SpawnNewInWorld(lastKnownLoc);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Get adjascent surrounding locales and zones
        /// </summary>
        /// <returns>The adjascent locales and zones</returns>
        public IEnumerable <ILocation> GetSurroundings()
        {
            List <ILocation>       radiusLocations = new List <ILocation>();
            IEnumerable <IPathway> paths           = LiveCache.GetAll <IPathway>().Where(path => path.Origin.Equals(this));

            //If we don't have any paths out what can we even do
            if (paths.Count() == 0)
            {
                return(radiusLocations);
            }

            while (paths.Count() > 0)
            {
                IEnumerable <ILocation> currentLocsSet = paths.Select(path => path.Destination);

                if (currentLocsSet.Count() == 0)
                {
                    break;
                }

                radiusLocations.AddRange(currentLocsSet);
                paths = currentLocsSet.SelectMany(ro => ro.GetPathways());
            }

            return(radiusLocations);
        }
Exemplo n.º 14
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();
        }
Exemplo n.º 15
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);
        }
Exemplo n.º 16
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();
        }
Exemplo n.º 17
0
        /// <summary>
        /// Message handling
        /// </summary>
        /// <param name="message">See <see cref="Message"/></param>
        internal override void Handle(Message message)
        {
            string channelId = message.GetValue("id");
            string billId    = message.GetValue("billid");
            int    nodeId    = message.Node.Id;

            LiveCache.AddOrReplace($"channelIdToBillId-{nodeId}-{channelId}", billId);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Find the emergency we dont know where to spawn this guy spawn location
        /// </summary>
        /// <returns>The emergency spawn location</returns>
        private IContains GetBaseSpawn()
        {
            var chr = (Character)DataTemplate;

            var roomId = chr.StillANoob ? chr.RaceData.StartingLocation.ID : chr.RaceData.EmergencyLocation.ID;

            return(LiveCache.Get <Room>(roomId));
        }
Exemplo n.º 19
0
        /// <summary>
        /// Restful list of entities contained (it needs to never store its own objects, only cache references)
        /// </summary>
        public IEnumerable <T> EntitiesContained()
        {
            if (Count() > 0)
            {
                return(LiveCache.GetMany <T>(Birthmarks.Values.SelectMany(hs => hs)));
            }

            return(Enumerable.Empty <T>());
        }
Exemplo n.º 20
0
        public ActionResult AddEditZoneDescriptive(string birthMark, LiveOccurrenceViewModel vModel)
        {
            string          message    = string.Empty;
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

            IZone obj = LiveCache.Get <IZone>(new LiveCacheKey(typeof(Zone), birthMark));

            if (obj == null)
            {
                message = "That does not exist";
                return(RedirectToRoute("ModalErrorOrClose", new { Message = message }));
            }

            ISensoryEvent existingOccurrence = obj.Descriptives.FirstOrDefault(occurrence => occurrence.Event.Role == vModel.SensoryEventDataObject.Event.Role &&
                                                                               occurrence.Event.Phrase.Equals(vModel.SensoryEventDataObject.Event.Phrase, StringComparison.InvariantCultureIgnoreCase));

            if (existingOccurrence == null)
            {
                existingOccurrence = new SensoryEvent(vModel.SensoryEventDataObject.SensoryType)
                {
                    Strength = vModel.SensoryEventDataObject.Strength,
                    Event    = new Lexica(vModel.SensoryEventDataObject.Event.Type,
                                          vModel.SensoryEventDataObject.Event.Role,
                                          vModel.SensoryEventDataObject.Event.Phrase, new LexicalContext(null))
                    {
                        Modifiers = vModel.SensoryEventDataObject.Event.Modifiers
                    }
                };
            }
            else
            {
                existingOccurrence.Strength    = vModel.SensoryEventDataObject.Strength;
                existingOccurrence.SensoryType = vModel.SensoryEventDataObject.SensoryType;
                existingOccurrence.Event       = new Lexica(vModel.SensoryEventDataObject.Event.Type,
                                                            vModel.SensoryEventDataObject.Event.Role,
                                                            vModel.SensoryEventDataObject.Event.Phrase, new LexicalContext(null))
                {
                    Modifiers = vModel.SensoryEventDataObject.Event.Modifiers
                };
            }

            obj.Descriptives.RemoveWhere(occurrence => occurrence.Event.Role == vModel.SensoryEventDataObject.Event.Role &&
                                         occurrence.Event.Phrase.Equals(vModel.SensoryEventDataObject.Event.Phrase, StringComparison.InvariantCultureIgnoreCase));

            obj.Descriptives.Add(existingOccurrence);

            if (obj.Save())
            {
                LoggingUtility.LogAdminCommandUsage("*WEB* - LIVE DATA - Zone AddEditDescriptive[" + obj.BirthMark + "]", authedUser.GameAccount.GlobalIdentityHandle);
            }
            else
            {
                message = "Error; Edit failed.";
            }

            return(RedirectToRoute("ModalErrorOrClose", new { Message = message }));
        }
Exemplo n.º 21
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 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);
        }
Exemplo n.º 22
0
        public override void Execute()
        {
            IEnumerable <IPlayer> whoList = LiveCache.GetAll <IPlayer>().Where(player => player.Descriptor != null);

            ILexicalParagraph toActor = new LexicalParagraph(string.Join(",", whoList.Select(who => who.GetDescribableName(Actor))));

            Message messagingObject = new Message(toActor);

            messagingObject.ExecuteMessaging(Actor, null, null, null, null);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Something went wrong with restoring the live backup, this loads all persistence singeltons from the database (rooms, paths, spawns)
        /// </summary>
        /// <returns>success state</returns>
        public bool NewWorldFallback()
        {
            //Only load in stuff that is static and spawns as singleton
            LiveCache.PreLoadAll <RoomData>();
            LiveCache.PreLoadAll <PathwayData>();

            LoggingUtility.Log("World restored from data fallback.", LogChannels.Backup, true);

            return(true);
        }
Exemplo n.º 24
0
        public string RenderLiveRoomForEditWithRadius(string birthMark, int radius)
        {
            IRoom centerRoom = LiveCache.Get <IRoom>(new LiveCacheKey(typeof(IRoom), birthMark));

            if (centerRoom == null || radius < 0)
            {
                return("Invalid inputs.");
            }

            return(Rendering.RenderRadiusMap(centerRoom, radius));
        }
Exemplo n.º 25
0
        /// <summary>
        /// Get this from the world or make a new one and put it in
        /// </summary>
        public void GetFromWorldOrSpawn()
        {
            //Try to see if they are already there
            ILocale me = LiveCache.Get <ILocale>(TemplateId, typeof(LocaleTemplate));

            //Isn't in the world currently
            if (me == default(ILocale))
            {
                SpawnNewInWorld();
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// Tries to find this entity in the world based on its Id or gets a new one from the db and puts it in the world
        /// </summary>
        public void GetFromWorldOrSpawn()
        {
            //Try to see if they are already there
            Pathway me = LiveCache.Get <Pathway>(TemplateId);

            //Isn't in the world currently
            if (me == default(Pathway))
            {
                SpawnNewInWorld();
            }
        }
Exemplo n.º 27
0
        public ActionResult Zones(string SearchTerms = "", int CurrentPageNumber = 1, int ItemsPerPage = 20)
        {
            LiveZonesViewModel vModel = new LiveZonesViewModel(LiveCache.GetAll <IZone>())
            {
                AuthedUser        = UserManager.FindById(User.Identity.GetUserId()),
                CurrentPageNumber = CurrentPageNumber,
                ItemsPerPage      = ItemsPerPage,
                SearchTerms       = SearchTerms
            };

            return(View(vModel));
        }
Exemplo n.º 28
0
        /// <summary>
        /// Update this entry to the live world cache
        /// </summary>
        public void UpsertToLiveWorldCache(bool forceSave = false)
        {
            LiveCache.Add(this);

            DateTime now = DateTime.Now;

            if (CleanUntil < now.AddMinutes(-5) || forceSave)
            {
                CleanUntil = now;
                Save();
            }
        }
Exemplo n.º 29
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);
        }
Exemplo n.º 30
0
        public string[] RenderLiveLocaleMapForEdit(string birthMark, int zIndex)
        {
            ILocale locale = LiveCache.Get <ILocale>(new LiveCacheKey(typeof(ILocale), birthMark));

            if (locale == null)
            {
                return(new string[] { "Invalid inputs." });
            }

            System.Tuple <string, string, string> maps = Rendering.RenderRadiusMap(locale, 10, zIndex);

            return(new string[] { maps.Item1, maps.Item2, maps.Item3 });
        }