Exemplo n.º 1
0
        public bool TeleportMove(Mobj thing, Fixed x, Fixed y)
        {
            // Kill anything occupying the position.
            currentThing = thing;
            currentFlags = thing.Flags;

            currentX = x;
            currentY = y;

            currentBox[Box.Top]    = y + currentThing.Radius;
            currentBox[Box.Bottom] = y - currentThing.Radius;
            currentBox[Box.Right]  = x + currentThing.Radius;
            currentBox[Box.Left]   = x - currentThing.Radius;

            var ss = Geometry.PointInSubsector(x, y, world.Map);

            currentCeilingLine = null;

            // The base floor / ceiling is from the subsector that contains the point.
            // Any contacted lines the step closer together will adjust them.
            currentFloorZ   = currentDropoffZ = ss.Sector.FloorHeight;
            currentCeilingZ = ss.Sector.CeilingHeight;

            var validcount = world.GetNewValidCount();

            crossedSpecialCount = 0;

            // Stomp on any things contacted.
            var bm      = world.Map.BlockMap;
            var blockX1 = bm.GetBlockX(currentBox[Box.Left] - GameConst.MaxThingRadius);
            var blockX2 = bm.GetBlockX(currentBox[Box.Right] + GameConst.MaxThingRadius);
            var blockY1 = bm.GetBlockY(currentBox[Box.Bottom] - GameConst.MaxThingRadius);
            var blockY2 = bm.GetBlockY(currentBox[Box.Top] + GameConst.MaxThingRadius);

            for (var bx = blockX1; bx <= blockX2; bx++)
            {
                for (var by = blockY1; by <= blockY2; by++)
                {
                    if (!bm.IterateThings(bx, by, stompThingFunc))
                    {
                        return(false);
                    }
                }
            }

            // the move is ok, so link the thing into its new position
            UnsetThingPosition(thing);

            thing.FloorZ   = currentFloorZ;
            thing.CeilingZ = currentCeilingZ;
            thing.X        = x;
            thing.Y        = y;

            SetThingPosition(thing);

            return(true);
        }
Exemplo n.º 2
0
 public MobjInfo(
     string name,
     int doomEdNum,
     MobjState spawnState,
     int spawnHealth,
     MobjState seeState,
     Sfx seeSound,
     int reactionTime,
     Sfx attackSound,
     MobjState painState,
     int painChance,
     Sfx painSound,
     MobjState meleeState,
     MobjState missileState,
     MobjState deathState,
     MobjState xdeathState,
     Sfx deathSound,
     int speed,
     Fixed radius,
     Fixed height,
     int mass,
     int damage,
     Sfx activeSound,
     MobjFlags flags,
     MobjState raiseState
     )
 {
     this.Name         = name;
     this.doomEdNum    = doomEdNum;
     this.spawnState   = spawnState;
     this.spawnHealth  = spawnHealth;
     this.seeState     = seeState;
     this.seeSound     = seeSound;
     this.reactionTime = reactionTime;
     this.attackSound  = attackSound;
     this.painState    = painState;
     this.painChance   = painChance;
     this.painSound    = painSound;
     this.meleeState   = meleeState;
     this.missileState = missileState;
     this.deathState   = deathState;
     this.xdeathState  = xdeathState;
     this.deathSound   = deathSound;
     this.speed        = speed;
     this.radius       = radius;
     this.height       = height;
     this.mass         = mass;
     this.damage       = damage;
     this.activeSound  = activeSound;
     this.flags        = flags;
     this.raiseState   = raiseState;
 }
Exemplo n.º 3
0
        /// <summary>
        /// This is purely informative, nothing is modified
        /// (except things picked up).
        ///
        /// In:
        ///     A Mobj (can be valid or invalid)
        ///     A position to be checked
        ///     (doesn't need to be related to the mobj.X and Y)
        ///
        /// During:
        ///     Special things are touched if MobjFlags.PickUp
        ///     Early out on solid lines?
        ///
        /// Out:
        ///     New subsector
        ///     CurrentFloorZ
        ///     CurrentCeilingZ
        ///     CurrentDropoffZ
        ///     The lowest point contacted
        ///     (monsters won't move to a dropoff)
        ///     crossedSpecials[]
        ///     crossedSpecialCount
        /// </summary>
        public bool CheckPosition(Mobj thing, Fixed x, Fixed y)
        {
            var map = world.Map;
            var bm  = map.BlockMap;

            currentThing = thing;
            currentFlags = thing.Flags;

            currentX = x;
            currentY = y;

            currentBox[Box.Top]    = y + currentThing.Radius;
            currentBox[Box.Bottom] = y - currentThing.Radius;
            currentBox[Box.Right]  = x + currentThing.Radius;
            currentBox[Box.Left]   = x - currentThing.Radius;

            var newSubsector = Geometry.PointInSubsector(x, y, map);

            currentCeilingLine = null;

            // The base floor / ceiling is from the subsector that contains the point.
            // Any contacted lines the step closer together will adjust them.
            currentFloorZ   = currentDropoffZ = newSubsector.Sector.FloorHeight;
            currentCeilingZ = newSubsector.Sector.CeilingHeight;

            var validCount = world.GetNewValidCount();

            crossedSpecialCount = 0;

            if ((currentFlags & MobjFlags.NoClip) != 0)
            {
                return(true);
            }

            // Check things first, possibly picking things up.
            // The bounding box is extended by MaxThingRadius because mobj_ts are grouped into
            // mapblocks based on their origin point, and can overlap into adjacent blocks by up
            // to MaxThingRadius units.
            {
                var blockX1 = bm.GetBlockX(currentBox[Box.Left] - GameConst.MaxThingRadius);
                var blockX2 = bm.GetBlockX(currentBox[Box.Right] + GameConst.MaxThingRadius);
                var blockY1 = bm.GetBlockY(currentBox[Box.Bottom] - GameConst.MaxThingRadius);
                var blockY2 = bm.GetBlockY(currentBox[Box.Top] + GameConst.MaxThingRadius);

                for (var bx = blockX1; bx <= blockX2; bx++)
                {
                    for (var by = blockY1; by <= blockY2; by++)
                    {
                        if (!map.BlockMap.IterateThings(bx, by, checkThingFunc))
                        {
                            return(false);
                        }
                    }
                }
            }

            // Check lines.
            {
                var blockX1 = bm.GetBlockX(currentBox[Box.Left]);
                var blockX2 = bm.GetBlockX(currentBox[Box.Right]);
                var blockY1 = bm.GetBlockY(currentBox[Box.Bottom]);
                var blockY2 = bm.GetBlockY(currentBox[Box.Top]);

                for (var bx = blockX1; bx <= blockX2; bx++)
                {
                    for (var by = blockY1; by <= blockY2; by++)
                    {
                        if (!map.BlockMap.IterateLines(bx, by, checkLineFunc, validCount))
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }