Update() private method

private Update ( ) : void
return void
Exemplo n.º 1
0
 public void EndShoot(MyShootActionEnum action)
 {
     MyAnalyticsHelper.ReportActivityEnd(this.Owner, "Drilling");
     m_drillBase.StopDrill();
     m_tryingToDrill = false;
     SinkComp.Update();
 }
        private void UpdatePower()
        {
            bool shouldBePowered = ShouldBePowered();

            if (shouldBePowered != m_wasPowered)
            {
                m_wasPowered = shouldBePowered;
                SinkComp.Update();
            }
        }
 public virtual void EndShoot(MyShootActionEnum action)
 {
     if (action == MyShootActionEnum.PrimaryAction)
     {
         CurrentEffect = 0;
         StopLoopSound();
         ShakeAmount     = 0.0f;
         m_tryingToShoot = false;
         SinkComp.Update();
         m_activated         = false;
         m_shootFrameCounter = 0;
     }
 }
Exemplo n.º 4
0
        public void OnControlReleased()
        {
            m_drillBase.IgnoredEntities.Remove(m_owner);
            m_drillBase.StopDrill();
            m_tryingToDrill = false;
            SinkComp.Update();
            m_drillBase.OutputInventory = null;

            if (m_owner.ControllerInfo.IsLocallyControlled())
            {
                m_oreDetectorBase.Clear();
            }

            m_owner = null;
        }
Exemplo n.º 5
0
        private bool DoDrillAction(bool collectOre)
        {
            m_tryingToDrill = true;
            SinkComp.Update();

            if (!SinkComp.IsPowered)
            {
                return(false);
            }

            m_lastTimeDrilled = MySandboxGame.TotalGamePlayTimeInMilliseconds;
            m_drillBase.Drill(collectOre);
            m_spikeLastUpdateTime = MySandboxGame.TotalGamePlayTimeInMilliseconds;

            return(true);
        }
Exemplo n.º 6
0
        private bool DoDrillAction(bool collectOre)
        {
            m_tryingToDrill = true;
            SinkComp.Update();

            if (!SinkComp.IsPoweredByType(MyResourceDistributorComponent.ElectricityId))
            {
                return(false);
            }

            m_lastTimeDrilled = MySandboxGame.TotalGamePlayTimeInMilliseconds;
            m_drillBase.Drill(collectOre, assignDamagedMaterial: true, speedMultiplier: m_speedMultiplier);
            m_spikeLastUpdateTime = MySandboxGame.TotalGamePlayTimeInMilliseconds;

            return(true);
        }
Exemplo n.º 7
0
        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 virtual void Shoot(MyShootActionEnum action, Vector3 direction, string gunAction)
        {
            if (action != MyShootActionEnum.PrimaryAction)
            {
                return;
            }

            m_lastTimeShoot = MySandboxGame.TotalGamePlayTimeInMilliseconds;

            m_shootFrameCounter++;
            m_tryingToShoot = true;
            SinkComp.Update();
            if (!SinkComp.IsPowered)
            {
                CurrentEffect = 0;
                return;
            }

            m_activated = true;

            var targetBlock = GetTargetBlock();

            if (targetBlock == null)
            {
                CurrentEffect = 2;
                ShakeAmount   = m_handItemDef.ShakeAmountNoTarget;
            }

            int currentTime = MySandboxGame.TotalGamePlayTimeInMilliseconds;

            if (targetBlock != null)
            {
                ShakeAmount   = m_handItemDef.ShakeAmountTarget;
                CurrentEffect = 1;
            }
            return;
        }
Exemplo n.º 9
0
 protected override void OnEnabledChanged()
 {
     base.OnEnabledChanged();
     SinkComp.Update();
 }
Exemplo n.º 10
0
 void ComponentStack_IsFunctionalChanged()
 {
     SinkComp.Update();
 }
Exemplo n.º 11
0
 public void EndShoot(MyShootActionEnum action)
 {
     m_drillBase.StopDrill();
     m_tryingToDrill = false;
     SinkComp.Update();
 }
Exemplo n.º 12
0
        public override void UpdateAfterSimulation()
        {
            base.UpdateAfterSimulation();

            //MyRenderProxy.DebugDrawSphere(m_gunBase.PositionMuzzleWorld, 0.2f, new Vector3(1, 0, 0), 1.0f, true);

            m_targetGrid           = null;
            m_targetDestroyable    = null;
            m_targetFloatingObject = null;
            m_targetCharacter      = null;

            if (Owner == null)
            {
                return;
            }

            var   entitiesInRange    = m_sensor.EntitiesInRange;
            int   closestEntityIndex = 0;
            float closestDistance    = float.MaxValue;

            if (entitiesInRange != null && entitiesInRange.Count > 0)
            {
                int i = 0;
                foreach (var entity in entitiesInRange.Values)
                {
                    var targetGrid = entity.Entity as MyCubeGrid;
                    var distanceSq = (float)Vector3D.DistanceSquared(entity.DetectionPoint, m_gunBase.GetMuzzleWorldPosition());
                    if (entity.Entity.Physics != null && entity.Entity.Physics.Enabled)
                    {
                        if (distanceSq < closestDistance)
                        {
                            m_targetGrid           = targetGrid;
                            m_targetDistanceSq     = (float)distanceSq;
                            m_targetDestroyable    = entity.Entity as IMyDestroyableObject;
                            m_targetFloatingObject = entity.Entity as MyFloatingObject;
                            m_targetCharacter      = entity.Entity as MyCharacter;
                            closestDistance        = m_targetDistanceSq;
                            closestEntityIndex     = i;
                        }
                    }
                    ++i;
                }
            }

            if (m_targetGrid != null)
            {
                m_targetPosition = entitiesInRange.Values.ElementAt(closestEntityIndex).DetectionPoint;
                var invWorld     = m_targetGrid.PositionComp.GetWorldMatrixNormalizedInv();
                var gridLocalPos = Vector3D.Transform(m_targetPosition, invWorld);
                var gridSpacePos = Vector3I.Round(gridLocalPos / m_targetGrid.GridSize);
                m_targetGrid.FixTargetCube(out m_targetCube, gridLocalPos / m_targetGrid.GridSize);

                var head        = PositionComp.WorldMatrix;
                var aimToMuzzle = Vector3D.Normalize(m_targetPosition - m_gunBase.GetMuzzleWorldPosition());
                if (Vector3.Dot(aimToMuzzle, head.Forward) > 0)
                {
                    m_targetDistanceSq = 0;
                }
                else
                {
                    m_targetDistanceSq = (float)Vector3D.DistanceSquared(m_targetPosition, m_gunBase.GetMuzzleWorldPosition());
                }
            }
            SinkComp.Update();

            if (IsShooting && !SinkComp.IsPowered)
            {
                EndShoot(MyShootActionEnum.PrimaryAction);
            }

            UpdateEffect();
            CheckEffectType();

            if (Owner != null && Owner.ControllerInfo.IsLocallyHumanControlled())
            {
                if (MySession.Static.SurvivalMode && (MySession.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);
        }