public object FromRef(int refID) { var oid = new ObjectID((uint)refID); var ob = m_world.GetObject(oid); return(ob); }
void HandleChange(ObjectMoveChangeData change) { var ob = m_world.FindObject <MovableObject>(change.ObjectID); if (ob == null) { /* There's a special case where we don't get objectinfo, but we do get * ObjectMove: If the object moves from tile, that just came visible to us, * to a tile that we cannot see. So let's not throw exception, but exit * silently */ // XXX is this still valid? return; } Debug.Assert(ob.IsInitialized); ContainerObject env = null; if (change.DestinationID != ObjectID.NullObjectID) { env = m_world.GetObject <ContainerObject>(change.DestinationID); } ob.MoveTo(env, change.DestinationLocation); }
void HandleMessage(ControllablesDataMessage msg) { bool b; switch (msg.Operation) { case ControllablesDataMessage.Op.Add: b = true; break; case ControllablesDataMessage.Op.Remove: b = false; break; default: throw new Exception(); } foreach (var oid in msg.Controllables) { var l = m_world.GetObject <LivingObject>(oid); l.IsControllable = b; } }
public void SendProceedTurn() { turnTrace.TraceVerbose("SendProceedTurn"); if (m_world.IsOurTurn == false) { turnTrace.TraceWarning("SendProceedTurn when not our turn"); return; } if (m_proceedTurnSent) { turnTrace.TraceWarning("SendProceedTurn when proceed turn already sent"); return; } var list = new List <KeyValuePair <ObjectID, GameAction> >(); IEnumerable <LivingObject> livings; if (m_world.CurrentLivingID == ObjectID.AnyObjectID) { // livings which the user can control (ie. server not doing high priority action) livings = m_world.Controllables.Where(l => l.UserActionPossible()); } else { var living = m_world.GetObject <LivingObject>(m_world.CurrentLivingID); if (living.UserActionPossible() == false) { throw new NotImplementedException(); } livings = new LivingObject[] { living }; } var focusedObject = this.FocusedObject; foreach (var living in livings) { GameAction action; if (m_actionMap.TryGetValue(living, out action) == false) { // skip AI if we're directly controlling the living if (focusedObject != living) { action = living.DecideAction(); } else { action = living.CurrentAction; } } Debug.Assert(action == null || action.GUID.IsNull == false); if (action != living.CurrentAction) { turnTrace.TraceVerbose("{0}: selecting new action {1}", living, action); list.Add(new KeyValuePair <ObjectID, GameAction>(living.ObjectID, action)); } } m_user.Send(new Dwarrowdelf.Messages.ProceedTurnReplyMessage() { Actions = list.ToArray() }); m_proceedTurnSent = true; m_actionMap.Clear(); }