public override void UpdateAfterSimulation() { base.UpdateAfterSimulation(); //MyRenderProxy.DebugDrawSphere(m_gunBase.PositionMuzzleWorld, 0.2f, new Vector3(1, 0, 0), 1.0f, true); if (Owner == null) { return; } Vector3 weaponLocalPosition = Owner.GetLocalWeaponPosition(); Vector3D localDummyPosition = m_gunBase.GetMuzzleLocalPosition(); MatrixD weaponWorld = WorldMatrix; Vector3D localDummyPositionRotated; Vector3D.Rotate(ref localDummyPosition, ref weaponWorld, out localDummyPositionRotated); m_raycastComponent.SetPointOfReference(Owner.PositionComp.GetPosition() + weaponLocalPosition + localDummyPositionRotated); SinkComp.Update(); if (IsShooting && !SinkComp.IsPowered) { EndShoot(MyShootActionEnum.PrimaryAction); } UpdateEffect(); CheckEffectType(); if (Owner != null && Owner.ControllerInfo.IsLocallyHumanControlled()) { if (MySession.Static.SurvivalMode && (MySession.Static.GetCameraControllerEnum() != MyCameraControllerEnum.Spectator || MyFinalBuildConstants.IS_OFFICIAL)) { var character = ((MyCharacter)this.CharacterInventory.Owner); MyCubeBuilder.Static.MaxGridDistanceFrom = character.PositionComp.GetPosition() + character.WorldMatrix.Up * 1.8f; } else { MyCubeBuilder.Static.MaxGridDistanceFrom = null; } } //MyTrace.Watch("MyEngineerToolBase.RequiredPowerInput", RequiredPowerInput); }
public void Init(MyObjectBuilder_EntityBase builder, MyHandItemDefinition definition) { m_handItemDef = definition; System.Diagnostics.Debug.Assert(definition != null, "Missing definition for tool!"); if (definition != null) { m_physItemDef = MyDefinitionManager.Static.GetPhysicalItemForHandItem(definition.Id); m_gunBase = new MyToolBase(m_handItemDef.MuzzlePosition, WorldMatrix); } else { m_gunBase = new MyToolBase(Vector3.Zero, WorldMatrix); } base.Init(builder); if (PhysicalObject != null) { PhysicalObject.GunEntity = builder; } if ((definition as MyEngineerToolBaseDefinition) != null) { m_speedMultiplier = (m_handItemDef as MyEngineerToolBaseDefinition).SpeedMultiplier; m_distanceMultiplier = (definition as MyEngineerToolBaseDefinition).DistanceMultiplier; } MyDrillSensorRayCast raycaster = new MyDrillSensorRayCast(0f, DEFAULT_REACH_DISTANCE * m_distanceMultiplier); m_raycastComponent = new MyCasterComponent(raycaster); m_raycastComponent.SetPointOfReference(m_gunBase.GetMuzzleWorldPosition()); Components.Add <MyCasterComponent>(m_raycastComponent); var sinkComp = new MyResourceSinkComponent(); sinkComp.Init( MyStringHash.GetOrCompute("Utility"), MyEnergyConstants.REQUIRED_INPUT_ENGINEERING_TOOL, CalculateRequiredPower); SinkComp = sinkComp; m_soundEmitter = new MyEntity3DSoundEmitter(this); }