コード例 #1
0
        /// <summary>
        /// Launches a player.
        /// </summary>
        /// <param name="player">Player who requested launching.</param>
        public async void OnInteract(Player player)
        {
            // LUP launchpad is handled in its own component
            if (GameObject.TryGetComponent <LUPLaunchpadComponent>(out _))
            {
                return;
            }

            // Get the player rocket.
            var rocket = player.GetComponent <InventoryManagerComponent>()[InventoryType.Models].Items.FirstOrDefault(
                item => item.Lot == Lot.ModularRocket
                );

            if (rocket == default)
            {
                Logger.Error($"Could not find a valid rocket for {player}");
                return;
            }

            // Equip the rocket.
            rocket.WorldState = ObjectWorldState.Attached;

            player.Message(new FireEventClientSideMessage
            {
                Associate = GameObject,
                Arguments = "RocketEquipped",
                Target    = rocket,
                Sender    = player
            });

            // Set the player as landing by rocket for the next zone.
            if (!player.TryGetComponent <CharacterComponent>(out var characterComponent))
            {
                return;
            }
            characterComponent.LandingByRocket = true;
            if (this.AlternativeTargetScene != default && this.AlternativeTargetScenePrecondition.HasValue &&
                await Requirements.CheckPreconditionAsync(this.AlternativeTargetScenePrecondition.Value, player))
            {
                characterComponent.SpawnLocationName = this.AlternativeTargetScene;
            }
            else
            {
                characterComponent.SpawnLocationName = this.TargetScene;
            }
        }