Inheritance: ContainerObject, IMovableObject
Example #1
0
        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;
        }
Example #2
0
 public ObjectMoveLocationChange(MovableObject mover, IntVector3 sourceLocation, IntVector3 destinationLocation)
     : base(mover)
 {
     this.SourceLocation      = sourceLocation;
     this.DestinationLocation = destinationLocation;
 }
Example #3
0
 internal void MoveChild(MovableObject ob, IntPoint3 srcLoc, IntPoint3 dstLoc)
 {
     OnChildMoved(ob, srcLoc, dstLoc);
 }
Example #4
0
 protected virtual void OnChildAdded(MovableObject child)
 {
 }
Example #5
0
 protected virtual void OnChildRemoved(MovableObject child)
 {
 }
Example #6
0
 public virtual bool OkToMoveChild(MovableObject ob, Direction dir, IntPoint3 dstLoc)
 {
     return true;
 }
Example #7
0
 protected virtual void OnChildMoved(MovableObject child, IntVector3 srcLoc, IntVector3 dstLoc)
 {
 }
Example #8
0
 protected virtual void OnChildMoved(MovableObject child, IntVector3 srcLoc, IntVector3 dstLoc)
 {
 }
Example #9
0
        protected override void OnChildMoved(MovableObject child, IntVector3 srcLoc, IntVector3 dstLoc)
        {
            if (srcLoc.Z == dstLoc.Z)
                return;

            var list = m_contentArray[srcLoc.Z];
            Debug.Assert(list.Contains(child));
            list.Remove(child);

            list = m_contentArray[dstLoc.Z];
            Debug.Assert(!list.Contains(child));
            list.Add(child);
        }
Example #10
0
 protected override void OnChildRemoved(MovableObject child)
 {
     var list = m_contentArray[child.Z];
     Debug.Assert(list.Contains(child));
     list.Remove(child);
 }
Example #11
0
 public override bool OkToMoveChild(MovableObject ob, Direction dir, IntVector3 dstLoc)
 {
     return EnvironmentExtensions.CanMoveFromTo(this, ob.Location, dir);
 }
Example #12
0
        public override bool OkToAddChild(MovableObject ob, IntVector3 p)
        {
            Debug.Assert(this.World.IsWritable);

            if (!this.Contains(p))
                return false;

            return true;
        }
Example #13
0
 public override bool OkToMoveChild(MovableObject ob, Direction dir, IntVector3 dstLoc)
 {
     return(EnvironmentExtensions.CanMoveFromTo(this, ob.Location, dir));
 }
Example #14
0
 protected virtual void OnChildAdded(MovableObject child)
 {
 }
Example #15
0
 internal void AddChild(MovableObject ob)
 {
     m_contents.Add(ob);
     OnChildAdded(ob);
 }
Example #16
0
 protected virtual void OnChildRemoved(MovableObject child)
 {
 }
Example #17
0
 internal void RemoveChild(MovableObject ob)
 {
     OnChildRemoved(ob);
     m_contents.Remove(ob);
 }
Example #18
0
 protected virtual void OnChildMoved(MovableObject child, IntPoint3 srcLoc, IntPoint3 dstLoc)
 {
 }
Example #19
0
 internal void RemoveChild(MovableObject ob)
 {
     OnChildRemoved(ob);
     m_contents.Remove(ob);
 }
Example #20
0
 public virtual bool OkToAddChild(MovableObject ob, IntPoint3 dstLoc)
 {
     return true;
 }
Example #21
0
 internal void AddChild(MovableObject ob)
 {
     m_contents.Add(ob);
     OnChildAdded(ob);
 }
Example #22
0
 internal void AddChild(MovableObject ob)
 {
     m_children.Add(ob);
     OnChildAdded(ob);
 }
Example #23
0
 internal void MoveChild(MovableObject ob, IntVector3 srcLoc, IntVector3 dstLoc)
 {
     OnChildMoved(ob, srcLoc, dstLoc);
 }
Example #24
0
 internal void RemoveChild(MovableObject ob)
 {
     OnChildRemoved(ob);
     m_children.Remove(ob);
 }
