Exemplo n.º 1
0
 internal void ExaminedBy(GameObject viewer, bool fromInside)
 {
     if (HasComponent(Text.CompVisible))
     {
         VisibleComponent comp = (VisibleComponent)GetComponent(Text.CompVisible);
         comp.ExaminedBy(viewer, fromInside);
     }
     else
     {
         viewer.WriteLine("There is nothing there.");
     }
 }
Exemplo n.º 2
0
        internal override void ConfigureFromJson(JToken compData)
        {
            enterMessage = $"{parent.name} enters from the $DIR.";
            leaveMessage = $"{parent.name} leaves to the $DIR.";
            deathMessage = $"The corpse of {parent.name} lies here.";

            Bodyplan bp = null;

            if (!JsonExtensions.IsNullOrEmpty(compData["mobtype"]))
            {
                bp = Modules.Bodies.GetPlan((string)compData["mobtype"]);
            }
            if (bp == null)
            {
                bp = Modules.Bodies.GetPlan("humanoid");
            }

            foreach (Bodypart b in bp.allParts)
            {
                GameObject newLimb = (GameObject)Game.Objects.CreateNewInstance(false);
                newLimb.name = "limb";
                newLimb.aliases.Add("bodypart");

                VisibleComponent vis = (VisibleComponent)newLimb.AddComponent(Text.CompVisible);
                vis.SetValue(Text.FieldShortDesc, b.name);
                vis.SetValue(Text.FieldRoomDesc, $"A severed {b.name} has been left here.");
                vis.SetValue(Text.FieldExaminedDesc, $"It is a severed {b.name} that has been lopped off its owner.");

                PhysicsComponent phys = (PhysicsComponent)newLimb.AddComponent(Text.CompPhysics);
                phys.width      = b.width;
                phys.length     = b.length;
                phys.height     = b.height;
                phys.strikeArea = b.strikeArea;
                phys.edged      = b.isEdged;
                phys.UpdateValues();

                BodypartComponent body = (BodypartComponent)newLimb.AddComponent(Text.CompBodypart);
                body.canGrasp        = b.canGrasp;
                body.canStand        = b.canStand;
                body.isNaturalWeapon = b.isNaturalWeapon;

                foreach (string s in b.equipmentSlots)
                {
                    if (!body.equipmentSlots.Contains(s))
                    {
                        body.equipmentSlots.Add(s);
                    }
                }
                Game.Objects.AddDatabaseEntry(newLimb);
                limbs.Add(b.name, newLimb);
            }
            UpdateLists();
        }
Exemplo n.º 3
0
        internal PlayerAccount CreateAccount(string userName, string passwordHash)
        {
            // Create the new, blank account.
            PlayerAccount acct = (PlayerAccount)CreateNewInstance(GetUnusedIndex(), false);

            acct.userName     = userName;
            acct.passwordHash = passwordHash;

            // Create the shell the client will be piloting around, saving data to, etc.
            GameObject gameObj = Modules.Templates.Instantiate("mob");

            gameObj.name    = Text.Capitalize(acct.userName);
            gameObj.gender  = Modules.Gender.GetByTerm(Text.GenderPlural);
            gameObj.aliases = new List <string>()
            {
                gameObj.name.ToLower()
            };
            VisibleComponent vis = (VisibleComponent)gameObj.GetComponent(Text.CompVisible);

            vis.SetValue(Text.FieldShortDesc, $"{gameObj.name}");
            vis.SetValue(Text.FieldRoomDesc, $"{gameObj.name} is here.");
            vis.SetValue(Text.FieldExaminedDesc, "and are completely uninteresting.");
            MobileComponent mob = (MobileComponent)gameObj.GetComponent(Text.CompMobile);

            mob.SetValue(Text.FieldEnterMessage, $"{gameObj.name} enters from the $DIR.");
            mob.SetValue(Text.FieldLeaveMessage, $"{gameObj.name} leaves to the $DIR.");
            mob.SetValue(Text.FieldDeathMessage, $"The corpse of {gameObj.name} lies here.");
            Game.Objects.QueueForUpdate(gameObj);

            acct.objectId = gameObj.id;

            // If the account DB is empty, give them admin roles.
            if (accounts.Count <= 0)
            {
                Debug.WriteLine($"No accounts found, giving admin roles to {acct.userName}.");
                acct.roles.Add(Modules.Roles.GetRole("builder"));
                acct.roles.Add(Modules.Roles.GetRole("administrator"));
            }

            // Finalize everything.
            accounts.Add(acct.userName, acct);
            AddDatabaseEntry(acct);
            return(acct);
        }