void OnLivingRequestsAction(LivingObject living, GameAction action) { turnTrace.TraceVerbose("SignalLivingHasAction({0}, {1}", living, action); if (m_world.IsOurTurn == false) { turnTrace.TraceWarning("SignalLivingHasAction when not our turn"); return; } m_actionMap[living] = action; SendProceedTurn(); }
IAssignment IJobSource.FindAssignment(ILivingObject _living) { var living = (LivingObject)_living; if (this.CurrentBuildOrder == null) return null; if (m_currentJob == null) { var job = CreateJob(this.CurrentBuildOrder); if (job == null) { trace.TraceWarning("XXX failed to create job, removing build order"); RemoveBuildOrder(this.CurrentBuildOrder); return null; } m_currentJob = job; trace.TraceInformation("new build job created"); } foreach (var a in m_currentJob.GetAssignments(living)) { if (a.LaborID == LaborID.None || living.GetLaborEnabled(a.LaborID)) return m_currentJob.FindAssignment(living); } return null; }
public void Send(ServerMessage msg) { if (m_connection == null) { trace.TraceWarning("Send: m_connection == null"); return; } if (!m_connection.IsConnected) { trace.TraceWarning("Send: m_connection.IsConnected == false"); return; } m_connection.Send(msg); }
void ReceiveMessage(ProceedTurnReplyMessage msg) { if (this.IsProceedTurnReplyReceived == true) { throw new Exception(); } foreach (var kvp in msg.Actions) { var actorOid = kvp.Key; var action = kvp.Value; if (m_world.CurrentLivingID != ObjectID.AnyObjectID && m_world.CurrentLivingID != actorOid) { trace.TraceWarning("received action request for living who's turn is not now: {0}", actorOid); continue; } var living = m_controllables.SingleOrDefault(l => l.ObjectID == actorOid); if (living == null) { trace.TraceWarning("received action request for non controlled living {0}", actorOid); continue; } if (living.Controller != this) { throw new Exception(); } if (action == null) { if (living.ActionPriority == ActionPriority.High) { throw new Exception(); } living.CancelAction(); continue; } if (living.HasAction) { if (living.ActionPriority <= ActionPriority.User) { living.CancelAction(); } else { throw new Exception("already has an action"); } } living.StartAction(action, ActionPriority.User); } this.IsProceedTurnReplyReceived = true; if (ProceedTurnReceived != null) { ProceedTurnReceived(this); } }