public void AddBuildOrder(BuildOrder buildOrder) { buildOrder.PropertyChanged += OnBuildOrderPropertyChanged; m_buildOrderQueue.Add(buildOrder); trace.TraceInformation("new order {0}", buildOrder); if (this.CurrentBuildOrder == null) MoveToNextBuildOrder(); }
void OnTickStarted() { if (this.Environment == null) { return; } if (this.Environment.Contains(this.Location.Down) == false) { // XXX falls off the map return; } if (this.Environment.GetTileData(this.Location).HasSupportBelow == false) { // fall down Trace.TraceInformation("{0} falls down", this); this.MoveToMustSucceed(this.Location.Down); if (this.HasAction) { this.CancelAction(); } } }
public void SetPlayer(Player player) { trace.TraceInformation("{0} takes control of {1}", this, player); this.Player = player; player.ConnectUser(this); if (m_ipStartTask != null) { m_ipStartTask.Wait(); } if (m_ipRunner != null) { m_ipRunner.SetPlayer(player); } }
void OnNewMessages(object state) { Message msg; while (m_connection.TryGetMessage(out msg)) { InvokeMessageHandler((ClientMessage)msg); } m_onNewMessagesInvoked = false; while (m_connection.TryGetMessage(out msg)) { InvokeMessageHandler((ClientMessage)msg); } if (m_connection.IsConnected == false) { trace.TraceInformation("OnDisconnect"); m_world = null; m_state = ClientUserState.Disconnected; if (DisconnectEvent != null) { DisconnectEvent(); } DH.Dispose(ref m_connection); } }
void OnConnected() { trace.TraceInformation("OnConnected"); m_world.WorldChanged += HandleWorldChange; m_world.ReportReceived += HandleReport; Send(new Messages.LogOnReplyBeginMessage() { PlayerID = this.PlayerID, IsSeeAll = m_seeAll, GameMode = m_engine.GameMode, }); m_world.SendWorldData(this); m_world.SendTo(this, m_seeAll ? ObjectVisibility.All : ObjectVisibility.Public); InitControllablesVisionTracker(m_controllables); SendAddControllables(m_controllables); Send(new Messages.ClientDataMessage() { ClientData = m_engine.LoadClientData(this.PlayerID, m_engine.LastLoadID), }); Send(new Messages.LogOnReplyEndMessage() { }); if (m_world.IsTickOnGoing) { if (m_world.TickMethod == WorldTickMethod.Simultaneous) { var change = new TurnStartChange(null); m_changeHandler.HandleWorldChange(change); } else { throw new NotImplementedException(); } } }
public void Run(EventWaitHandle serverStartWaitHandle) { this.World.TickStarted += OnTickStarted; this.World.TickEnded += OnTickEnded; this.World.TurnStarting += OnTurnStarting; this.World.TurnEnded += OnTurnEnded; PipeConnectionListener.StartListening(_OnNewConnection); TcpConnectionListener.StartListening(_OnNewConnection, "SNet"); DirectConnectionListener.StartListening(_OnNewConnection); trace.TraceInformation("The server is ready."); if (serverStartWaitHandle != null) { serverStartWaitHandle.Set(); } CheckForStartTick(); // Enter the main loop m_dispatcher.Run(MainWork); trace.TraceInformation("Server exiting"); DirectConnectionListener.StopListening(); TcpConnectionListener.StopListening(); PipeConnectionListener.StopListening(); this.World.TurnEnded -= OnTurnEnded; this.World.TurnStarting -= OnTurnStarting; this.World.TickEnded -= OnTickEnded; this.World.TickStarted -= OnTickStarted; // Need to disconnect the sockets foreach (var user in m_users) { if (user.IsConnected) { user.Disconnect(); } } trace.TraceInformation("Server exit"); }