// Move to a location in a new container void MoveToLow(ContainerObject dst, IntVector3 dstLoc) { Debug.Assert(this.IsInitialized); Debug.Assert(!this.IsDestructed); Debug.Assert(this.Container != dst); var src = this.Container; var srcLoc = this.Location; this.OnParentChanging(); if (src != null) src.RemoveChild(this); this.Container = dst; this.Location = dstLoc; if (dst != null) dst.AddChild(this); this.OnParentChanged(src, dst); this.World.AddChange(new ObjectMoveChange(this, src, srcLoc, dst, dstLoc)); }
public ObjectMoveChange(MovableObject mover, ContainerObject sourceEnv, IntPoint3 sourceLocation, ContainerObject destinationEnv, IntPoint3 destinationLocation) : base(mover) { this.Source = sourceEnv; this.SourceLocation = sourceLocation; this.Destination = destinationEnv; this.DestinationLocation = destinationLocation; }
public void MoveToMustSucceed(ContainerObject dst, IntVector3 dstLoc = new IntVector3()) { bool ok = MoveTo(dst, dstLoc); if (!ok) throw new Exception(); }
protected virtual void OnParentChanged(ContainerObject src, ContainerObject dst) { }
public bool MoveTo(ContainerObject dst, IntVector3 dstLoc = new IntVector3()) { Debug.Assert(this.World.IsWritable); if (!OkToMove()) return false; if (this.Container == dst && this.Location == dstLoc) return true; if (dst != null && !dst.OkToAddChild(this, dstLoc)) return false; if (dst != this.Container) MoveToLow(dst, dstLoc); else MoveToLow(dstLoc); return true; }
public void MoveToMustSucceed(ContainerObject container) { bool ok = MoveTo(container); if (!ok) throw new Exception(); }
public bool MoveTo(ContainerObject container) { if (this.Container == container) return true; return MoveTo(container, new IntVector3()); }
protected override void OnParentChanged(ContainerObject src, ContainerObject dst) { m_losMapVersion = 0; if (this.ParentChanged != null) this.ParentChanged(this, src, dst); }
void OnControllableParentChanged(LivingObject living, ContainerObject _src, ContainerObject _dst) { var src = _src as EnvironmentObject; if (src != null) { var tracker = GetVisionTrackerInternal(src); tracker.RemoveLiving(living); } var dst = _dst as EnvironmentObject; if (dst != null) { var tracker = GetVisionTrackerInternal(src); tracker.AddLiving(living); } }
public bool MoveTo(ContainerObject parent) { if (this.Parent == parent) return true; return MoveTo(parent, new IntPoint3()); }