Ejemplo n.º 1
0
        /// <summary>
        /// Spawns a ragdoll on the map based on the different arguments.
        /// </summary>
        /// <remarks>
        /// Tip: You can do, for example, '<paramref name="velocity"/>: "Vector3.up * 3"' to skip parameters.
        /// </remarks>
        /// <example>
        /// <code>
        /// // Code to spawn a fake ragdoll
        /// if (ev.Player == MyPlugin.TheInmortalPlayer)
        /// {
        ///     var fakeRagdoll = Map.SpawnRagdoll(ev.Player.Role, ev.Player.Position, victimNick: ev.Player.DisplayNickname, playerId: ev.Player.Id);
        /// }
        /// </code>
        /// </example>
        /// <param name="roleType">The <see cref="RoleType"/> to use as ragdoll.</param>
        /// <param name="victimNick">The name from the victim, who the corpse belongs to.</param>
        /// <param name="hitInfo">The <see cref="PlayerStats.HitInfo"/> that displays who killed this ragdoll, and using which tool.</param>
        /// <param name="position">Where the ragdoll will be spawned.</param>
        /// <param name="rotation">The rotation for the ragdoll.</param>
        /// <param name="velocity">The initial velocity the ragdoll will have, as if it was exploded.</param>
        /// <param name="allowRecall">Sets this ragdoll as respawnable by SCP-049.</param>
        /// <param name="playerId">Used for recall. The <see cref="Player.Id"/> to be recalled.</param>
        /// <param name="mirrorOwnerId">Can be ignored. The <see cref="Dissonance.Integrations.MirrorIgnorance.MirrorIgnorancePlayer"/>'s PlayerId field, likely used in the client.</param>
        /// <returns>The Ragdoll component (requires Assembly-CSharp to be referenced).</returns>
        public static global::Ragdoll SpawnRagdoll(
            RoleType roleType,
            string victimNick,
            global::PlayerStats.HitInfo hitInfo,
            Vector3 position,
            Quaternion rotation  = default,
            Vector3 velocity     = default,
            bool allowRecall     = false,
            int playerId         = -1,
            string mirrorOwnerId = null)
        {
            global::Role role = CharacterClassManager._staticClasses.SafeGet(roleType);

            // Check if there's no ragdoll for this class, or if the class is invalid
            if (role.model_ragdoll == null)
            {
                return(null);
            }
            var @default = DefaultRagdollOwner;

            var ragdollInfo = new Ragdoll.Info()
            {
                ownerHLAPI_id = mirrorOwnerId != null ? mirrorOwnerId : @default.ownerHLAPI_id,
                PlayerId      = playerId,
                DeathCause    = hitInfo != default ? hitInfo : @default.DeathCause,
                ClassColor    = role.classColor,
                FullName      = role.fullName,
                Nick          = victimNick,
            };

            return(SpawnRagdoll(role, ragdollInfo, position, rotation, velocity, allowRecall));
        }