private TerraformingOperation GetTerraformingOperation(TerrainLock terrainLock) { (terrainLock.TerraformType == TerraformType.Undefined || terrainLock.TerraformDirection == TerraformDirection.Undefined || terrainLock.Radius == 0).ThrowIfTrue(ErrorCodes.BadTerraformLock); var position = terrainLock.Location; var radius = terrainLock.Radius.Clamp(0, TERRAFORM_MAX_RADIUS); var falloff = terrainLock.Falloff.Clamp(0, radius); switch (terrainLock.TerraformType) { case TerraformType.Blur: return(new BlurTerraformingOperation(position, radius, PLANT_DAMAGE)); case TerraformType.Level: return(new LevelTerraformingOperation(position, radius, PLANT_DAMAGE)); case TerraformType.Simple: (terrainLock.TerraformDirection == TerraformDirection.Undefined).ThrowIfTrue(ErrorCodes.BadTerraformLock); var sign = terrainLock.TerraformDirection == TerraformDirection.Lower ? -1 : 1; var terrainChangeAmount = TERRAIN_CHANGE_AMOUNT * sign; return(new SimpleTileTerraformingOperation(position, terrainChangeAmount, PLANT_DAMAGE, radius, falloff)); } throw new PerpetuumException(ErrorCodes.BadTerraformLock); }
public override void VisitTerrainLock(TerrainLock terrainLock) { if (!_lockHandler.IsInLockingRange(terrainLock.Location)) { Error = ErrorCodes.TargetOutOfRange; } }
public override void VisitTerrainLock(TerrainLock terrainLock) { _lockType = LockType.Terrain; _target.AppendInt(terrainLock.Location.intX); _target.AppendInt(terrainLock.Location.intY); _target.AppendInt(terrainLock.Location.intZ); base.VisitTerrainLock(terrainLock); }
private void HandleLockTerrain(Packet packet) { var x = packet.ReadInt(); var y = packet.ReadInt(); packet.ReadInt(); // z var z = _zone.GetZ(x, y); var location = new Position(x + 0.5, y + 0.5, z); var isPrimary = packet.ReadByte() != 0; WritePacketLog(packet, $"target = {location} primary = {isPrimary}"); var terrainLock = new TerrainLock(_player, location) { Primary = isPrimary }; _player.AddLock(terrainLock); }
public void VisitTerrainLock(TerrainLock terrainLock) { var location = terrainLock.Location; _weapon.ConsumeAmmo(); var blockingInfo = _weapon?.ParentRobot?.Zone?.Terrain.Blocks.GetValue(terrainLock.Location) ?? BlockingInfo.None; location = location.AddToZ(Math.Min(blockingInfo.Height, 20)); var losResult = _weapon.GetLineOfSight(location); if (losResult.hit && !location.IsEqual2D(losResult.position)) { location = losResult.position; _weapon.OnError(ErrorCodes.LOSFailed); } DoDamageToPosition(location); }
public virtual void VisitTerrainLock(TerrainLock terrainLock) { VisitLock(terrainLock); }