예제 #1
0
        protected void TimeTick(SimulationEvent ev)
        {
            //TODO: When a Time tick is received from the DDD, pass that tick back to the SeamateRuntime engine to see if any Items are triggered, and then
            //check the DDDAdapter's DDD Event Queue to see if any new events need to be sent to the DDD.

            int time = ((IntegerValue)ev["Time"]).value; // /1000?  do we want seconds or millis?

            //call tick on RuntimeEngine (callback)
            if (_tickCallback != null)
            {
                _tickCallback(time);
            }

            List <ScheduledAttack> attacksToStart = PopReadyAttacks(time);


            lock (GroundTruthLock)
            {
                List <DDDEvent> eventsToSend = _eventsQueue.GetEventsUpTo(time);
                foreach (ScheduledAttack a in attacksToStart)
                {
                    if (_revealedObjects.ContainsKey(a.attackerid) && _revealedObjects.ContainsKey(a.targetid))
                    {
                        eventsToSend.Add(new AttackEvent(a.attackerid, a.targetid, "Surface to surface", time));
                    }
                }

                foreach (DDDEvent e in eventsToSend)
                {
                    _dddConnection.SendSimEvent(e.ToSimulationEvent(ref _simModel));
                }
            }
            Console.WriteLine("Tick");
        }