GetAvatarPlace() public method

public GetAvatarPlace ( FSO.SimAntics.VMEntity target, FSO.LotView.Model.LotTilePos pos, Direction dir ) : VMPlacementResult
target FSO.SimAntics.VMEntity
pos FSO.LotView.Model.LotTilePos
dir Direction
return VMPlacementResult
Ejemplo n.º 1
0
        public VMPlacementResult PositionValid(LotTilePos pos,Direction direction,VMContext context)
        {
            if (pos == LotTilePos.OUT_OF_WORLD)
            {
                return(new VMPlacementResult());
            }
            else if (context.IsOutOfBounds(pos))
            {
                return new VMPlacementResult {
                           Status = VMPlacementError.LocationOutOfBounds
                }
            }
            ;

            //TODO: speedup with exit early checks
            //TODO: corner checks (wtf uses this)

            var arch = context.Architecture;
            var wall = arch.GetWall(pos.TileX,pos.TileY,pos.Level); //todo: preprocess to check which walls are real solid walls and not fences.

            if (this is VMGameObject)                               //needs special handling for avatar eventually
            {
                VMPlacementError wallValid = WallChangeValid(wall,direction,true);

                if (wallValid != VMPlacementError.Success)
                {
                    return new VMPlacementResult {
                               Status = wallValid
                    }
                }
                ;
            }

            var floor = arch.GetFloor(pos.TileX,pos.TileY,pos.Level);
            VMPlacementError floorValid = FloorChangeValid(floor,pos.Level);

            if (floorValid != VMPlacementError.Success)
            {
                return new VMPlacementResult {
                           Status = floorValid
                }
            }
            ;

            //we've passed the wall test, now check if we intersect any objects.
            var valid = (this is VMAvatar)? context.GetAvatarPlace(this,pos,direction) : context.GetObjPlace(this,pos,direction);

            return(valid);
        }
Ejemplo n.º 2
0
        public VMPlacementResult PositionValid(LotTilePos pos, Direction direction, VMContext context)
        {
            if (pos == LotTilePos.OUT_OF_WORLD) return new VMPlacementResult();
            else if (context.IsOutOfBounds(pos)) return new VMPlacementResult { Status = VMPlacementError.LocationOutOfBounds };

            //TODO: speedup with exit early checks
            //TODO: corner checks (wtf uses this)

            var arch = context.Architecture;
            var wall = arch.GetWall(pos.TileX, pos.TileY, pos.Level); //todo: preprocess to check which walls are real solid walls and not fences.

            if (this is VMGameObject) //needs special handling for avatar eventually
            {
                VMPlacementError wallValid = WallChangeValid(wall, direction, true);
                if (wallValid != VMPlacementError.Success) return new VMPlacementResult { Status = wallValid };
            }

            var floor = arch.GetFloor(pos.TileX, pos.TileY, pos.Level);
            VMPlacementError floorValid = FloorChangeValid(floor, pos.Level);
            if (floorValid != VMPlacementError.Success) return new VMPlacementResult { Status = floorValid };

            //we've passed the wall test, now check if we intersect any objects.
            var valid = (this is VMAvatar)? context.GetAvatarPlace(this, pos, direction) : context.GetObjPlace(this, pos, direction);
            return valid;
        }