Example #1
0
        public ActorSolarSystem(IActorRef actorEngine, IActorRef actorTextOutput, SolarSystem ss)
        {
            _actorEngine = actorEngine;
            _actorTextOutput = actorTextOutput;
            ss.Actor = Self;
            _solarSystemC = new SolarSystemController(ss, this, actorTextOutput);
            _tickCompleteCmd = new MessageEngineSSCompletedCommand(_solarSystemC.SolarSystemId);

            setupChildMarketActors(ss);
            setupChildAgentActors(ss);

            Receive<MessageTick>(msg => receiveTick(msg));
            Receive<MessageShipCommand>(msg => receiveCommandForShip(msg));
            Receive<MessageEngineAgCompletedCommand>(msg => receiveAgentCompletedMessage(msg));

            //_actorTextOutput.Tell("Solar System initialised : " + _solarSystem.Name);
        }
        public SolarSystemController(SolarSystem ss, ActorSolarSystem parentActor, IActorRef actorTextOutput)
        {
            _model = ss;
            _parentActor = parentActor;
            _actorTextOutput = actorTextOutput;

            // create child controller for each planet in ss
            _planetCs = new Dictionary<Int64, PlanetController>();
            foreach (Planet p in ss.Planets)
            {
                PlanetController pc = new PlanetController(p, actorTextOutput);
                _planetCs.Add(p.PlanetId, pc);
            }
            _planetValues = _planetCs.Values;

            // create child controller for each ship in ss
            _shipCs = new Dictionary<Int64, ShipController>();
            foreach (Ship s in ss.Ships)
            {
                ShipController sc = new ShipController(s, this, actorTextOutput);
                _shipCs.Add(s.ShipId, sc);
            }
            _shipValues = _shipCs.Values;
        }
Example #3
0
 private void setupChildAgentActors(SolarSystem ss)
 {
     // create child actors for each agent in ss
     _subscribedActorAgents = new Dictionary<Int64, IActorRef>();
     _numberOfIncompleteAg = ss.Agents.Count();
     foreach (Agent agent in ss.Agents)
     {
         Props agentProps = Props.Create<ActorAgent>(_actorTextOutput, agent, Self);
         IActorRef actor = Context.ActorOf(agentProps, "Agent" + agent.AgentId.ToString());
         _subscribedActorAgents.Add(agent.AgentId, actor);
     }
     _actorAgentValues = _subscribedActorAgents.Values;
 }
Example #4
0
 private void setupChildMarketActors(SolarSystem ss)
 {
     _subscribedActorMarkets = new Dictionary<Int64, IActorRef>();
     foreach (Planet p in ss.Planets)
     {
         // TODO only create market actors for planets with an active market
         Props marketProps = Props.Create<ActorMarket>(_actorTextOutput, p.Market, ss.Actor);
         IActorRef actor = Context.ActorOf(marketProps, "Market" + p.StarChartId.ToString());
         _subscribedActorMarkets.Add(p.StarChartId, actor);
     }
 }
Example #5
0
 private SolarSystem getSolarSystemFromStarChartSS(ScSolarSystem chartSS)
 {
     SolarSystem ss = new SolarSystem();
     ss.Name = chartSS.Name;
     return ss;
 }