Example #25
0
 public virtual bool OkToAddChild(MovableObject ob, IntVector3 dstLoc)
 {
     return(true);
 }
Example #26
0
        public override bool OkToAddChild(MovableObject ob, IntVector3 dstLoc)
        {
            if (this.ItemInfo.IsContainer == false)
                throw new Exception();

            return true;
        }
Example #27
0
 public virtual bool OkToMoveChild(MovableObject ob, Direction dir, IntVector3 dstLoc)
 {
     return(true);
 }
Example #28
0
 public ObjectMoveLocationChange(MovableObject mover, IntPoint3 sourceLocation, IntPoint3 destinationLocation)
     : base(mover)
 {
     this.SourceLocation = sourceLocation;
     this.DestinationLocation = destinationLocation;
 }
Example #29
0
        bool CanSeeChange(Change change)
        {
            if (change is TurnStartChange)
            {
                // XXX Maybe this should be sent only if the player sees the Living
                return(true);
            }
            else if (change is TurnEndChange)
            {
                // XXX Maybe this should be sent only if the player sees the Living
                return(true);
            }
            else if (change is TickStartChange)
            {
                return(true);
            }
            else if (change is GameDateChange)
            {
                return(true);
            }
            else if (change is ObjectDestructedChange)
            {
                // XXX We should only send this if the player sees the object.
                // And the client should have a cleanup of some kind to remove old objects (which may or may not be destructed)
                return(true);
            }
            else if (change is ObjectCreatedChange)
            {
                return(false);
            }
            else if (change is ObjectMoveChange)
            {
                var c = (ObjectMoveChange)change;

                if (m_player.IsController(c.Object))
                {
                    return(true);
                }

                if (m_player.Sees(c.Source, c.SourceLocation))
                {
                    return(true);
                }

                if (m_player.Sees(c.Destination, c.DestinationLocation))
                {
                    return(true);
                }

                return(false);
            }
            else if (change is ObjectMoveLocationChange)
            {
                var c = (ObjectMoveLocationChange)change;

                if (m_player.IsController(c.Object))
                {
                    return(true);
                }

                // XXX
                var env = ((MovableObject)c.Object).Container;

                if (m_player.Sees(env, c.SourceLocation))
                {
                    return(true);
                }

                if (m_player.Sees(env, c.DestinationLocation))
                {
                    return(true);
                }

                return(false);
            }
            else if (change is MapChange)
            {
                var c = (MapChange)change;
                return(m_player.Sees(c.Environment, c.Location));
            }
            else if (change is PropertyChange)
            {
                var c = (PropertyChange)change;

                // fast path for controllables
                if (m_player.IsController(c.Object))
                {
                    return(true);
                }

                if (c.PropertyID == PropertyID.IsEquipped)
                {
                    // XXX special handling for IsEquipped for now
                    // We see the prop change even if the item is inside a non-controllable

                    var mo = (MovableObject)c.Object;

                    for (MovableObject o = mo; o != null; o = o.Container as MovableObject)
                    {
                        var ov = m_player.GetObjectVisibility(o);
                        if ((ov & ObjectVisibility.Public) != 0)
                        {
                            return(true);
                        }
                    }

                    return(false);
                }
                else
                {
                    var vis = PropertyVisibilities.GetPropertyVisibility(c.PropertyID);
                    var ov  = m_player.GetObjectVisibility(c.Object);

                    return((ov & vis) != 0);
                }
            }
            else if (change is ActionStartedChange)
            {
                var c = (ActionStartedChange)change;
                return(m_player.IsController(c.Object));
            }
            else if (change is ActionProgressChange)
            {
                var c = (ActionProgressChange)change;
                return(m_player.IsController(c.Object));
            }
            else if (change is ActionDoneChange)
            {
                var c = (ActionDoneChange)change;
                return(m_player.IsController(c.Object));
            }

            else if (change is ObjectChange)
            {
                var c = (ObjectChange)change;

                var vis = m_player.GetObjectVisibility(c.Object);

                return(vis != ObjectVisibility.None);
            }
            else
            {
                throw new Exception();
            }
        }