示例#1
0
        /// <summary>
        /// Toggle equipped status of entity, this will generate the proper result to potential add or remove the entity
        /// from the equipment array
        /// </summary>
        /// <param name="resultSet">Result</param>
        /// <param name="equippableEntity">Entity to equip</param>
        public void ToggleEquip(ResultSet resultSet, EntityID equippableEntity)
        {
            if (equippableEntity.e == null || equippableEntity.e.equippable == null)
            {
                return;
            }

            var slot = equippableEntity.e.equippable.slot;

            if (equipment[(int)slot] == equippableEntity)
            {
                resultSet.AddDequipped(owner, equippableEntity);
                resultSet.AddMessage(
                    C.FSTR.Set(C.STR_COLOR_NAME).Append(owner.e.name).Append("@- dequipped the ").Append(C.STR_COLOR_NAME).Append(equipment[(int)slot].e.name).Append("@-."));

                equipment[(int)slot] = EntityID.empty;
            }
            else
            {
                if (!equipment[(int)slot].isEmpty)
                {
                    resultSet.AddDequipped(owner, equipment[(int)slot]);
                    resultSet.AddMessage(
                        C.FSTR.Set(C.STR_COLOR_NAME).Append(owner.e.name).Append("@- dequipped the ").Append(C.STR_COLOR_NAME).Append(equipment[(int)slot].e.name).Append("@-."));
                }

                equipment[(int)slot] = equippableEntity;
                resultSet.AddEquipped(owner, equipment[(int)slot]);
                resultSet.AddMessage(
                    C.FSTR.Set(C.STR_COLOR_NAME).Append(owner.e.name).Append("@- equipped the ").Append(C.STR_COLOR_NAME).Append(equippableEntity.e.name).Append("@-."));
            }
        }