void Environment_ObjectAdded(MovableObject obj) { var item = obj as ItemObject; if (item == null) return; Debug.Assert(m_items.Contains(item) == false); m_items.Add(item); }
void Environment_ObjectMoved(MovableObject ob, IntVector3 oldPos) { if (this.Area.Contains(oldPos) == false) return; var item = ob as ItemObject; if (item != null && item.StockpiledBy == this) item.StockpiledBy = null; }
public static void AddGameEvent(MovableObject ob, string message) { AddGameEvent(ob.Environment, ob.Location, message); }
protected virtual void ChildRemoved(MovableObject child) { }
protected virtual void ChildAdded(MovableObject child) { }
public void MoveChild(MovableObject ob, IntVector3 from, IntVector3 to) { ChildMoved(ob, from, to); }
void OnObjectAddedOrRemoved(MovableObject ob) { m_invalid = true; }
void OnObjectMoved(MovableObject ob, IntVector3 p) { m_invalid = true; }
protected virtual void ChildMoved(MovableObject child, IntPoint3 from, IntPoint3 to) { }
public void RemoveChild(MovableObject ob) { m_inventory.Remove(ob); ChildRemoved(ob); }
public void MoveChild(MovableObject ob, IntPoint3 from, IntPoint3 to) { ChildMoved(ob, from, to); }
public void AddChild(MovableObject ob) { m_inventory.Add(ob); ChildAdded(ob); }
void Environment_ObjectMoved(MovableObject obj, IntPoint3 oldPos) { var item = obj as ItemObject; if (item == null) return; // nop for now }
// called from object when its visual property changes internal void OnObjectVisualChanged(MovableObject ob) { if (MapTileObjectChanged != null) MapTileObjectChanged(ob, ob.Location, MapTileObjectChangeType.Update); }
public void RemoveChild(MovableObject ob) { m_contents.Remove(ob); ChildRemoved(ob); }
protected override void ChildAdded(MovableObject child) { IntPoint3 l = child.Location; List<MovableObject> obs; if (!m_objectMap.TryGetValue(l, out obs)) { obs = new List<MovableObject>(); m_objectMap[l] = obs; } Debug.Assert(!obs.Contains(child)); if (child.IsLiving) obs.Insert(0, child); else obs.Add(child); if (MapTileObjectChanged != null) MapTileObjectChanged(child, l, MapTileObjectChangeType.Add); if (this.ObjectAdded != null) this.ObjectAdded(child); }
protected override void ChildMoved(MovableObject child, IntPoint3 from, IntPoint3 to) { List<MovableObject> obs; /* first remove from the old position ... */ Debug.Assert(m_objectMap.ContainsKey(from)); obs = m_objectMap[from]; bool removed = obs.Remove(child); Debug.Assert(removed); if (MapTileObjectChanged != null) MapTileObjectChanged(child, from, MapTileObjectChangeType.Remove); /* ... and then add to the new one */ if (!m_objectMap.TryGetValue(to, out obs)) { obs = new List<MovableObject>(); m_objectMap[to] = obs; } Debug.Assert(!obs.Contains(child)); if (child.IsLiving) obs.Insert(0, child); else obs.Add(child); if (MapTileObjectChanged != null) MapTileObjectChanged(child, to, MapTileObjectChangeType.Add); if (this.ObjectMoved != null) this.ObjectMoved(child, from); }
public void AddChild(MovableObject ob) { m_contents.Add(ob); ChildAdded(ob); }
protected override void ChildRemoved(MovableObject child) { IntPoint3 l = child.Location; Debug.Assert(m_objectMap.ContainsKey(l)); List<MovableObject> obs = m_objectMap[l]; bool removed = obs.Remove(child); Debug.Assert(removed); if (MapTileObjectChanged != null) MapTileObjectChanged(child, l, MapTileObjectChangeType.Remove); if (this.ObjectRemoved != null) this.ObjectRemoved(child); }
protected virtual void ChildMoved(MovableObject child, IntVector3 from, IntVector3 to) { }
public static void AddGameEvent(MovableObject ob, string format, params object[] args) { AddGameEvent(ob.Environment, ob.Location, String.Format(format, args)); }
public void CameraMoveTo(MovableObject ob) { if (ob == null) { this.Environment = null; } else { var env = ob.Environment; CameraMoveTo(env, ob.Location); } }
void Environment_ObjectRemoved(MovableObject ob) { if (this.Area.Contains(ob.Location) == false) return; var item = ob as ItemObject; if (item != null && item.StockpiledBy == this) item.StockpiledBy = null; }
void Environment_ObjectRemoved(MovableObject obj) { var item = obj as ItemObject; if (item == null) return; Debug.Assert(m_items.Contains(item) == true); m_items.Remove(item); }