Пример #1
0
        public Sub LaunchSub(IGameState state, LaunchEvent launchEvent)
        {
            // Determine any specialist effects if a specialist left the sub.
            LaunchEventData launchData  = launchEvent.GetEventData();
            Entity          source      = state.GetEntity(launchData.SourceId);
            Entity          destination = state.GetEntity(launchData.DestinationId);

            if (destination != null && _drillerCarrier.HasDrillers(launchData.DrillerCount))
            {
                _drillerCarrier.RemoveDrillers(launchData.DrillerCount);
                Sub launchedSub = new Sub(launchEvent.GetEventId(), source, destination, state.GetCurrentTick(), launchData.DrillerCount, this._drillerCarrier.GetOwner());
                this._specialistManager.TransferSpecialistsById(launchedSub.GetComponent <SpecialistManager>(), launchData.SpecialistIds.ToList());
                state.AddSub(launchedSub);
                launchEvent.SetLaunchedSub(launchedSub);

                OnSubLaunch?.Invoke(this, new OnSubLaunchEventArgs()
                {
                    Destination = destination,
                    LaunchedSub = launchedSub,
                    LaunchEvent = launchEvent,
                    Source      = source
                });

                return(launchedSub);
            }

            return(null);
        }