示例#1
0
        public void PlaceObject(Mobile from, UOACZBaseConstructionDeed constructionDeed)
        {
            if (from == null || constructionDeed == null)
            {
                return;
            }

            PlayerMobile player = from as PlayerMobile;

            if (player == null)
            {
                return;
            }

            if (m_ConstructionTypeAllowed != ConstructionObjectType.Any)
            {
                if (constructionDeed.ConstructionType != m_ConstructionTypeAllowed)
                {
                    string objectType = "";

                    switch (m_ConstructionTypeAllowed)
                    {
                    case ConstructionObjectType.Fortification: objectType = "fortification"; break;

                    case ConstructionObjectType.Wall: objectType = "wall"; break;
                    }

                    player.SendMessage("Only " + objectType + " type construction objects may be placed at that location.");
                    return;
                }
            }

            Type type = constructionDeed.ConstructableObject;

            UOACZConstructable itemToBuild = (UOACZConstructable)Activator.CreateInstance(type);

            if (itemToBuild == null)
            {
                return;
            }

            Constructable = itemToBuild;
            Constructable.ConstructionTile = this;

            Constructable.MoveToWorld(Location, Map);
            Constructable.Facing = m_ObjectFacing;
            Constructable.UpdateOverrides();
            Constructable.UpdateDamagedState();

            player.PlaySound(0x3E5);
            player.SendMessage("You place the object in the construction slot. Use a repair hammer and restore it to full durability to activate it.");

            if (player.Backpack != null && constructionDeed.CraftedBy == player)
            {
                UOACZSystem.ChangeStat(player, UOACZSystem.UOACZStatType.HumanScore, UOACZSystem.HumanConstructableScorePoints, true);

                if (Utility.RandomDouble() <= UOACZSystem.HumanConstructableSurvivalStoneChance)
                {
                    player.Backpack.AddItem(new UOACZSurvivalStone(player));
                    player.SendMessage("You have earned a survival stone for your construction efforts!");
                }

                if (Utility.RandomDouble() <= UOACZSystem.HumanConstructableUpgradeTokenChance)
                {
                    player.Backpack.AddItem(new UOACZHumanUpgradeToken(player));
                    player.SendMessage("You have earned an upgrade token for your construction efforts!");
                }
            }

            constructionDeed.Delete();
        }