コード例 #1
0
        public override void OnNeighborBlockChanged(int x, int y, int z, int neighborX, int neighborY, int neighborZ)
        {
            int    face      = LadderBlock.GetFace(Terrain.ExtractData(base.SubsystemTerrain.Terrain.GetCellValue(x, y, z)));
            Point3 point     = CellFace.FaceToPoint3(face);
            int    cellValue = base.SubsystemTerrain.Terrain.GetCellValue(x - point.X, y - point.Y, z - point.Z);
            int    num       = Terrain.ExtractContents(cellValue);

            if (BlocksManager.Blocks[num].IsFaceTransparent(base.SubsystemTerrain, face, cellValue))
            {
                base.SubsystemTerrain.DestroyCell(0, x, y, z, 0, noDrop: false, noParticleSystem: false);
            }
        }
コード例 #2
0
 public virtual void Update(float dt)
 {
     SlipSpeed = null;
     if (m_subsystemGameInfo.WorldSettings.GameMode != 0)
     {
         IsCreativeFlyEnabled = false;
     }
     StunTime = MathUtils.Max(StunTime - dt, 0f);
     if (m_componentCreature.ComponentHealth.Health > 0f && StunTime <= 0f)
     {
         Vector3     position    = m_componentCreature.ComponentBody.Position;
         PlayerStats playerStats = m_componentCreature.PlayerStats;
         if (playerStats != null)
         {
             float x = m_lastPosition.HasValue ? Vector3.Distance(position, m_lastPosition.Value) : 0f;
             x = MathUtils.Min(x, 25f * m_subsystemTime.PreviousGameTimeDelta);
             playerStats.DistanceTravelled += x;
             if (m_componentRider != null && m_componentRider.Mount != null)
             {
                 playerStats.DistanceRidden += x;
             }
             else
             {
                 if (m_walking)
                 {
                     playerStats.DistanceWalked += x;
                     m_walking = false;
                 }
                 if (m_falling)
                 {
                     playerStats.DistanceFallen += x;
                     m_falling = false;
                 }
                 if (m_climbing)
                 {
                     playerStats.DistanceClimbed += x;
                     m_climbing = false;
                 }
                 if (m_jumping)
                 {
                     playerStats.Jumps++;
                     m_jumping = false;
                 }
                 if (m_swimming)
                 {
                     playerStats.DistanceSwam += x;
                     m_swimming = false;
                 }
                 if (m_flying)
                 {
                     playerStats.DistanceFlown += x;
                     m_flying = false;
                 }
             }
             playerStats.DeepestDive     = MathUtils.Max(playerStats.DeepestDive, m_componentCreature.ComponentBody.ImmersionDepth);
             playerStats.LowestAltitude  = MathUtils.Min(playerStats.LowestAltitude, position.Y);
             playerStats.HighestAltitude = MathUtils.Max(playerStats.HighestAltitude, position.Y);
             playerStats.EasiestModeUsed = (GameMode)MathUtils.Min((int)m_subsystemGameInfo.WorldSettings.GameMode, (int)playerStats.EasiestModeUsed);
         }
         m_lastPosition       = position;
         m_swimBurstRemaining = MathUtils.Saturate(0.1f * m_swimBurstRemaining + dt);
         int   x2        = Terrain.ToCell(position.X);
         int   y         = Terrain.ToCell(position.Y + 0.2f);
         int   z         = Terrain.ToCell(position.Z);
         int   cellValue = m_subsystemTerrain.Terrain.GetCellValue(x2, y, z);
         int   num       = Terrain.ExtractContents(cellValue);
         Block block     = BlocksManager.Blocks[num];
         if (LadderSpeed > 0f && !LadderValue.HasValue && block is LadderBlock && m_subsystemTime.GameTime >= m_ladderActivationTime && !IsCreativeFlyEnabled && m_componentCreature.ComponentBody.ParentBody == null)
         {
             int face = LadderBlock.GetFace(Terrain.ExtractData(cellValue));
             if ((face == 0 && m_componentCreature.ComponentBody.CollisionVelocityChange.Z > 0f) || (face == 1 && m_componentCreature.ComponentBody.CollisionVelocityChange.X > 0f) || (face == 2 && m_componentCreature.ComponentBody.CollisionVelocityChange.Z < 0f) || (face == 3 && m_componentCreature.ComponentBody.CollisionVelocityChange.X < 0f) || !m_componentCreature.ComponentBody.StandingOnValue.HasValue)
             {
                 LadderValue            = cellValue;
                 m_ladderActivationTime = m_subsystemTime.GameTime + 0.20000000298023224;
                 m_componentCreature.ComponentCreatureSounds.PlayFootstepSound(1f);
             }
         }
         Quaternion rotation = m_componentCreature.ComponentBody.Rotation;
         float      num2     = MathUtils.Atan2(2f * rotation.Y * rotation.W - 2f * rotation.X * rotation.Z, 1f - 2f * rotation.Y * rotation.Y - 2f * rotation.Z * rotation.Z);
         num2 += (0f - TurnSpeed) * TurnOrder.X * dt;
         if (VrLookOrder.HasValue)
         {
             num2 += VrLookOrder.Value.X;
         }
         m_componentCreature.ComponentBody.Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitY, num2);
         LookAngles += LookSpeed * LookOrder * dt;
         if (VrLookOrder.HasValue)
         {
             LookAngles = new Vector2(LookAngles.X, VrLookOrder.Value.Y);
         }
         if (VrMoveOrder.HasValue)
         {
             m_componentCreature.ComponentBody.ApplyDirectMove(VrMoveOrder.Value);
         }
         if (LadderValue.HasValue)
         {
             LadderMovement(dt, cellValue);
         }
         else
         {
             NormalMovement(dt);
         }
     }
     else
     {
         m_componentCreature.ComponentBody.IsGravityEnabled    = true;
         m_componentCreature.ComponentBody.IsGroundDragEnabled = true;
         m_componentCreature.ComponentBody.IsWaterDragEnabled  = true;
     }
     LastWalkOrder = WalkOrder;
     LastFlyOrder  = FlyOrder;
     LastSwimOrder = SwimOrder;
     LastTurnOrder = TurnOrder;
     LastJumpOrder = JumpOrder;
     WalkOrder     = null;
     FlyOrder      = null;
     SwimOrder     = null;
     TurnOrder     = Vector2.Zero;
     JumpOrder     = 0f;
     VrMoveOrder   = null;
     VrLookOrder   = null;
     LookOrder     = new Vector2(m_lookAutoLevelX ? (-10f * LookAngles.X / LookSpeed) : 0f, m_lookAutoLevelY ? (-10f * LookAngles.Y / LookSpeed) : 0f);
 }
