示例#1
0
文件: Fittings.cs 项目: Meigs2/BUZZ
        /// <summary>
        /// Save a new fitting for a character.
        /// <para>POST /characters/{character_id}/fittings/</para>
        /// </summary>
        /// <param name="auth">The <see cref="AuthDTO"/> object.</param>
        /// <param name="fitting">Details about the new fitting.</param>
        /// <returns><see cref="ESIModelDTO{T}"/> containing a list of fittings.</returns>
        public async Task <ESIModelDTO <long> > CreateFittingV1Async(AuthDTO auth, ShipFitting fitting)
        {
            CheckAuth(auth, Scopes.ESI_FITTINGS_READ_FITTINGS_1);

            var responseModel = await PostAsync($"/v1/characters/{auth.CharacterId}/fittings/", auth, fitting);

            CheckResponse(nameof(CreateFittingV1Async), responseModel.Error, responseModel.Message, responseModel.LegacyWarning, logger);

            return(ReturnModelDTO <long>(responseModel));
        }
        private static void InitFitting(ShipComp sdc, ShipFitting fit, GameObject WeaponsGO)
        {
            fit.FittedWeapon.Owner = sdc.Owner;             //have to manually set owner of contained components
            fit.WeaponFittingGO    = new GameObject("WeaponFitting");
            Transform tf = fit.WeaponFittingGO.transform;

            tf.SetParent(WeaponsGO.transform, false);
            tf.localPosition = fit.PositionOffset;
            tf.localRotation = fit.RotationOffset;

            //spawn weapon prefab if exists
            if (fit.FittedWeapon.LauncherPrefab.DoesNotContain("None"))
            {
                var weaponPF = Res.CreateFromPool(fit.FittedWeapon.LauncherPrefab);
                weaponPF.SetActive(true);
                weaponPF.transform.SetParent(tf, false);
                fit.FittedWeapon.WeaponGameObject = weaponPF;
                //weaponPF.transform.localPosition = fit.PositionOffset;
                fit.ProjectileSpawnPositionOffset = weaponPF.GetComponent <LauncherBehaviour>()?.LaunchPosOffset ?? Vector3.zero;
            }
        }