Example #1
0
 public override void OnClearScene()
 {
     if (GameNetwork.IsServer)
     {
         foreach (Agent agent in this._agentTimers.Keys.ToList <Agent>())
         {
             this.OnAgentWentInOrRemoved(agent, true);
         }
     }
     else
     {
         if (this._mainAgentLeaveTimer == null)
         {
             return;
         }
         if (this.Mission.MainAgent != null)
         {
             this.OnAgentWentInOrRemoved(this.Mission.MainAgent, true);
         }
         else
         {
             this._mainAgentLeaveTimer = (MissionTimer)null;
         }
     }
 }
Example #2
0
        private void OnAgentWentInOrRemoved(Agent agent, bool isAgentRemoved)
        {
            if (GameNetwork.IsServer)
            {
                this._agentTimers.Remove(agent);
                if (!isAgentRemoved)
                {
                    MissionPeer         missionPeer  = agent.MissionPeer;
                    NetworkCommunicator communicator = missionPeer != null?missionPeer.GetNetworkPeer() : (NetworkCommunicator)null;

                    if (communicator != null && !communicator.IsServerPeer)
                    {
                        GameNetwork.BeginModuleEventAsServer(communicator);
                        GameNetwork.WriteMessage((GameNetworkMessage) new SetBoundariesState(false));
                        GameNetwork.EndModuleEventAsServer();
                    }
                }
            }
            if (this.Mission.MainAgent != agent)
            {
                return;
            }
            this._mainAgentLeaveTimer = (MissionTimer)null;
            Action stopTime = this.StopTime;

            if (stopTime == null)
            {
                return;
            }
            stopTime();
        }
Example #3
0
 private void HandleAgentStateChange(
     Agent agent,
     bool isAgentOutside,
     bool isTimerActiveForAgent,
     MissionTimer timerInstance)
 {
     if (isAgentOutside && !isTimerActiveForAgent)
     {
         this.OnAgentWentOut(agent, 0.0f);
     }
     else if (!isAgentOutside & isTimerActiveForAgent)
     {
         this.OnAgentWentInOrRemoved(agent, false);
     }
     else
     {
         if (!isAgentOutside || !timerInstance.Check())
         {
             return;
         }
         this.HandleAgentPunishment(agent);
     }
 }
Example #4
0
        private void OnAgentWentOut(Agent agent, float startTimeInSeconds)
        {
            MissionTimer missionTimer = GameNetwork.IsClient ? MissionTimer.CreateSynchedTimerClient(startTimeInSeconds, 10f) : new MissionTimer(10f);

            if (GameNetwork.IsServer)
            {
                this._agentTimers.Add(agent, missionTimer);
                MissionPeer         missionPeer  = agent.MissionPeer;
                NetworkCommunicator communicator = missionPeer != null?missionPeer.GetNetworkPeer() : (NetworkCommunicator)null;

                if (communicator != null && !communicator.IsServerPeer)
                {
                    GameNetwork.BeginModuleEventAsServer(communicator);
                    GameNetwork.WriteMessage((GameNetworkMessage) new SetBoundariesState(true, missionTimer.GetStartTime().NumberOfTicks));
                    GameNetwork.EndModuleEventAsServer();
                }
            }
            if (this.Mission.MainAgent != agent)
            {
                return;
            }
            this._mainAgentLeaveTimer = missionTimer;
            Action <float, float> startTime = this.StartTime;

            if (startTime != null)
            {
                startTime(10f, 0.0f);
            }
            MatrixFrame cameraFrame = Mission.Current.GetCameraFrame();
            Vec3        position    = cameraFrame.origin + cameraFrame.rotation.u;

            if (Mission.Current.Mode != MissionMode.Battle)
            {
                return;
            }
            MBSoundEvent.PlaySound(SoundEvent.GetEventIdFromString("event:/alerts/report/out_of_map"), position);
        }
 public void StartTimerAsClient(float startTime, float duration)
 {
     this._missionTimer  = MissionTimer.CreateSynchedTimerClient(startTime, duration);
     this.IsTimerRunning = true;
 }
 public void StartTimerAsServer(float duration)
 {
     this._missionTimer  = new MissionTimer(duration);
     this.IsTimerRunning = true;
 }
Example #7
0
 private void RearmTickTimer() => this._tickTimer = new MissionTimer(2.5f + MBRandom.RandomFloat);