コード例 #3
0
        public static bool IsBlockMovable(int value, int pistonFace, int y, out bool isEnd)
        {
            isEnd = false;
            int num  = Terrain.ExtractContents(value);
            int data = Terrain.ExtractData(value);

            switch (num)
            {
            case 27:
            case 45:
            case 64:
            case 65:
            case 216:
                return(false);

            case 227:
                return(true);

            case 237:
                return(!PistonBlock.GetIsExtended(data));

            case 238:
                return(false);

            case 131:
            case 132:
            case 244:
                return(false);

            case 127:
                return(false);

            case 126:
                return(false);

            case 1:
                return(y > 1);

            default:
            {
                Block block = BlocksManager.Blocks[num];
                if (block is BottomSuckerBlock)
                {
                    return(false);
                }
                if (block is MountedElectricElementBlock)
                {
                    isEnd = true;
                    return(((MountedElectricElementBlock)block).GetFace(value) == pistonFace);
                }
                if (block is DoorBlock || block is TrapdoorBlock)
                {
                    return(false);
                }
                if (block is LadderBlock)
                {
                    isEnd = true;
                    return(pistonFace == LadderBlock.GetFace(data));
                }
                if (block is AttachedSignBlock)
                {
                    isEnd = true;
                    return(pistonFace == AttachedSignBlock.GetFace(data));
                }
                if (block.IsNonDuplicable)
                {
                    return(false);
                }
                if (block.IsCollidable)
                {
                    return(true);
                }
                return(false);
            }
            }
        }