public override void OnNewFrameFixed(Game game_, int entity, float dt) { game = game_; if (game.guistate == GuiState.MapLoading) { return; } movespeednow = game.MoveSpeedNow(); game.controls.movedx = MathCi.ClampFloat(game.controls.movedx, -1, 1); game.controls.movedy = MathCi.ClampFloat(game.controls.movedy, -1, 1); Controls move = game.controls; jumpstartacceleration = 13.333f * constGravity; // default jumpstartaccelerationhalf = 9 * constGravity; acceleration.SetDefault(); game.soundnow = new BoolRef(); if (game.FollowId() != null && game.FollowId().value == game.LocalPlayerId) { move.movedx = 0; move.movedy = 0; move.moveup = false; move.wantsjump = false; } Update(game.player.position, move, dt, game.soundnow, Vector3Ref.Create(game.pushX, game.pushY, game.pushZ), game.entities[game.LocalPlayerId].drawModel.ModelHeight); }
internal void UpdateGrenade(Game game, int grenadeEntityId, float dt) { float LocalPlayerPositionX = game.player.position.x; float LocalPlayerPositionY = game.player.position.y; float LocalPlayerPositionZ = game.player.position.z; Entity grenadeEntity = game.entities[grenadeEntityId]; Sprite grenadeSprite = grenadeEntity.sprite; Grenade_ grenade = grenadeEntity.grenade; float oldposX = grenadeEntity.sprite.positionX; float oldposY = grenadeSprite.positionY; float oldposZ = grenadeSprite.positionZ; float newposX = grenadeSprite.positionX + grenade.velocityX * dt; float newposY = grenadeSprite.positionY + grenade.velocityY * dt; float newposZ = grenadeSprite.positionZ + grenade.velocityZ * dt; grenade.velocityY += -projectilegravity * dt; Vector3Ref velocity = Vector3Ref.Create(grenade.velocityX, grenade.velocityY, grenade.velocityZ); Vector3Ref bouncePosition = GrenadeBounce(game, Vector3Ref.Create(oldposX, oldposY, oldposZ), Vector3Ref.Create(newposX, newposY, newposZ), velocity, dt); grenade.velocityX = velocity.X; grenade.velocityY = velocity.Y; grenade.velocityZ = velocity.Z; grenadeSprite.positionX = bouncePosition.X; grenadeSprite.positionY = bouncePosition.Y; grenadeSprite.positionZ = bouncePosition.Z; }
public static ModelData Get() { ModelData m = new ModelData(); m.setMode(DrawModeEnum.Lines); m.xyz = new float[3 * 4 * 6]; m.uv = new float[2 * 4 * 6]; m.rgba = new byte[4 * 4 * 6]; m.indices = new int[8 * 6]; DrawLineLoop(m, Vector3Ref.Create(-1, -1, -1), Vector3Ref.Create(-1, 1, -1), Vector3Ref.Create(1, 1, -1), Vector3Ref.Create(1, -1, -1) ); DrawLineLoop(m, Vector3Ref.Create(-1, -1, -1), Vector3Ref.Create(1, -1, -1), Vector3Ref.Create(1, -1, 1), Vector3Ref.Create(-1, -1, 1) ); DrawLineLoop(m, Vector3Ref.Create(-1, -1, -1), Vector3Ref.Create(-1, -1, 1), Vector3Ref.Create(-1, 1, 1), Vector3Ref.Create(-1, 1, -1) ); DrawLineLoop(m, Vector3Ref.Create(-1, -1, 1), Vector3Ref.Create(1, -1, 1), Vector3Ref.Create(1, 1, 1), Vector3Ref.Create(-1, 1, 1) ); DrawLineLoop(m, Vector3Ref.Create(-1, 1, -1), Vector3Ref.Create(-1, 1, 1), Vector3Ref.Create(1, 1, 1), Vector3Ref.Create(1, 1, -1) ); DrawLineLoop(m, Vector3Ref.Create(1, -1, -1), Vector3Ref.Create(1, 1, -1), Vector3Ref.Create(1, 1, 1), Vector3Ref.Create(1, -1, 1) ); return(m); }
internal float[] OverheadCamera(Game game) { game.overheadcameraK.GetPosition(game.platform, OverheadCamera_cameraEye); Vector3Ref cameraEye = OverheadCamera_cameraEye; Vector3Ref cameraTarget = Vector3Ref.Create(game.overheadcameraK.Center.X, game.overheadcameraK.Center.Y + game.GetCharacterEyesHeight(), game.overheadcameraK.Center.Z); FloatRef currentOverheadcameradistance = FloatRef.Create(game.overheadcameradistance); LimitThirdPersonCameraToWalls(game, cameraEye, cameraTarget, currentOverheadcameradistance); float[] ret = new float[16]; Mat4.LookAt(ret, Vec3.FromValues(cameraEye.X, cameraEye.Y, cameraEye.Z), Vec3.FromValues(cameraTarget.X, cameraTarget.Y, cameraTarget.Z), upVec3); game.CameraEyeX = cameraEye.X; game.CameraEyeY = cameraEye.Y; game.CameraEyeZ = cameraEye.Z; return(ret); }
internal Vector3Ref CurrentRailPos(Game game) { RailSlope slope = d_RailMapUtil.GetRailSlope(currentrailblockX, currentrailblockY, currentrailblockZ); float aX = currentrailblockX; float aY = currentrailblockY; float aZ = currentrailblockZ; float x_correction = 0; float y_correction = 0; float z_correction = 0; float half = one / 2; switch (currentdirection) { case VehicleDirection12.HorizontalRight: x_correction += currentrailblockprogress; y_correction += half; if (slope == RailSlope.TwoRightRaised) { z_correction += currentrailblockprogress; } if (slope == RailSlope.TwoLeftRaised) { z_correction += 1 - currentrailblockprogress; } break; case VehicleDirection12.HorizontalLeft: x_correction += 1 - currentrailblockprogress; y_correction += half; if (slope == RailSlope.TwoRightRaised) { z_correction += 1 - currentrailblockprogress; } if (slope == RailSlope.TwoLeftRaised) { z_correction += currentrailblockprogress; } break; case VehicleDirection12.VerticalDown: x_correction += half; y_correction += currentrailblockprogress; if (slope == RailSlope.TwoDownRaised) { z_correction += currentrailblockprogress; } if (slope == RailSlope.TwoUpRaised) { z_correction += 1 - currentrailblockprogress; } break; case VehicleDirection12.VerticalUp: x_correction += half; y_correction += 1 - currentrailblockprogress; if (slope == RailSlope.TwoDownRaised) { z_correction += 1 - currentrailblockprogress; } if (slope == RailSlope.TwoUpRaised) { z_correction += currentrailblockprogress; } break; case VehicleDirection12.UpLeftLeft: x_correction += half * (1 - currentrailblockprogress); y_correction += half * currentrailblockprogress; break; case VehicleDirection12.UpLeftUp: x_correction += half * currentrailblockprogress; y_correction += half - half * currentrailblockprogress; break; case VehicleDirection12.UpRightRight: x_correction += half + half * currentrailblockprogress; y_correction += half * currentrailblockprogress; break; case VehicleDirection12.UpRightUp: x_correction += 1 - half * currentrailblockprogress; y_correction += half - half * currentrailblockprogress; break; case VehicleDirection12.DownLeftLeft: x_correction += half * (1 - currentrailblockprogress); y_correction += 1 - half * currentrailblockprogress; break; case VehicleDirection12.DownLeftDown: x_correction += half * currentrailblockprogress; y_correction += half + half * currentrailblockprogress; break; case VehicleDirection12.DownRightRight: x_correction += half + half * currentrailblockprogress; y_correction += 1 - half * currentrailblockprogress; break; case VehicleDirection12.DownRightDown: x_correction += 1 - half * currentrailblockprogress; y_correction += half + half * currentrailblockprogress; break; } //+1 because player can't be inside rail block (picking wouldn't work) return(Vector3Ref.Create(aX + x_correction, aZ + railheight + 1 + z_correction, aY + y_correction)); }
public void Update(EntityPosition_ stateplayerposition, Controls move, float dt, BoolRef soundnow, Vector3Ref push, float modelheight) { if (game.stopPlayerMove) { movedz = 0; game.stopPlayerMove = false; } // No air control if (!isplayeronground) { acceleration.acceleration1 = 0.99f; acceleration.acceleration2 = 0.2f; acceleration.acceleration3 = 70; } // Trampoline { int blockunderplayer = game.BlockUnderPlayer(); if (blockunderplayer != -1 && blockunderplayer == game.d_Data.BlockIdTrampoline() && (!isplayeronground) && !game.controls.shiftkeydown) { game.controls.wantsjump = true; jumpstartacceleration = 20.666f * constGravity; } } // Slippery walk on ice and when swimming { int blockunderplayer = game.BlockUnderPlayer(); if ((blockunderplayer != -1 && game.d_Data.IsSlipperyWalk()[blockunderplayer]) || game.SwimmingBody()) { acceleration.acceleration1 = 0.99f; acceleration.acceleration2 = 0.2f; acceleration.acceleration3 = 70; } } soundnow.value = false; Vector3Ref diff1ref = new Vector3Ref(); VectorTool.ToVectorInFixedSystem (move.movedx * movespeednow * dt, 0, move.movedy * movespeednow * dt, stateplayerposition.rotx, stateplayerposition.roty, diff1ref); Vector3Ref diff1 = new Vector3Ref(); diff1.X = diff1ref.X; diff1.Y = diff1ref.Y; diff1.Z = diff1ref.Z; if (MiscCi.Vec3Length(push.X, push.Y, push.Z) > 0.01f) { push.Normalize(); push.X *= 5; push.Y *= 5; push.Z *= 5; } diff1.X += push.X * dt; diff1.Y += push.Y * dt; diff1.Z += push.Z * dt; bool loaded = false; int cx = game.platform.FloatToInt(game.player.position.x / Game.chunksize); int cy = game.platform.FloatToInt(game.player.position.z / Game.chunksize); int cz = game.platform.FloatToInt(game.player.position.y / Game.chunksize); if (game.map.IsValidChunkPos(cx, cy, cz)) { if (game.map.chunks[MapUtilCi.Index3d(cx, cy, cz, game.map.MapSizeX / Game.chunksize, game.map.MapSizeY / Game.chunksize)] != null) { loaded = true; } } else { loaded = true; } if ((!(move.freemove)) && loaded) { if (!game.SwimmingBody()) { movedz += -constGravity;//gravity } else { movedz += -constGravity * constWaterGravityMultiplier; //more gravity because it's slippery. } } game.movedz = movedz; if (constEnableAcceleration) { curspeed.X *= acceleration.acceleration1; curspeed.Y *= acceleration.acceleration1; curspeed.Z *= acceleration.acceleration1; curspeed.X = MakeCloserToZero(curspeed.X, acceleration.acceleration2 * dt); curspeed.Y = MakeCloserToZero(curspeed.Y, acceleration.acceleration2 * dt); curspeed.Z = MakeCloserToZero(curspeed.Z, acceleration.acceleration2 * dt); diff1.Y += move.moveup ? 2 * movespeednow * dt : 0; diff1.Y -= move.movedown ? 2 * movespeednow * dt : 0; curspeed.X += diff1.X * acceleration.acceleration3 * dt; curspeed.Y += diff1.Y * acceleration.acceleration3 * dt; curspeed.Z += diff1.Z * acceleration.acceleration3 * dt; if (curspeed.Length() > movespeednow) { curspeed.Normalize(); curspeed.X *= movespeednow; curspeed.Y *= movespeednow; curspeed.Z *= movespeednow; } } else { if (MiscCi.Vec3Length(diff1.X, diff1.Y, diff1.Z) > 0) { diff1.Normalize(); } curspeed.X = diff1.X * movespeednow; curspeed.Y = diff1.Y * movespeednow; curspeed.Z = diff1.Z * movespeednow; } Vector3Ref newposition = Vector3Ref.Create(0, 0, 0); if (!(move.freemove)) { newposition.X = stateplayerposition.x + curspeed.X; newposition.Y = stateplayerposition.y + curspeed.Y; newposition.Z = stateplayerposition.z + curspeed.Z; if (!game.SwimmingBody()) { newposition.Y = stateplayerposition.y; } // Fast move when looking at the ground float diffx = newposition.X - stateplayerposition.x; float diffy = newposition.Y - stateplayerposition.y; float diffz = newposition.Z - stateplayerposition.z; float difflength = MiscCi.Vec3Length(diffx, diffy, diffz); if (difflength > 0) { diffx /= difflength; diffy /= difflength; diffz /= difflength; diffx *= curspeed.Length(); diffy *= curspeed.Length(); diffz *= curspeed.Length(); } newposition.X = stateplayerposition.x + diffx * dt; newposition.Y = stateplayerposition.y + diffy * dt; newposition.Z = stateplayerposition.z + diffz * dt; } else { newposition.X = stateplayerposition.x + (curspeed.X) * dt; newposition.Y = stateplayerposition.y + (curspeed.Y) * dt; newposition.Z = stateplayerposition.z + (curspeed.Z) * dt; } newposition.Y += movedz * dt; Vector3Ref previousposition = Vector3Ref.Create(stateplayerposition.x, stateplayerposition.y, stateplayerposition.z); if (!move.noclip) { float[] v = WallSlide( Vec3.FromValues(stateplayerposition.x, stateplayerposition.y, stateplayerposition.z), Vec3.FromValues(newposition.X, newposition.Y, newposition.Z), modelheight); stateplayerposition.x = v[0]; stateplayerposition.y = v[1]; stateplayerposition.z = v[2]; } else { stateplayerposition.x = newposition.X; stateplayerposition.y = newposition.Y; stateplayerposition.z = newposition.Z; } if (!(move.freemove)) { if ((isplayeronground) || game.SwimmingBody()) { jumpacceleration = 0; movedz = 0; } if ((move.wantsjump || move.wantsjumphalf) && (((jumpacceleration == 0 && isplayeronground) || game.SwimmingBody()) && loaded) && (!game.SwimmingEyes())) { jumpacceleration = move.wantsjumphalf ? jumpstartaccelerationhalf : jumpstartacceleration; soundnow.value = true; } if (jumpacceleration > 0) { isplayeronground = false; jumpacceleration = jumpacceleration / 2; } //if (!this.reachedceiling) { movedz += jumpacceleration * constJump; } } else { isplayeronground = true; } game.isplayeronground = isplayeronground; }
public void AddTorch(GameData d_Data, Game d_TerainRenderer, ModelData m, int x, int y, int z, TorchType type) { float one = 1; int curcolor = Game.ColorFromArgb(255, 255, 255, 255); float torchsizexy = one * 16 / 100; float topx = one / 2 - torchsizexy / 2; float topy = one / 2 - torchsizexy / 2; float bottomx = one / 2 - torchsizexy / 2; float bottomy = one / 2 - torchsizexy / 2; topx += x; topy += y; bottomx += x; bottomy += y; if (type == TorchType.Front) { bottomx = x - torchsizexy; } if (type == TorchType.Back) { bottomx = x + 1; } if (type == TorchType.Left) { bottomy = y - torchsizexy; } if (type == TorchType.Right) { bottomy = y + 1; } Vector3Ref top00 = Vector3Ref.Create(topx, z + (one * 9 / 10), topy); Vector3Ref top01 = Vector3Ref.Create(topx, z + (one * 9 / 10), topy + torchsizexy); Vector3Ref top10 = Vector3Ref.Create(topx + torchsizexy, z + (one * 9 / 10), topy); Vector3Ref top11 = Vector3Ref.Create(topx + torchsizexy, z + (one * 9 / 10), topy + torchsizexy); if (type == TorchType.Left) { top01.Y += -(one * 1 / 10); top11.Y += -(one * 1 / 10); } if (type == TorchType.Right) { top10.Y += -(one * 1 / 10); top00.Y += -(one * 1 / 10); } if (type == TorchType.Front) { top10.Y += -(one * 1 / 10); top11.Y += -(one * 1 / 10); } if (type == TorchType.Back) { top01.Y += -(one * 1 / 10); top00.Y += -(one * 1 / 10); } Vector3Ref bottom00 = Vector3Ref.Create(bottomx, z + 0, bottomy); Vector3Ref bottom01 = Vector3Ref.Create(bottomx, z + 0, bottomy + torchsizexy); Vector3Ref bottom10 = Vector3Ref.Create(bottomx + torchsizexy, z + 0, bottomy); Vector3Ref bottom11 = Vector3Ref.Create(bottomx + torchsizexy, z + 0, bottomy + torchsizexy); //top { int sidetexture = TopTexture; RectFRef texrec = TextureAtlas.TextureCoords2d(sidetexture, d_TerainRenderer.texturesPacked()); int lastelement = m.GetVerticesCount(); AddVertex(m, top00.X, top00.Y, top00.Z, texrec.Left(), texrec.Top(), curcolor); AddVertex(m, top01.X, top01.Y, top01.Z, texrec.Left(), texrec.Bottom(), curcolor); AddVertex(m, top10.X, top10.Y, top10.Z, texrec.Right(), texrec.Top(), curcolor); AddVertex(m, top11.X, top11.Y, top11.Z, texrec.Right(), texrec.Bottom(), curcolor); m.indices[m.indicesCount++] = (lastelement + 0); m.indices[m.indicesCount++] = (lastelement + 1); m.indices[m.indicesCount++] = (lastelement + 2); m.indices[m.indicesCount++] = (lastelement + 1); m.indices[m.indicesCount++] = (lastelement + 3); m.indices[m.indicesCount++] = (lastelement + 2); } //bottom - same as top, but z is 1 less. { int sidetexture = SideTexture; RectFRef texrec = TextureAtlas.TextureCoords2d(sidetexture, d_TerainRenderer.texturesPacked()); int lastelement = m.GetVerticesCount(); AddVertex(m, bottom00.X, bottom00.Y, bottom00.Z, texrec.Left(), texrec.Top(), curcolor); AddVertex(m, bottom01.X, bottom01.Y, bottom01.Z, texrec.Left(), texrec.Bottom(), curcolor); AddVertex(m, bottom10.X, bottom10.Y, bottom10.Z, texrec.Right(), texrec.Top(), curcolor); AddVertex(m, bottom11.X, bottom11.Y, bottom11.Z, texrec.Right(), texrec.Bottom(), curcolor); m.indices[m.indicesCount++] = (lastelement + 1); m.indices[m.indicesCount++] = (lastelement + 0); m.indices[m.indicesCount++] = (lastelement + 2); m.indices[m.indicesCount++] = (lastelement + 3); m.indices[m.indicesCount++] = (lastelement + 1); m.indices[m.indicesCount++] = (lastelement + 2); } //front { int sidetexture = SideTexture; RectFRef texrec = TextureAtlas.TextureCoords2d(sidetexture, d_TerainRenderer.texturesPacked()); int lastelement = m.GetVerticesCount(); AddVertex(m, bottom00.X, bottom00.Y, bottom00.Z, texrec.Left(), texrec.Bottom(), curcolor); AddVertex(m, bottom01.X, bottom01.Y, bottom01.Z, texrec.Right(), texrec.Bottom(), curcolor); AddVertex(m, top00.X, top00.Y, top00.Z, texrec.Left(), texrec.Top(), curcolor); AddVertex(m, top01.X, top01.Y, top01.Z, texrec.Right(), texrec.Top(), curcolor); m.indices[m.indicesCount++] = (lastelement + 0); m.indices[m.indicesCount++] = (lastelement + 1); m.indices[m.indicesCount++] = (lastelement + 2); m.indices[m.indicesCount++] = (lastelement + 1); m.indices[m.indicesCount++] = (lastelement + 3); m.indices[m.indicesCount++] = (lastelement + 2); } //back - same as front, but x is 1 greater. { int sidetexture = SideTexture; RectFRef texrec = TextureAtlas.TextureCoords2d(sidetexture, d_TerainRenderer.texturesPacked()); int lastelement = m.GetVerticesCount(); AddVertex(m, bottom10.X, bottom10.Y, bottom10.Z, texrec.Right(), texrec.Bottom(), curcolor); AddVertex(m, bottom11.X, bottom11.Y, bottom11.Z, texrec.Left(), texrec.Bottom(), curcolor); AddVertex(m, top10.X, top10.Y, top10.Z, texrec.Right(), texrec.Top(), curcolor); AddVertex(m, top11.X, top11.Y, top11.Z, texrec.Left(), texrec.Top(), curcolor); m.indices[m.indicesCount++] = (lastelement + 1); m.indices[m.indicesCount++] = (lastelement + 0); m.indices[m.indicesCount++] = (lastelement + 2); m.indices[m.indicesCount++] = (lastelement + 3); m.indices[m.indicesCount++] = (lastelement + 1); m.indices[m.indicesCount++] = (lastelement + 2); } { int sidetexture = SideTexture; RectFRef texrec = TextureAtlas.TextureCoords2d(sidetexture, d_TerainRenderer.texturesPacked()); int lastelement = m.GetVerticesCount(); AddVertex(m, bottom00.X, bottom00.Y, bottom00.Z, texrec.Right(), texrec.Bottom(), curcolor); AddVertex(m, top00.X, top00.Y, top00.Z, texrec.Right(), texrec.Top(), curcolor); AddVertex(m, bottom10.X, bottom10.Y, bottom10.Z, texrec.Left(), texrec.Bottom(), curcolor); AddVertex(m, top10.X, top10.Y, top10.Z, texrec.Left(), texrec.Top(), curcolor); m.indices[m.indicesCount++] = (lastelement + 0); m.indices[m.indicesCount++] = (lastelement + 1); m.indices[m.indicesCount++] = (lastelement + 2); m.indices[m.indicesCount++] = (lastelement + 1); m.indices[m.indicesCount++] = (lastelement + 3); m.indices[m.indicesCount++] = (lastelement + 2); } //right - same as left, but y is 1 greater. { int sidetexture = SideTexture; RectFRef texrec = TextureAtlas.TextureCoords2d(sidetexture, d_TerainRenderer.texturesPacked()); int lastelement = m.GetVerticesCount(); AddVertex(m, bottom01.X, bottom01.Y, bottom01.Z, texrec.Left(), texrec.Bottom(), curcolor); AddVertex(m, top01.X, top01.Y, top01.Z, texrec.Left(), texrec.Top(), curcolor); AddVertex(m, bottom11.X, bottom11.Y, bottom11.Z, texrec.Right(), texrec.Bottom(), curcolor); AddVertex(m, top11.X, top11.Y, top11.Z, texrec.Right(), texrec.Top(), curcolor); m.indices[m.indicesCount++] = (lastelement + 1); m.indices[m.indicesCount++] = (lastelement + 0); m.indices[m.indicesCount++] = (lastelement + 2); m.indices[m.indicesCount++] = (lastelement + 3); m.indices[m.indicesCount++] = (lastelement + 1); m.indices[m.indicesCount++] = (lastelement + 2); } }
internal void NextBullet(Game game, int bulletsshot) { float one = 1; bool left = game.mouseLeft; bool middle = game.mouseMiddle; bool right = game.mouseRight; bool IsNextShot = bulletsshot != 0; if (!game.leftpressedpicking) { if (game.mouseleftclick) { game.leftpressedpicking = true; } else { left = false; } } else { if (game.mouseleftdeclick) { game.leftpressedpicking = false; left = false; } } if (!left) { game.currentAttackedBlock = null; } Packet_Item item = game.d_Inventory.RightHand[game.ActiveMaterial]; bool ispistol = (item != null && game.blocktypes[item.BlockId].IsPistol); bool ispistolshoot = ispistol && left; bool isgrenade = ispistol && game.blocktypes[item.BlockId].PistolType == Packet_PistolTypeEnum.Grenade; if (ispistol && isgrenade) { ispistolshoot = game.mouseleftdeclick; } //grenade cooking - TODO: fix instant explosion when closing ESC menu if (game.mouseleftclick) { game.grenadecookingstartMilliseconds = game.platform.TimeMillisecondsFromStart(); if (ispistol && isgrenade) { if (game.blocktypes[item.BlockId].Sounds.ShootCount > 0) { game.AudioPlay(game.platform.StringFormat("{0}.ogg", game.blocktypes[item.BlockId].Sounds.Shoot[0])); } } } float wait = ((one * (game.platform.TimeMillisecondsFromStart() - game.grenadecookingstartMilliseconds)) / 1000); if (isgrenade && left) { if (wait >= game.grenadetime && isgrenade && game.grenadecookingstartMilliseconds != 0) { ispistolshoot = true; game.mouseleftdeclick = true; } else { return; } } else { game.grenadecookingstartMilliseconds = 0; } if (ispistol && game.mouserightclick && (game.platform.TimeMillisecondsFromStart() - game.lastironsightschangeMilliseconds) >= 500) { game.IronSights = !game.IronSights; game.lastironsightschangeMilliseconds = game.platform.TimeMillisecondsFromStart(); } IntRef pick2count = new IntRef(); Line3D pick = new Line3D(); GetPickingLine(game, pick, ispistolshoot); BlockPosSide[] pick2 = game.Pick(game.s, pick, pick2count); if (left) { game.handSetAttackDestroy = true; } else if (right) { game.handSetAttackBuild = true; } if (game.overheadcamera && pick2count.value > 0 && left) { //if not picked any object, and mouse button is pressed, then walk to destination. if (game.Follow == null) { //Only walk to destination when not following someone game.playerdestination = Vector3Ref.Create(pick2[0].blockPos[0], pick2[0].blockPos[1] + 1, pick2[0].blockPos[2]); } } bool pickdistanceok = (pick2count.value > 0); //&& (!ispistol); if (pickdistanceok) { if (game.Dist(pick2[0].blockPos[0] + one / 2, pick2[0].blockPos[1] + one / 2, pick2[0].blockPos[2] + one / 2, pick.Start[0], pick.Start[1], pick.Start[2]) > CurrentPickDistance(game)) { pickdistanceok = false; } } bool playertileempty = game.IsTileEmptyForPhysics( game.platform.FloatToInt(game.player.position.x), game.platform.FloatToInt(game.player.position.z), game.platform.FloatToInt(game.player.position.y + (one / 2))); bool playertileemptyclose = game.IsTileEmptyForPhysicsClose( game.platform.FloatToInt(game.player.position.x), game.platform.FloatToInt(game.player.position.z), game.platform.FloatToInt(game.player.position.y + (one / 2))); BlockPosSide pick0 = new BlockPosSide(); if (pick2count.value > 0 && ((pickdistanceok && (playertileempty || (playertileemptyclose))) || game.overheadcamera) ) { game.SelectedBlockPositionX = game.platform.FloatToInt(pick2[0].Current()[0]); game.SelectedBlockPositionY = game.platform.FloatToInt(pick2[0].Current()[1]); game.SelectedBlockPositionZ = game.platform.FloatToInt(pick2[0].Current()[2]); pick0 = pick2[0]; } else { game.SelectedBlockPositionX = -1; game.SelectedBlockPositionY = -1; game.SelectedBlockPositionZ = -1; pick0.blockPos = new float[3]; pick0.blockPos[0] = -1; pick0.blockPos[1] = -1; pick0.blockPos[2] = -1; } PickEntity(game, pick, pick2, pick2count); if (game.cameratype == CameraType.Fpp || game.cameratype == CameraType.Tpp) { int ntileX = game.platform.FloatToInt(pick0.Current()[0]); int ntileY = game.platform.FloatToInt(pick0.Current()[1]); int ntileZ = game.platform.FloatToInt(pick0.Current()[2]); if (game.IsUsableBlock(game.map.GetBlock(ntileX, ntileZ, ntileY))) { game.currentAttackedBlock = Vector3IntRef.Create(ntileX, ntileZ, ntileY); } } if (game.GetFreeMouse()) { if (pick2count.value > 0) { OnPick_(pick0); } return; } if ((one * (game.platform.TimeMillisecondsFromStart() - lastbuildMilliseconds) / 1000) >= BuildDelay(game) || IsNextShot) { if (left && game.d_Inventory.RightHand[game.ActiveMaterial] == null) { game.SendPacketClient(ClientPackets.MonsterHit(game.platform.FloatToInt(2 + game.rnd.NextFloat() * 4))); } if (left && !fastclicking) { //todo animation fastclicking = false; } if ((left || right || middle) && (!isgrenade)) { lastbuildMilliseconds = game.platform.TimeMillisecondsFromStart(); } if (isgrenade && game.mouseleftdeclick) { lastbuildMilliseconds = game.platform.TimeMillisecondsFromStart(); } if (game.reloadstartMilliseconds != 0) { PickingEnd(left, right, middle, ispistol); return; } if (ispistolshoot) { if ((!(game.LoadedAmmo[item.BlockId] > 0)) || (!(game.TotalAmmo[item.BlockId] > 0))) { game.AudioPlay("Dry Fire Gun-SoundBible.com-2053652037.ogg"); PickingEnd(left, right, middle, ispistol); return; } } if (ispistolshoot) { float toX = pick.End[0]; float toY = pick.End[1]; float toZ = pick.End[2]; if (pick2count.value > 0) { toX = pick2[0].blockPos[0]; toY = pick2[0].blockPos[1]; toZ = pick2[0].blockPos[2]; } Packet_ClientShot shot = new Packet_ClientShot(); shot.FromX = game.SerializeFloat(pick.Start[0]); shot.FromY = game.SerializeFloat(pick.Start[1]); shot.FromZ = game.SerializeFloat(pick.Start[2]); shot.ToX = game.SerializeFloat(toX); shot.ToY = game.SerializeFloat(toY); shot.ToZ = game.SerializeFloat(toZ); shot.HitPlayer = -1; for (int i = 0; i < game.entitiesCount; i++) { if (game.entities[i] == null) { continue; } if (game.entities[i].drawModel == null) { continue; } Entity p_ = game.entities[i]; if (p_.networkPosition == null) { continue; } if (!p_.networkPosition.PositionLoaded) { continue; } float feetposX = p_.position.x; float feetposY = p_.position.y; float feetposZ = p_.position.z; //var p = PlayerPositionSpawn; Box3D bodybox = new Box3D(); float headsize = (p_.drawModel.ModelHeight - p_.drawModel.eyeHeight) * 2; //0.4f; float h = p_.drawModel.ModelHeight - headsize; float r = one * 35 / 100; bodybox.AddPoint(feetposX - r, feetposY + 0, feetposZ - r); bodybox.AddPoint(feetposX - r, feetposY + 0, feetposZ + r); bodybox.AddPoint(feetposX + r, feetposY + 0, feetposZ - r); bodybox.AddPoint(feetposX + r, feetposY + 0, feetposZ + r); bodybox.AddPoint(feetposX - r, feetposY + h, feetposZ - r); bodybox.AddPoint(feetposX - r, feetposY + h, feetposZ + r); bodybox.AddPoint(feetposX + r, feetposY + h, feetposZ - r); bodybox.AddPoint(feetposX + r, feetposY + h, feetposZ + r); Box3D headbox = new Box3D(); headbox.AddPoint(feetposX - r, feetposY + h, feetposZ - r); headbox.AddPoint(feetposX - r, feetposY + h, feetposZ + r); headbox.AddPoint(feetposX + r, feetposY + h, feetposZ - r); headbox.AddPoint(feetposX + r, feetposY + h, feetposZ + r); headbox.AddPoint(feetposX - r, feetposY + h + headsize, feetposZ - r); headbox.AddPoint(feetposX - r, feetposY + h + headsize, feetposZ + r); headbox.AddPoint(feetposX + r, feetposY + h + headsize, feetposZ - r); headbox.AddPoint(feetposX + r, feetposY + h + headsize, feetposZ + r); float[] p; float localeyeposX = game.EyesPosX(); float localeyeposY = game.EyesPosY(); float localeyeposZ = game.EyesPosZ(); p = Intersection.CheckLineBoxExact(pick, headbox); if (p != null) { //do not allow to shoot through terrain if (pick2count.value == 0 || (game.Dist(pick2[0].blockPos[0], pick2[0].blockPos[1], pick2[0].blockPos[2], localeyeposX, localeyeposY, localeyeposZ) > game.Dist(p[0], p[1], p[2], localeyeposX, localeyeposY, localeyeposZ))) { if (!isgrenade) { Entity entity = new Entity(); Sprite sprite = new Sprite(); sprite.positionX = p[0]; sprite.positionY = p[1]; sprite.positionZ = p[2]; sprite.image = "blood.png"; entity.sprite = sprite; entity.expires = Expires.Create(one * 2 / 10); game.EntityAddLocal(entity); } shot.HitPlayer = i; shot.IsHitHead = 1; } } else { p = Intersection.CheckLineBoxExact(pick, bodybox); if (p != null) { //do not allow to shoot through terrain if (pick2count.value == 0 || (game.Dist(pick2[0].blockPos[0], pick2[0].blockPos[1], pick2[0].blockPos[2], localeyeposX, localeyeposY, localeyeposZ) > game.Dist(p[0], p[1], p[2], localeyeposX, localeyeposY, localeyeposZ))) { if (!isgrenade) { Entity entity = new Entity(); Sprite sprite = new Sprite(); sprite.positionX = p[0]; sprite.positionY = p[1]; sprite.positionZ = p[2]; sprite.image = "blood.png"; entity.sprite = sprite; entity.expires = Expires.Create(one * 2 / 10); game.EntityAddLocal(entity); } shot.HitPlayer = i; shot.IsHitHead = 0; } } } } shot.WeaponBlock = item.BlockId; game.LoadedAmmo[item.BlockId] = game.LoadedAmmo[item.BlockId] - 1; game.TotalAmmo[item.BlockId] = game.TotalAmmo[item.BlockId] - 1; float projectilespeed = game.DeserializeFloat(game.blocktypes[item.BlockId].ProjectileSpeedFloat); if (projectilespeed == 0) { { Entity entity = game.CreateBulletEntity( pick.Start[0], pick.Start[1], pick.Start[2], toX, toY, toZ, 150); game.EntityAddLocal(entity); } } else { float vX = toX - pick.Start[0]; float vY = toY - pick.Start[1]; float vZ = toZ - pick.Start[2]; float vLength = game.Length(vX, vY, vZ); vX /= vLength; vY /= vLength; vZ /= vLength; vX *= projectilespeed; vY *= projectilespeed; vZ *= projectilespeed; shot.ExplodesAfter = game.SerializeFloat(game.grenadetime - wait); { Entity grenadeEntity = new Entity(); Sprite sprite = new Sprite(); sprite.image = "ChemicalGreen.png"; sprite.size = 14; sprite.animationcount = 0; sprite.positionX = pick.Start[0]; sprite.positionY = pick.Start[1]; sprite.positionZ = pick.Start[2]; grenadeEntity.sprite = sprite; Grenade_ projectile = new Grenade_(); projectile.velocityX = vX; projectile.velocityY = vY; projectile.velocityZ = vZ; projectile.block = item.BlockId; projectile.sourcePlayer = game.LocalPlayerId; grenadeEntity.expires = Expires.Create(game.grenadetime - wait); grenadeEntity.grenade = projectile; game.EntityAddLocal(grenadeEntity); } } Packet_Client packet = new Packet_Client(); packet.Id = Packet_ClientIdEnum.Shot; packet.Shot = shot; game.SendPacketClient(packet); if (game.blocktypes[item.BlockId].Sounds.ShootEndCount > 0) { game.pistolcycle = game.rnd.Next() % game.blocktypes[item.BlockId].Sounds.ShootEndCount; game.AudioPlay(game.platform.StringFormat("{0}.ogg", game.blocktypes[item.BlockId].Sounds.ShootEnd[game.pistolcycle])); } bulletsshot++; if (bulletsshot < game.DeserializeFloat(game.blocktypes[item.BlockId].BulletsPerShotFloat)) { NextBullet(game, bulletsshot); } //recoil game.player.position.rotx -= game.rnd.NextFloat() * game.CurrentRecoil(); game.player.position.roty += game.rnd.NextFloat() * game.CurrentRecoil() * 2 - game.CurrentRecoil(); PickingEnd(left, right, middle, ispistol); return; } if (ispistol && right) { PickingEnd(left, right, middle, ispistol); return; } if (pick2count.value > 0) { if (middle) { int newtileX = game.platform.FloatToInt(pick0.Current()[0]); int newtileY = game.platform.FloatToInt(pick0.Current()[1]); int newtileZ = game.platform.FloatToInt(pick0.Current()[2]); if (game.map.IsValidPos(newtileX, newtileZ, newtileY)) { int clonesource = game.map.GetBlock(newtileX, newtileZ, newtileY); int clonesource2 = game.d_Data.WhenPlayerPlacesGetsConvertedTo()[clonesource]; bool gotoDone = false; //find this block in another right hand. for (int i = 0; i < 10; i++) { if (game.d_Inventory.RightHand[i] != null && game.d_Inventory.RightHand[i].ItemClass == Packet_ItemClassEnum.Block && game.d_Inventory.RightHand[i].BlockId == clonesource2) { game.ActiveMaterial = i; gotoDone = true; } } if (!gotoDone) { IntRef freehand = game.d_InventoryUtil.FreeHand(game.ActiveMaterial); //find this block in inventory. for (int i = 0; i < game.d_Inventory.ItemsCount; i++) { Packet_PositionItem k = game.d_Inventory.Items[i]; if (k == null) { continue; } if (k.Value_.ItemClass == Packet_ItemClassEnum.Block && k.Value_.BlockId == clonesource2) { //free hand if (freehand != null) { game.WearItem( game.InventoryPositionMainArea(k.X, k.Y), game.InventoryPositionMaterialSelector(freehand.value)); break; } //try to replace current slot if (game.d_Inventory.RightHand[game.ActiveMaterial] != null && game.d_Inventory.RightHand[game.ActiveMaterial].ItemClass == Packet_ItemClassEnum.Block) { game.MoveToInventory( game.InventoryPositionMaterialSelector(game.ActiveMaterial)); game.WearItem( game.InventoryPositionMainArea(k.X, k.Y), game.InventoryPositionMaterialSelector(game.ActiveMaterial)); } } } } string[] sound = game.d_Data.CloneSound()[clonesource]; if (sound != null) // && sound.Length > 0) { game.AudioPlay(sound[0]); //todo sound cycle } } } if (left || right) { BlockPosSide tile = pick0; int newtileX; int newtileY; int newtileZ; if (right) { newtileX = game.platform.FloatToInt(tile.Translated()[0]); newtileY = game.platform.FloatToInt(tile.Translated()[1]); newtileZ = game.platform.FloatToInt(tile.Translated()[2]); } else { newtileX = game.platform.FloatToInt(tile.Current()[0]); newtileY = game.platform.FloatToInt(tile.Current()[1]); newtileZ = game.platform.FloatToInt(tile.Current()[2]); } if (game.map.IsValidPos(newtileX, newtileZ, newtileY)) { //Console.WriteLine(". newtile:" + newtile + " type: " + d_Map.GetBlock(newtileX, newtileZ, newtileY)); if (!(pick0.blockPos[0] == -1 && pick0.blockPos[1] == -1 && pick0.blockPos[2] == -1)) { int blocktype; if (left) { blocktype = game.map.GetBlock(newtileX, newtileZ, newtileY); } else { blocktype = ((game.BlockInHand() == null) ? 1 : game.BlockInHand().value); } if (left && blocktype == game.d_Data.BlockIdAdminium()) { PickingEnd(left, right, middle, ispistol); return; } string[] sound = left ? game.d_Data.BreakSound()[blocktype] : game.d_Data.BuildSound()[blocktype]; if (sound != null) // && sound.Length > 0) { game.AudioPlay(sound[0]); //todo sound cycle } } //normal attack if (!right) { //attack int posx = newtileX; int posy = newtileZ; int posz = newtileY; game.currentAttackedBlock = Vector3IntRef.Create(posx, posy, posz); if (!game.blockHealth.ContainsKey(posx, posy, posz)) { game.blockHealth.Set(posx, posy, posz, game.GetCurrentBlockHealth(posx, posy, posz)); } game.blockHealth.Set(posx, posy, posz, game.blockHealth.Get(posx, posy, posz) - game.WeaponAttackStrength()); float health = game.GetCurrentBlockHealth(posx, posy, posz); if (health <= 0) { if (game.currentAttackedBlock != null) { game.blockHealth.Remove(posx, posy, posz); } game.currentAttackedBlock = null; OnPick(game, game.platform.FloatToInt(newtileX), game.platform.FloatToInt(newtileZ), game.platform.FloatToInt(newtileY), game.platform.FloatToInt(tile.Current()[0]), game.platform.FloatToInt(tile.Current()[2]), game.platform.FloatToInt(tile.Current()[1]), tile.collisionPos, right); } PickingEnd(left, right, middle, ispistol); return; } if (!right) { game.particleEffectBlockBreak.StartParticleEffect(newtileX, newtileY, newtileZ);//must be before deletion - gets ground type. } if (!game.map.IsValidPos(newtileX, newtileZ, newtileY)) { game.platform.ThrowException("Error in picking - NextBullet()"); } OnPick(game, game.platform.FloatToInt(newtileX), game.platform.FloatToInt(newtileZ), game.platform.FloatToInt(newtileY), game.platform.FloatToInt(tile.Current()[0]), game.platform.FloatToInt(tile.Current()[2]), game.platform.FloatToInt(tile.Current()[1]), tile.collisionPos, right); //network.SendSetBlock(new Vector3((int)newtile.X, (int)newtile.Z, (int)newtile.Y), // right ? BlockSetMode.Create : BlockSetMode.Destroy, (byte)MaterialSlots[activematerial]); } } } } PickingEnd(left, right, middle, ispistol); }
internal Vector3Ref GrenadeBounce(Game game, Vector3Ref oldposition, Vector3Ref newposition, Vector3Ref velocity, float dt) { bool ismoving = velocity.Length() > 100 * dt; float modelheight = walldistance; oldposition.Y += walldistance; newposition.Y += walldistance; //Math.Floor() is needed because casting negative values to integer is not floor. Vector3IntRef oldpositioni = Vector3IntRef.Create(game.MathFloor(oldposition.X), game.MathFloor(oldposition.Z), game.MathFloor(oldposition.Y)); float playerpositionX = newposition.X; float playerpositionY = newposition.Y; float playerpositionZ = newposition.Z; //left { float qnewpositionX = newposition.X; float qnewpositionY = newposition.Y; float qnewpositionZ = newposition.Z + walldistance; bool newempty = game.IsTileEmptyForPhysics(game.MathFloor(qnewpositionX), game.MathFloor(qnewpositionZ), game.MathFloor(qnewpositionY)) && game.IsTileEmptyForPhysics(game.MathFloor(qnewpositionX), game.MathFloor(qnewpositionZ), game.MathFloor(qnewpositionY) + 1); if (newposition.Z - oldposition.Z > 0) { if (!newempty) { velocity.Z = -velocity.Z; velocity.X *= bouncespeedmultiply; velocity.Y *= bouncespeedmultiply; velocity.Z *= bouncespeedmultiply; if (ismoving) { game.AudioPlayAt("grenadebounce.ogg", newposition.X, newposition.Y, newposition.Z); } //playerposition.Z = oldposition.Z - newposition.Z; } } } //front { float qnewpositionX = newposition.X + walldistance; float qnewpositionY = newposition.Y; float qnewpositionZ = newposition.Z; bool newempty = game.IsTileEmptyForPhysics(game.MathFloor(qnewpositionX), game.MathFloor(qnewpositionZ), game.MathFloor(qnewpositionY)) && game.IsTileEmptyForPhysics(game.MathFloor(qnewpositionX), game.MathFloor(qnewpositionZ), game.MathFloor(qnewpositionY) + 1); if (newposition.X - oldposition.X > 0) { if (!newempty) { velocity.X = -velocity.X; velocity.X *= bouncespeedmultiply; velocity.Y *= bouncespeedmultiply; velocity.Z *= bouncespeedmultiply; if (ismoving) { game.AudioPlayAt("grenadebounce.ogg", newposition.X, newposition.Y, newposition.Z); } //playerposition.X = oldposition.X - newposition.X; } } } //top { float qnewpositionX = newposition.X; float qnewpositionY = newposition.Y - walldistance; float qnewpositionZ = newposition.Z; int x = game.MathFloor(qnewpositionX); int y = game.MathFloor(qnewpositionZ); int z = game.MathFloor(qnewpositionY); float a_ = walldistance; bool newfull = (!game.IsTileEmptyForPhysics(x, y, z)) || (qnewpositionX - game.MathFloor(qnewpositionX) <= a_ && (!game.IsTileEmptyForPhysics(x - 1, y, z)) && (game.IsTileEmptyForPhysics(x - 1, y, z + 1))) || (qnewpositionX - game.MathFloor(qnewpositionX) >= (1 - a_) && (!game.IsTileEmptyForPhysics(x + 1, y, z)) && (game.IsTileEmptyForPhysics(x + 1, y, z + 1))) || (qnewpositionZ - game.MathFloor(qnewpositionZ) <= a_ && (!game.IsTileEmptyForPhysics(x, y - 1, z)) && (game.IsTileEmptyForPhysics(x, y - 1, z + 1))) || (qnewpositionZ - game.MathFloor(qnewpositionZ) >= (1 - a_) && (!game.IsTileEmptyForPhysics(x, y + 1, z)) && (game.IsTileEmptyForPhysics(x, y + 1, z + 1))); if (newposition.Y - oldposition.Y < 0) { if (newfull) { velocity.Y = -velocity.Y; velocity.X *= bouncespeedmultiply; velocity.Y *= bouncespeedmultiply; velocity.Z *= bouncespeedmultiply; if (ismoving) { game.AudioPlayAt("grenadebounce.ogg", newposition.X, newposition.Y, newposition.Z); } //playerposition.Y = oldposition.Y - newposition.Y; } } } //right { float qnewpositionX = newposition.X; float qnewpositionY = newposition.Y; float qnewpositionZ = newposition.Z - walldistance; bool newempty = game.IsTileEmptyForPhysics(game.MathFloor(qnewpositionX), game.MathFloor(qnewpositionZ), game.MathFloor(qnewpositionY)) && game.IsTileEmptyForPhysics(game.MathFloor(qnewpositionX), game.MathFloor(qnewpositionZ), game.MathFloor(qnewpositionY) + 1); if (newposition.Z - oldposition.Z < 0) { if (!newempty) { velocity.Z = -velocity.Z; velocity.X *= bouncespeedmultiply; velocity.Y *= bouncespeedmultiply; velocity.Z *= bouncespeedmultiply; if (ismoving) { game.AudioPlayAt("grenadebounce.ogg", newposition.X, newposition.Y, newposition.Z); } //playerposition.Z = oldposition.Z - newposition.Z; } } } //back { float qnewpositionX = newposition.X - walldistance; float qnewpositionY = newposition.Y; float qnewpositionZ = newposition.Z; bool newempty = game.IsTileEmptyForPhysics(game.MathFloor(qnewpositionX), game.MathFloor(qnewpositionZ), game.MathFloor(qnewpositionY)) && game.IsTileEmptyForPhysics(game.MathFloor(qnewpositionX), game.MathFloor(qnewpositionZ), game.MathFloor(qnewpositionY) + 1); if (newposition.X - oldposition.X < 0) { if (!newempty) { velocity.X = -velocity.X; velocity.X *= bouncespeedmultiply; velocity.Y *= bouncespeedmultiply; velocity.Z *= bouncespeedmultiply; if (ismoving) { game.AudioPlayAt("grenadebounce.ogg", newposition.X, newposition.Y, newposition.Z); } //playerposition.X = oldposition.X - newposition.X; } } } //bottom { float qnewpositionX = newposition.X; float qnewpositionY = newposition.Y + modelheight; float qnewpositionZ = newposition.Z; bool newempty = game.IsTileEmptyForPhysics(game.MathFloor(qnewpositionX), game.MathFloor(qnewpositionZ), game.MathFloor(qnewpositionY)); if (newposition.Y - oldposition.Y > 0) { if (!newempty) { velocity.Y = -velocity.Y; velocity.X *= bouncespeedmultiply; velocity.Y *= bouncespeedmultiply; velocity.Z *= bouncespeedmultiply; if (ismoving) { game.AudioPlayAt("grenadebounce.ogg", newposition.X, newposition.Y, newposition.Z); } //playerposition.Y = oldposition.Y - newposition.Y; } } } //ok: playerpositionY -= walldistance; return(Vector3Ref.Create(playerpositionX, playerpositionY, playerpositionZ)); }
internal void DrawPlayers(Game game, float dt) { game.totaltimeMilliseconds = game.platform.TimeMillisecondsFromStart(); for (int i = 0; i < game.entitiesCount; i++) { if (game.entities[i] == null) { continue; } if (game.entities[i].drawModel == null) { continue; } Entity p_ = game.entities[i]; if (i == game.LocalPlayerId && (!game.ENABLE_TPP_VIEW)) { continue; } if ((p_.networkPosition != null) && (!p_.networkPosition.PositionLoaded)) { continue; } if (!game.d_FrustumCulling.SphereInFrustum(p_.position.x, p_.position.y, p_.position.z, 3)) { continue; } if (p_.drawModel.CurrentTexture == -1) { continue; } int cx = game.platform.FloatToInt(p_.position.x) / Game.chunksize; int cy = game.platform.FloatToInt(p_.position.z) / Game.chunksize; int cz = game.platform.FloatToInt(p_.position.y) / Game.chunksize; if (game.map.IsValidChunkPos(cx, cy, cz)) { if (!game.map.IsChunkRendered(cx, cy, cz)) { continue; } } float shadow = (one * game.GetLight(game.platform.FloatToInt(p_.position.x), game.platform.FloatToInt(p_.position.z), game.platform.FloatToInt(p_.position.y))) / Game.maxlight; if (p_.playerDrawInfo == null) { p_.playerDrawInfo = new PlayerDrawInfo(); } p_.playerDrawInfo.anim.light = shadow; float FeetPosX = p_.position.x; float FeetPosY = p_.position.y; float FeetPosZ = p_.position.z; AnimationHint animHint = game.entities[i].playerDrawInfo.AnimationHint_; float playerspeed_; if (i == game.LocalPlayerId) { if (game.player.playerDrawInfo == null) { game.player.playerDrawInfo = new PlayerDrawInfo(); } Vector3Ref playerspeed = Vector3Ref.Create(game.playervelocity.X / 60, game.playervelocity.Y / 60, game.playervelocity.Z / 60); float playerspeedf = playerspeed.Length() * (one * 15 / 10); game.player.playerDrawInfo.moves = playerspeedf != 0; playerspeed_ = playerspeedf; } else { playerspeed_ = (game.Length(p_.playerDrawInfo.velocityX, p_.playerDrawInfo.velocityY, p_.playerDrawInfo.velocityZ) / dt) * (one * 4 / 100); } { if (p_.drawModel.renderer == null) { p_.drawModel.renderer = new AnimatedModelRenderer(); byte[] data = game.GetFile(p_.drawModel.Model_); int dataLength = game.GetFileLength(p_.drawModel.Model_); if (data != null) { string dataString = game.platform.StringFromUtf8ByteArray(data, dataLength); AnimatedModel model = AnimatedModelSerializer.Deserialize(game.platform, dataString); p_.drawModel.renderer.Start(game, model); } } game.GLPushMatrix(); game.GLTranslate(FeetPosX, FeetPosY, FeetPosZ); //game.GLRotate(PlayerInterpolate.RadToDeg(p_.position.rotx), 1, 0, 0); game.GLRotate(PlayerInterpolate.RadToDeg(-p_.position.roty + Game.GetPi()), 0, 1, 0); //game.GLRotate(PlayerInterpolate.RadToDeg(p_.position.rotz), 0, 0, 1); game.platform.BindTexture2d(game.entities[i].drawModel.CurrentTexture); p_.drawModel.renderer.Render(dt, PlayerInterpolate.RadToDeg(p_.position.rotx + Game.GetPi()), true, p_.playerDrawInfo.moves, shadow); game.GLPopMatrix(); } } }