Example #1
0
        /// <summary>
        /// News up an entity with its backing data
        /// </summary>
        /// <param name="room">the backing data</param>
        public Gaia(IGaiaTemplate world)
        {
            TemplateId          = world.Id;
            Qualities           = new HashSet <IQuality>();
            MeterologicalFronts = new HashSet <MeterologicalFront>();
            Macroeconomy        = new Economy();
            CelestialPositions  = new HashSet <ICelestialPosition>();

            GetFromWorldOrSpawn();
        }
Example #2
0
        /// <summary>
        /// Get the live world associated with this live zone
        /// </summary>
        /// <returns>The world</returns>
        public IGaia GetWorld()
        {
            IGaiaTemplate GaiaTemplate = Template <IZoneTemplate>().World;

            if (GaiaTemplate != null)
            {
                return(GaiaTemplate.GetLiveInstance());
            }

            return(null);
        }
Example #3
0
        public ActionResult Remove(long removeId = -1, string authorizeRemove = "", long unapproveId = -1, string authorizeUnapprove = "")
        {
            string message;

            if (!string.IsNullOrWhiteSpace(authorizeRemove) && removeId.ToString().Equals(authorizeRemove))
            {
                ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

                IGaiaTemplate obj = TemplateCache.Get <IGaiaTemplate>(removeId);

                if (obj == null)
                {
                    message = "That does not exist";
                }
                else if (obj.Remove(authedUser.GameAccount, authedUser.GetStaffRank(User)))
                {
                    LoggingUtility.LogAdminCommandUsage("*WEB* - RemoveGaiaTemplate[" + removeId.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                    message = "Delete Successful.";
                }
                else
                {
                    message = "Error; Removal failed.";
                }
            }
            else if (!string.IsNullOrWhiteSpace(authorizeUnapprove) && unapproveId.ToString().Equals(authorizeUnapprove))
            {
                ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

                IGaiaTemplate obj = TemplateCache.Get <IGaiaTemplate>(unapproveId);

                if (obj == null)
                {
                    message = "That does not exist";
                }
                else if (obj.ChangeApprovalStatus(authedUser.GameAccount, authedUser.GetStaffRank(User), ApprovalState.Returned))
                {
                    LoggingUtility.LogAdminCommandUsage("*WEB* - UnapproveGaiaTemplate[" + unapproveId.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                    message = "Unapproval Successful.";
                }
                else
                {
                    message = "Error; Unapproval failed.";
                }
            }
            else
            {
                message = "You must check the proper remove or unapprove authorization radio button first.";
            }

            return(RedirectToAction("Index", new { Message = message }));
        }
Example #4
0
        public ActionResult Edit(long id, string ArchivePath = "")
        {
            IGaiaTemplate obj = TemplateCache.Get <IGaiaTemplate>(id);

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

            AddEditGaiaViewModel vModel = new AddEditGaiaViewModel(ArchivePath, obj)
            {
                AuthedUser = UserManager.FindById(User.Identity.GetUserId())
            };

            return(View("~/Views/GameAdmin/Gaia/Edit.cshtml", vModel));
        }
Example #5
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();
        }
Example #6
0
        public ActionResult Add(AddEditGaiaViewModel vModel)
        {
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());
            IGaiaTemplate   newObj     = vModel.DataObject;
            string          message;

            if (newObj.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) == null)
            {
                message = "Error; Creation failed.";
            }
            else
            {
                LoggingUtility.LogAdminCommandUsage("*WEB* - AddGaiaTemplate[" + newObj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                message = "Creation Successful.";
            }

            return(RedirectToAction("Index", new { Message = message }));
        }
Example #7
0
        public Economy(IGaiaTemplate world)
        {
            Bases  = new HashSet <IEconomicBasis>();
            Trends = new HashSet <IEconomicTrend>();

            //We'll generate a new full set economy here
            IEnumerable <IInanimateTemplate> items = TemplateCache.GetAll <IInanimateTemplate>();

            foreach (DataStructure.Architectural.EntityBase.IQuality quality in items.SelectMany(obj => obj.Qualities))
            {
                MakeValuation(quality.Name);
            }

            foreach (IInanimateTemplate item in items)
            {
                MakeValuation(item);
            }
        }
Example #8
0
        public ActionResult Edit(long id, AddEditGaiaViewModel vModel)
        {
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

            IGaiaTemplate obj = TemplateCache.Get <IGaiaTemplate>(id);
            string        message;

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

            try
            {
                obj.Name                = vModel.DataObject.Name;
                obj.CelestialBodies     = vModel.DataObject.CelestialBodies;
                obj.ChronologicalSystem = vModel.DataObject.ChronologicalSystem;
                obj.Qualities           = vModel.DataObject.Qualities;
                obj.RotationalAngle     = vModel.DataObject.RotationalAngle;

                if (obj.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)))
                {
                    LoggingUtility.LogAdminCommandUsage("*WEB* - EditGaiaTemplate[" + obj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                    message = "Edit Successful.";
                }
                else
                {
                    message = "Error; Edit failed.";
                }
            }
            catch
            {
                message = "Error; Edit failed.";
            }

            return(RedirectToAction("Index", new { Message = message }));
        }