public override bool OnAim(Ray3 aim, ComponentMiner componentMiner, AimState state) { switch (state) { case AimState.InProgress: { componentMiner.ComponentCreature.ComponentCreatureModel.AimHandAngleOrder = 3.2f; Block block2 = BlocksManager.Blocks[Terrain.ExtractContents(componentMiner.ActiveBlockValue)]; ComponentFirstPersonModel componentFirstPersonModel = componentMiner.Entity.FindComponent <ComponentFirstPersonModel>(); if (componentFirstPersonModel != null) { componentMiner.ComponentPlayer?.ComponentAimingSights.ShowAimingSights(aim.Position, aim.Direction); componentFirstPersonModel.ItemOffsetOrder = new Vector3(0f, 0.35f, 0.17f); if (block2 is SpearBlock) { componentFirstPersonModel.ItemRotationOrder = new Vector3(-1.5f, 0f, 0f); } } if (block2 is SpearBlock) { componentMiner.ComponentCreature.ComponentCreatureModel.InHandItemOffsetOrder = new Vector3(0f, -0.25f, 0f); componentMiner.ComponentCreature.ComponentCreatureModel.InHandItemRotationOrder = new Vector3(3.14159f, 0f, 0f); } break; } case AimState.Completed: { Vector3 vector = componentMiner.ComponentCreature.ComponentCreatureModel.EyePosition + componentMiner.ComponentCreature.ComponentBody.Matrix.Right * 0.4f; Vector3 v = Vector3.Normalize(vector + aim.Direction * 10f - vector); if (componentMiner.Inventory == null) { break; } int activeSlotIndex = componentMiner.Inventory.ActiveSlotIndex; int slotValue = componentMiner.Inventory.GetSlotValue(activeSlotIndex); int slotCount = componentMiner.Inventory.GetSlotCount(activeSlotIndex); int num = Terrain.ExtractContents(slotValue); Block block = BlocksManager.Blocks[num]; if (slotCount > 0) { float num2 = block.ProjectileSpeed; if (componentMiner.ComponentPlayer != null) { num2 *= 0.5f * (componentMiner.ComponentPlayer.ComponentLevel.StrengthFactor - 1f) + 1f; } if (m_subsystemProjectiles.FireProjectile(slotValue, vector, v * num2, m_random.Vector3(5f, 10f), componentMiner.ComponentCreature) != null) { componentMiner.Inventory.RemoveSlotItems(activeSlotIndex, 1); m_subsystemAudio.PlaySound("Audio/Throw", m_random.Float(0.2f, 0.3f), m_random.Float(-0.2f, 0.2f), aim.Position, 2f, autoDelay: true); componentMiner.Poke(forceRestart: false); } } break; } } return(false); }
public override bool OnAim(Vector3 start, Vector3 direction, ComponentMiner componentMiner, AimState state) { IInventory inventory = componentMiner.Inventory; if (inventory != null) { int activeSlotIndex = inventory.ActiveSlotIndex; if (activeSlotIndex >= 0) { int slotValue = inventory.GetSlotValue(activeSlotIndex); int slotCount = inventory.GetSlotCount(activeSlotIndex); int num = Terrain.ExtractContents(slotValue); int data = Terrain.ExtractData(slotValue); int num2 = slotValue; int num3 = 0; if (num == Musket2Block.Index && slotCount > 0) { if (!m_aimStartTimes.TryGetValue(componentMiner, out double value)) { value = m_subsystemTime.GameTime; m_aimStartTimes[componentMiner] = value; } float num4 = (float)(m_subsystemTime.GameTime - value); float num5 = (float)MathUtils.Remainder(m_subsystemTime.GameTime, 1000.0); Vector3 v = (float)((componentMiner.ComponentCreature.ComponentBody.IsSneaking ? 0.00999999977648258 : 0.0299999993294477) + 0.200000002980232 * MathUtils.Saturate((num4 - 6.5f) / 40f)) * new Vector3 { X = SimplexNoise.OctavedNoise(num5, 2f, 3, 2f, 0.5f), Y = SimplexNoise.OctavedNoise(num5 + 100f, 2f, 3, 2f, 0.5f), Z = SimplexNoise.OctavedNoise(num5 + 200f, 2f, 3, 2f, 0.5f) }; direction = Vector3.Normalize(direction + v); switch (state) { case AimState.InProgress: { if (num4 >= 30f) { componentMiner.ComponentCreature.ComponentCreatureSounds.PlayMoanSound(); return(true); } if (num4 > 0.2f && !Musket2Block.GetHammerState(Terrain.ExtractData(num2))) { num2 = Terrain.MakeBlockValue(num, 0, Musket2Block.SetHammerState(Terrain.ExtractData(num2), true)); m_subsystemAudio.PlaySound("Audio/HammerCock", 1f, m_random.UniformFloat(-0.1f, 0.1f), 0f, 0f); } ComponentFirstPersonModel componentFirstPersonModel = componentMiner.Entity.FindComponent <ComponentFirstPersonModel>(); if (componentFirstPersonModel != null) { ComponentPlayer componentPlayer2 = componentMiner.ComponentPlayer; if (componentPlayer2 != null) { componentPlayer2.ComponentGui.ShowAimingSights(start, direction); } componentFirstPersonModel.ItemOffsetOrder = new Vector3(-0.21f, 0.15f, 0.08f); componentFirstPersonModel.ItemRotationOrder = new Vector3(-0.7f, 0f, 0f); } componentMiner.ComponentCreature.ComponentCreatureModel.AimHandAngleOrder = 1.4f; componentMiner.ComponentCreature.ComponentCreatureModel.InHandItemOffsetOrder = new Vector3(-0.08f, -0.08f, 0.07f); componentMiner.ComponentCreature.ComponentCreatureModel.InHandItemRotationOrder = new Vector3(-1.7f, 0f, 0f); break; } case AimState.Cancelled: if (Musket2Block.GetHammerState(Terrain.ExtractData(num2))) { num2 = Terrain.MakeBlockValue(num, 0, Musket2Block.SetHammerState(Terrain.ExtractData(num2), false)); m_subsystemAudio.PlaySound("Audio/HammerUncock", 1f, m_random.UniformFloat(-0.1f, 0.1f), 0f, 0f); } m_aimStartTimes.Remove(componentMiner); break; case AimState.Completed: { bool flag = false; int value2 = 0; int num6 = 0; float s = 0f; Vector3 vector = Vector3.Zero; Musket2Block.LoadState loadState = Musket2Block.GetLoadState(data); if (Musket2Block.GetHammerState(Terrain.ExtractData(num2))) { switch (loadState) { case Musket2Block.LoadState.Gunpowder: flag = true; value2 = Terrain.MakeBlockValue(214, 0, BulletBlock.SetBulletType(0, BulletBlock.BulletType.IronBullet)); s = 320f; num6 = 1; vector = new Vector3(0.01f, 0.01f, 0.05f); goto default; default: if (loadState == Musket2Block.LoadState.Wad) { flag = true; value2 = Terrain.MakeBlockValue(214, 0, BulletBlock.SetBulletType(0, BulletBlock.BulletType.IronBullet)); s = 320f; num6 = 1; vector = new Vector3(0.01f, 0.01f, 0.05f); } break; case Musket2Block.LoadState.Empty: { ComponentPlayer componentPlayer = componentMiner.ComponentPlayer; if (componentPlayer != null) { componentPlayer.ComponentGui.DisplaySmallMessage("Load bullet first", true, false); } break; } } } if (flag) { if (componentMiner.ComponentCreature.ComponentBody.ImmersionFactor > 0.4f) { m_subsystemAudio.PlaySound("Audio/MusketMisfire", 1f, m_random.UniformFloat(-0.1f, 0.1f), componentMiner.ComponentCreature.ComponentCreatureModel.EyePosition, 3f, true); } else { Vector3 eyePosition = componentMiner.ComponentCreature.ComponentCreatureModel.EyePosition; Matrix matrix = componentMiner.ComponentCreature.ComponentBody.Matrix; Vector3 v2 = eyePosition + matrix.Right * 0.3f; matrix = componentMiner.ComponentCreature.ComponentBody.Matrix; Vector3 vector2 = v2 - matrix.Up * 0.2f; var vector3 = Vector3.Normalize(vector2 + direction * 10f - vector2); var vector4 = Vector3.Normalize(Vector3.Cross(vector3, Vector3.UnitY)); var v3 = Vector3.Normalize(Vector3.Cross(vector3, vector4)); for (int i = 0; i < num6; i++) { Vector3 v4 = m_random.UniformFloat(0f - vector.X, vector.X) * vector4 + m_random.UniformFloat(0f - vector.Y, vector.Y) * v3 + m_random.UniformFloat(0f - vector.Z, vector.Z) * vector3; Projectile projectile = m_subsystemProjectiles.FireProjectile(value2, vector2, s * (vector3 + v4), Vector3.Zero, componentMiner.ComponentCreature); if (projectile != null) { projectile.ProjectileStoppedAction = ProjectileStoppedAction.Disappear; } } m_subsystemAudio.PlaySound("Audio/MusketFire", 1f, m_random.UniformFloat(-0.1f, 0.1f), componentMiner.ComponentCreature.ComponentCreatureModel.EyePosition, 10f, true); m_subsystemParticles.AddParticleSystem(new GunSmokeParticleSystem(SubsystemTerrain, vector2 + 0.3f * vector3, vector3)); m_subsystemNoise.MakeNoise(vector2, 1f, 40f); componentMiner.ComponentCreature.ComponentBody.ApplyImpulse(-1f * vector3); } if (loadState == Musket2Block.LoadState.Gunpowder) { num2 = Terrain.MakeBlockValue(Terrain.ExtractContents(num2), 0, Musket2Block.SetLoadState(Terrain.ExtractData(num2), Musket2Block.LoadState.Empty)); } if (loadState == Musket2Block.LoadState.Wad) { num2 = Terrain.MakeBlockValue(Terrain.ExtractContents(num2), 0, Musket2Block.SetLoadState(Terrain.ExtractData(num2), Musket2Block.LoadState.Gunpowder)); } num3 = 1; } if (Musket2Block.GetHammerState(Terrain.ExtractData(num2))) { num2 = Terrain.MakeBlockValue(Terrain.ExtractContents(num2), 0, Musket2Block.SetHammerState(Terrain.ExtractData(num2), false)); m_subsystemAudio.PlaySound("Audio/HammerRelease", 1f, m_random.UniformFloat(-0.1f, 0.1f), 0f, 0f); } m_aimStartTimes.Remove(componentMiner); break; } } } if (num2 != slotValue) { inventory.RemoveSlotItems(activeSlotIndex, 1); inventory.AddSlotItems(activeSlotIndex, num2, 1); } if (num3 > 0) { componentMiner.DamageActiveTool(num3); } } } return(false); }
public override bool OnAim(Ray3 aim, ComponentMiner componentMiner, AimState state) { IInventory inventory = componentMiner.Inventory; if (inventory != null) { int activeSlotIndex = inventory.ActiveSlotIndex; if (activeSlotIndex >= 0) { int slotValue = inventory.GetSlotValue(activeSlotIndex); int slotCount = inventory.GetSlotCount(activeSlotIndex); int num = Terrain.ExtractContents(slotValue); int data = Terrain.ExtractData(slotValue); if (num == 191 && slotCount > 0) { if (!m_aimStartTimes.TryGetValue(componentMiner, out double value)) { value = m_subsystemTime.GameTime; m_aimStartTimes[componentMiner] = value; } float num2 = (float)(m_subsystemTime.GameTime - value); float num3 = (float)MathUtils.Remainder(m_subsystemTime.GameTime, 1000.0); Vector3 v = ((componentMiner.ComponentCreature.ComponentBody.IsSneaking ? 0.02f : 0.04f) + 0.25f * MathUtils.Saturate((num2 - 2.1f) / 5f)) * new Vector3 { X = SimplexNoise.OctavedNoise(num3, 2f, 3, 2f, 0.5f), Y = SimplexNoise.OctavedNoise(num3 + 100f, 2f, 3, 2f, 0.5f), Z = SimplexNoise.OctavedNoise(num3 + 200f, 2f, 3, 2f, 0.5f) }; aim.Direction = Vector3.Normalize(aim.Direction + v); switch (state) { case AimState.InProgress: { if (num2 >= 9f) { componentMiner.ComponentCreature.ComponentCreatureSounds.PlayMoanSound(); return(true); } ComponentFirstPersonModel componentFirstPersonModel = componentMiner.Entity.FindComponent <ComponentFirstPersonModel>(); if (componentFirstPersonModel != null) { componentMiner.ComponentPlayer?.ComponentAimingSights.ShowAimingSights(aim.Position, aim.Direction); componentFirstPersonModel.ItemOffsetOrder = new Vector3(-0.1f, 0.15f, 0f); componentFirstPersonModel.ItemRotationOrder = new Vector3(0f, -0.7f, 0f); } componentMiner.ComponentCreature.ComponentCreatureModel.AimHandAngleOrder = 1.2f; componentMiner.ComponentCreature.ComponentCreatureModel.InHandItemOffsetOrder = new Vector3(0f, 0f, 0f); componentMiner.ComponentCreature.ComponentCreatureModel.InHandItemRotationOrder = new Vector3(0f, -0.2f, 0f); if (m_subsystemTime.PeriodicGameTimeEvent(0.10000000149011612, 0.0)) { int draw2 = MathUtils.Min(BowBlock.GetDraw(data) + 1, 15); inventory.RemoveSlotItems(activeSlotIndex, 1); inventory.AddSlotItems(activeSlotIndex, Terrain.MakeBlockValue(num, 0, BowBlock.SetDraw(data, draw2)), 1); } break; } case AimState.Cancelled: inventory.RemoveSlotItems(activeSlotIndex, 1); inventory.AddSlotItems(activeSlotIndex, Terrain.MakeBlockValue(num, 0, BowBlock.SetDraw(data, 0)), 1); m_aimStartTimes.Remove(componentMiner); break; case AimState.Completed: { int draw = BowBlock.GetDraw(data); ArrowBlock.ArrowType?arrowType = BowBlock.GetArrowType(data); if (arrowType.HasValue) { Vector3 vector = componentMiner.ComponentCreature.ComponentCreatureModel.EyePosition + componentMiner.ComponentCreature.ComponentBody.Matrix.Right * 0.3f - componentMiner.ComponentCreature.ComponentBody.Matrix.Up * 0.2f; Vector3 vector2 = Vector3.Normalize(vector + aim.Direction * 10f - vector); float num4 = MathUtils.Lerp(0f, 28f, MathUtils.Pow((float)draw / 15f, 0.75f)); if (componentMiner.ComponentPlayer != null) { num4 *= 0.5f * (componentMiner.ComponentPlayer.ComponentLevel.StrengthFactor - 1f) + 1f; } Vector3 vector3 = Vector3.Zero; if (arrowType == ArrowBlock.ArrowType.WoodenArrow) { vector3 = new Vector3(0.025f, 0.025f, 0.025f); } if (arrowType == ArrowBlock.ArrowType.StoneArrow) { vector3 = new Vector3(0.01f, 0.01f, 0.01f); } int value2 = Terrain.MakeBlockValue(192, 0, ArrowBlock.SetArrowType(0, arrowType.Value)); Vector3 vector4 = Vector3.Normalize(Vector3.Cross(vector2, Vector3.UnitY)); Vector3 v2 = Vector3.Normalize(Vector3.Cross(vector2, vector4)); Vector3 v3 = m_random.Float(0f - vector3.X, vector3.X) * vector4 + m_random.Float(0f - vector3.Y, vector3.Y) * v2 + m_random.Float(0f - vector3.Z, vector3.Z) * vector2; if (m_subsystemProjectiles.FireProjectile(value2, vector, (vector2 + v3) * num4, Vector3.Zero, componentMiner.ComponentCreature) != null) { data = BowBlock.SetArrowType(data, null); m_subsystemAudio.PlaySound("Audio/Bow", 1f, m_random.Float(-0.1f, 0.1f), vector, 3f, autoDelay: true); } } else { componentMiner.ComponentPlayer?.ComponentGui.DisplaySmallMessage("Load an arrow first", Color.White, blinking: true, playNotificationSound: false); } inventory.RemoveSlotItems(activeSlotIndex, 1); int value3 = Terrain.MakeBlockValue(num, 0, BowBlock.SetDraw(data, 0)); inventory.AddSlotItems(activeSlotIndex, value3, 1); int damageCount = 0; if (draw >= 15) { damageCount = 2; } else if (draw >= 4) { damageCount = 1; } componentMiner.DamageActiveTool(damageCount); m_aimStartTimes.Remove(componentMiner); break; } } } } } return(false); }
public override bool OnAim(Ray3 aim, ComponentMiner componentMiner, AimState state) { IInventory inventory = componentMiner.Inventory; if (inventory != null) { int activeSlotIndex = inventory.ActiveSlotIndex; if (activeSlotIndex >= 0) { int slotValue = inventory.GetSlotValue(activeSlotIndex); int slotCount = inventory.GetSlotCount(activeSlotIndex); int num = Terrain.ExtractContents(slotValue); int data = Terrain.ExtractData(slotValue); int num2 = slotValue; int num3 = 0; if (num == 212 && slotCount > 0) { if (!m_aimStartTimes.TryGetValue(componentMiner, out double value)) { value = m_subsystemTime.GameTime; m_aimStartTimes[componentMiner] = value; } float num4 = (float)(m_subsystemTime.GameTime - value); float num5 = (float)MathUtils.Remainder(m_subsystemTime.GameTime, 1000.0); Vector3 v = ((componentMiner.ComponentCreature.ComponentBody.IsSneaking ? 0.01f : 0.03f) + 0.2f * MathUtils.Saturate((num4 - 2.5f) / 6f)) * new Vector3 { X = SimplexNoise.OctavedNoise(num5, 2f, 3, 2f, 0.5f), Y = SimplexNoise.OctavedNoise(num5 + 100f, 2f, 3, 2f, 0.5f), Z = SimplexNoise.OctavedNoise(num5 + 200f, 2f, 3, 2f, 0.5f) }; aim.Direction = Vector3.Normalize(aim.Direction + v); switch (state) { case AimState.InProgress: { if (num4 >= 10f) { componentMiner.ComponentCreature.ComponentCreatureSounds.PlayMoanSound(); return(true); } if (num4 > 0.5f && !MusketBlock.GetHammerState(Terrain.ExtractData(num2))) { num2 = Terrain.MakeBlockValue(num, 0, MusketBlock.SetHammerState(Terrain.ExtractData(num2), state: true)); m_subsystemAudio.PlaySound("Audio/HammerCock", 1f, m_random.Float(-0.1f, 0.1f), 0f, 0f); } ComponentFirstPersonModel componentFirstPersonModel = componentMiner.Entity.FindComponent <ComponentFirstPersonModel>(); if (componentFirstPersonModel != null) { componentMiner.ComponentPlayer?.ComponentAimingSights.ShowAimingSights(aim.Position, aim.Direction); componentFirstPersonModel.ItemOffsetOrder = new Vector3(-0.21f, 0.15f, 0.08f); componentFirstPersonModel.ItemRotationOrder = new Vector3(-0.7f, 0f, 0f); } componentMiner.ComponentCreature.ComponentCreatureModel.AimHandAngleOrder = 1.4f; componentMiner.ComponentCreature.ComponentCreatureModel.InHandItemOffsetOrder = new Vector3(-0.08f, -0.08f, 0.07f); componentMiner.ComponentCreature.ComponentCreatureModel.InHandItemRotationOrder = new Vector3(-1.7f, 0f, 0f); break; } case AimState.Cancelled: if (MusketBlock.GetHammerState(Terrain.ExtractData(num2))) { num2 = Terrain.MakeBlockValue(num, 0, MusketBlock.SetHammerState(Terrain.ExtractData(num2), state: false)); m_subsystemAudio.PlaySound("Audio/HammerUncock", 1f, m_random.Float(-0.1f, 0.1f), 0f, 0f); } m_aimStartTimes.Remove(componentMiner); break; case AimState.Completed: { bool flag = false; int value2 = 0; int num6 = 0; float s = 0f; Vector3 vector = Vector3.Zero; MusketBlock.LoadState loadState = MusketBlock.GetLoadState(data); BulletBlock.BulletType?bulletType = MusketBlock.GetBulletType(data); if (MusketBlock.GetHammerState(Terrain.ExtractData(num2))) { switch (loadState) { case MusketBlock.LoadState.Empty: componentMiner.ComponentPlayer?.ComponentGui.DisplaySmallMessage("Load gunpowder first", Color.White, blinking: true, playNotificationSound: false); break; case MusketBlock.LoadState.Gunpowder: case MusketBlock.LoadState.Wad: flag = true; componentMiner.ComponentPlayer?.ComponentGui.DisplaySmallMessage("No bullet, blind shot fired", Color.White, blinking: true, playNotificationSound: false); break; case MusketBlock.LoadState.Loaded: flag = true; if (bulletType == BulletBlock.BulletType.Buckshot) { value2 = Terrain.MakeBlockValue(214, 0, BulletBlock.SetBulletType(0, BulletBlock.BulletType.BuckshotBall)); num6 = 8; vector = new Vector3(0.04f, 0.04f, 0.25f); s = 80f; } else if (bulletType == BulletBlock.BulletType.BuckshotBall) { value2 = Terrain.MakeBlockValue(214, 0, BulletBlock.SetBulletType(0, BulletBlock.BulletType.BuckshotBall)); num6 = 1; vector = new Vector3(0.06f, 0.06f, 0f); s = 60f; } else if (bulletType.HasValue) { value2 = Terrain.MakeBlockValue(214, 0, BulletBlock.SetBulletType(0, bulletType.Value)); num6 = 1; s = 120f; } break; } } if (flag) { if (componentMiner.ComponentCreature.ComponentBody.ImmersionFactor > 0.4f) { m_subsystemAudio.PlaySound("Audio/MusketMisfire", 1f, m_random.Float(-0.1f, 0.1f), componentMiner.ComponentCreature.ComponentCreatureModel.EyePosition, 3f, autoDelay: true); } else { Vector3 vector2 = componentMiner.ComponentCreature.ComponentCreatureModel.EyePosition + componentMiner.ComponentCreature.ComponentBody.Matrix.Right * 0.3f - componentMiner.ComponentCreature.ComponentBody.Matrix.Up * 0.2f; Vector3 vector3 = Vector3.Normalize(vector2 + aim.Direction * 10f - vector2); Vector3 vector4 = Vector3.Normalize(Vector3.Cross(vector3, Vector3.UnitY)); Vector3 v2 = Vector3.Normalize(Vector3.Cross(vector3, vector4)); for (int i = 0; i < num6; i++) { Vector3 v3 = m_random.Float(0f - vector.X, vector.X) * vector4 + m_random.Float(0f - vector.Y, vector.Y) * v2 + m_random.Float(0f - vector.Z, vector.Z) * vector3; Projectile projectile = m_subsystemProjectiles.FireProjectile(value2, vector2, s * (vector3 + v3), Vector3.Zero, componentMiner.ComponentCreature); if (projectile != null) { projectile.ProjectileStoppedAction = ProjectileStoppedAction.Disappear; } } m_subsystemAudio.PlaySound("Audio/MusketFire", 1f, m_random.Float(-0.1f, 0.1f), componentMiner.ComponentCreature.ComponentCreatureModel.EyePosition, 10f, autoDelay: true); m_subsystemParticles.AddParticleSystem(new GunSmokeParticleSystem(m_subsystemTerrain, vector2 + 0.3f * vector3, vector3)); m_subsystemNoise.MakeNoise(vector2, 1f, 40f); componentMiner.ComponentCreature.ComponentBody.ApplyImpulse(-4f * vector3); } num2 = Terrain.MakeBlockValue(Terrain.ExtractContents(num2), 0, MusketBlock.SetLoadState(Terrain.ExtractData(num2), MusketBlock.LoadState.Empty)); num3 = 1; } if (MusketBlock.GetHammerState(Terrain.ExtractData(num2))) { num2 = Terrain.MakeBlockValue(Terrain.ExtractContents(num2), 0, MusketBlock.SetHammerState(Terrain.ExtractData(num2), state: false)); m_subsystemAudio.PlaySound("Audio/HammerRelease", 1f, m_random.Float(-0.1f, 0.1f), 0f, 0f); } m_aimStartTimes.Remove(componentMiner); break; } } } if (num2 != slotValue) { inventory.RemoveSlotItems(activeSlotIndex, 1); inventory.AddSlotItems(activeSlotIndex, num2, 1); } if (num3 > 0) { componentMiner.DamageActiveTool(num3); } } } return(false); }
public override bool OnAim(Ray3 aim, ComponentMiner componentMiner, AimState state) { IInventory inventory = componentMiner.Inventory; if (inventory != null) { int activeSlotIndex = inventory.ActiveSlotIndex; if (activeSlotIndex >= 0) { int slotValue = inventory.GetSlotValue(activeSlotIndex); int slotCount = inventory.GetSlotCount(activeSlotIndex); int num = Terrain.ExtractContents(slotValue); int data = Terrain.ExtractData(slotValue); if (num == 200 && slotCount > 0) { int draw = CrossbowBlock.GetDraw(data); if (!m_aimStartTimes.TryGetValue(componentMiner, out double value)) { value = m_subsystemTime.GameTime; m_aimStartTimes[componentMiner] = value; } float num2 = (float)(m_subsystemTime.GameTime - value); float num3 = (float)MathUtils.Remainder(m_subsystemTime.GameTime, 1000.0); Vector3 v = ((componentMiner.ComponentCreature.ComponentBody.IsSneaking ? 0.01f : 0.03f) + 0.15f * MathUtils.Saturate((num2 - 2.5f) / 6f)) * new Vector3 { X = SimplexNoise.OctavedNoise(num3, 2f, 3, 2f, 0.5f), Y = SimplexNoise.OctavedNoise(num3 + 100f, 2f, 3, 2f, 0.5f), Z = SimplexNoise.OctavedNoise(num3 + 200f, 2f, 3, 2f, 0.5f) }; aim.Direction = Vector3.Normalize(aim.Direction + v); switch (state) { case AimState.InProgress: { if (num2 >= 10f) { componentMiner.ComponentCreature.ComponentCreatureSounds.PlayMoanSound(); return(true); } ComponentFirstPersonModel componentFirstPersonModel = componentMiner.Entity.FindComponent <ComponentFirstPersonModel>(); if (componentFirstPersonModel != null) { componentMiner.ComponentPlayer?.ComponentAimingSights.ShowAimingSights(aim.Position, aim.Direction); componentFirstPersonModel.ItemOffsetOrder = new Vector3(-0.22f, 0.15f, 0.1f); componentFirstPersonModel.ItemRotationOrder = new Vector3(-0.7f, 0f, 0f); } componentMiner.ComponentCreature.ComponentCreatureModel.AimHandAngleOrder = 1.3f; componentMiner.ComponentCreature.ComponentCreatureModel.InHandItemOffsetOrder = new Vector3(-0.08f, -0.1f, 0.07f); componentMiner.ComponentCreature.ComponentCreatureModel.InHandItemRotationOrder = new Vector3(-1.55f, 0f, 0f); break; } case AimState.Cancelled: m_aimStartTimes.Remove(componentMiner); break; case AimState.Completed: { ArrowBlock.ArrowType?arrowType = CrossbowBlock.GetArrowType(data); if (draw != 15) { componentMiner.ComponentPlayer?.ComponentGui.DisplaySmallMessage("Draw the crossbow first", Color.White, blinking: true, playNotificationSound: false); } else if (!arrowType.HasValue) { componentMiner.ComponentPlayer?.ComponentGui.DisplaySmallMessage("Load a bolt first", Color.White, blinking: true, playNotificationSound: false); } else { Vector3 vector = componentMiner.ComponentCreature.ComponentCreatureModel.EyePosition + componentMiner.ComponentCreature.ComponentBody.Matrix.Right * 0.3f - componentMiner.ComponentCreature.ComponentBody.Matrix.Up * 0.2f; Vector3 v2 = Vector3.Normalize(vector + aim.Direction * 10f - vector); int value2 = Terrain.MakeBlockValue(192, 0, ArrowBlock.SetArrowType(0, arrowType.Value)); float s = 38f; if (m_subsystemProjectiles.FireProjectile(value2, vector, s * v2, Vector3.Zero, componentMiner.ComponentCreature) != null) { data = CrossbowBlock.SetArrowType(data, null); m_subsystemAudio.PlaySound("Audio/Bow", 1f, m_random.Float(-0.1f, 0.1f), componentMiner.ComponentCreature.ComponentCreatureModel.EyePosition, 3f, 0.05f); } } inventory.RemoveSlotItems(activeSlotIndex, 1); int value3 = Terrain.MakeBlockValue(num, 0, CrossbowBlock.SetDraw(data, 0)); inventory.AddSlotItems(activeSlotIndex, value3, 1); if (draw > 0) { componentMiner.DamageActiveTool(1); m_subsystemAudio.PlaySound("Audio/CrossbowBoing", 1f, m_random.Float(-0.1f, 0.1f), componentMiner.ComponentCreature.ComponentCreatureModel.EyePosition, 3f, 0f); } m_aimStartTimes.Remove(componentMiner); break; } } } } } return(false); }