Inheritance: MonoBehaviour
Ejemplo n.º 1
0
 void Impact_Invalidated(object sender, InvalidateEventArgs e)
 {
     syncContext.Send(new SendOrPostCallback(delegate(object o)
     {
         UpdateAuthorInfo(Impact.GetSelectedAuthor());
     }), this);
 }
Ejemplo n.º 2
0
        public override void OnDisable()
        {
            base.OnDisable();

            Impact.Reset();
            Motion.Reset();
        }
Ejemplo n.º 3
0
 private void OnTriggerEnter(Collider collider)
 {
     if (collider.tag == "Bubble")
     {
         Impact?.Invoke(gameObject, collider);
     }
 }
Ejemplo n.º 4
0
        public static bool DoTheyCollide(Body a, Body b, out Impact impactA, out Impact impactB)
        {
            impactA = new Impact();
            impactB = new Impact();

            return(false);
        }
Ejemplo n.º 5
0
        public override void OnDisable()
        {
            base.OnDisable();

            Inventory.Reset();
            Impact.Reset();
        }
Ejemplo n.º 6
0
        private Impact CalculateImpactStats(Patch fileChanges)
        {
            var result = new Impact();

            foreach (var file in fileChanges)
            {
                if (FileShouldBeIgnored(file))
                {
                    continue;
                }

                var totalCommentedOutlinesToRemove = TotalCommentedOutLinesToDeduct(fileChanges);
                var totalLinesEdited = ((file.LinesAdded - totalCommentedOutlinesToRemove) + (file.LinesDeleted - totalCommentedOutlinesToRemove));

                result.TotalFiles         += 1;
                result.TotalEditLocations += (file.Patch.Split("@@").Length - 1) / 2;

                result.TotalLinesEdited += totalLinesEdited;
                if (file.Status == ChangeKind.Modified)
                {
                    result.TotalLinesOfOldCode += totalLinesEdited;
                }
            }

            return(result);
        }
Ejemplo n.º 7
0
        public override void Update(float deltaTime)
        {
            for (int i = bulletImpacts.Count - 1; i >= 0; i--)
            {
                Impact imp = bulletImpacts[i];
                imp.TimeLeft -= deltaTime;

                if (imp.TimeLeft <= 0)
                {
                    bulletImpacts.RemoveAt(i);
                }
            }

            for (int i = playerRollbacks.Count - 1; i >= 0; i--)
            {
                Impact imp = playerRollbacks[i];
                imp.TimeLeft -= deltaTime;

                if (imp.TimeLeft <= 0)
                {
                    playerRollbacks.RemoveAt(i);
                }
            }

            base.Update(deltaTime);
        }
Ejemplo n.º 8
0
        public override void Start()
        {
            base.Start();

            Impact.Init(this);
            Motion.Init(this);
        }
Ejemplo n.º 9
0
        public override void OnEnable()
        {
            base.OnEnable();

            Impact.Init(this);
            Motion.Init(this);
        }
Ejemplo n.º 10
0
        public override bool RunCharacterImpact(Character character)
        {
            DirCardinal dir = CollideDetect.GetDirectionOfCollision(character, this);

            if (dir == DirCardinal.Left)
            {
                TileCharBasicImpact.RunWallImpact(character, dir, DirCardinal.None);
            }
            else if (dir == DirCardinal.Right)
            {
                TileCharBasicImpact.RunWallImpact(character, dir, DirCardinal.None);
            }

            // Character is Beneath
            else if (dir == DirCardinal.Up)
            {
                if (this.physics.velocity.Y > 0)
                {
                    character.wounds.ReceiveWoundDamage(DamageStrength.Standard);

                    // Will kill if character is on ground.
                    if (character.physics.touch.toBottom)
                    {
                        character.wounds.ReceiveWoundDamage(DamageStrength.InstantKill);
                        return(true);
                    }
                }

                TileCharBasicImpact.RunWallImpact(character, dir, DirCardinal.None);
            }

            return(Impact.StandardImpact(character, this, dir));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,QmsProceduresProcesses,OtherDocumentation,FinishedProduct,ExistMaterialStockFinishProd,ProdCustSpec,MaterialQualification,ProductValidation,ProcessValidation,TestEquipMethodsCalib,RegulatoryReq,SupplierAgreementsSpec,CustomerReqSpec,NewExistEquipSoftware,Cleaning,Maintenance,Environment,ManufWorkFlowAncillaryPkgEquip,Other,ChangeLogId")] Impact impact)
        {
            if (id != impact.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(impact);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ImpactExists(impact.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ChangeLogId"] = new SelectList(_context.ChangeLogs, "Id", "Description", impact.ChangeLogId);
            return(View(impact));
        }
Ejemplo n.º 12
0
        private void HandleLevelCollision(Impact impact)
        {
            if (GameMain.GameSession != null && Timing.TotalTime < GameMain.GameSession.RoundStartTime + 10)
            {
                //ignore level collisions for the first 10 seconds of the round in case the sub spawns in a way that causes it to hit a wall
                //(e.g. level without outposts to dock to and an incorrectly configured ballast that makes the sub go up)
                return;
            }

            float wallImpact = Vector2.Dot(impact.Velocity, -impact.Normal);

            ApplyImpact(wallImpact, -impact.Normal, impact.ImpactPos);
            foreach (Submarine dockedSub in submarine.DockedTo)
            {
                dockedSub.SubBody.ApplyImpact(wallImpact, -impact.Normal, impact.ImpactPos);
            }

#if CLIENT
            int particleAmount = (int)Math.Min(wallImpact * 10.0f, 50);
            for (int i = 0; i < particleAmount; i++)
            {
                GameMain.ParticleManager.CreateParticle("iceshards",
                                                        ConvertUnits.ToDisplayUnits(impact.ImpactPos) + Rand.Vector(Rand.Range(1.0f, 50.0f)),
                                                        Rand.Vector(Rand.Range(50.0f, 500.0f)) + impact.Velocity);
            }
#endif
        }
Ejemplo n.º 13
0
        public override void OnEnable()
        {
            base.OnEnable();

            Inventory.Init(this);
            Impact.Init(this);
        }
Ejemplo n.º 14
0
        public bool EnemyHitsBlock(Enemy enemy, Block block, DirCardinal dir)
        {
            // TODO: LOTS OF STUFF HERE.
            // TODO: CONVEYORS, WALL JUMPS, ETC

            return(Impact.StandardImpact(enemy, block, dir));
        }
Ejemplo n.º 15
0
        public void GetForce(float[] output, int nsamples)
        {
            Array.Clear(output, 0, nsamples);

            while (impactrb.TryDequeue(out Impact imp))
            {
                if (numimpacts < MAXIMPACTS)
                {
                    impacts[numimpacts++] = imp;
                }
            }

            int i = 0;

            while (i < numimpacts)
            {
                Impact imp = impacts[i];
                for (uint n = 0; n < nsamples; n++)
                {
                    float impact = imp.Process(random);
                    output[n] += impact;
                }
                if (imp.volume < thr)
                {
                    imp = impacts[--numimpacts];
                }
                else
                {
                    ++i;
                }
            }
        }
Ejemplo n.º 16
0
 public ActionResult Create([Bind(Include = "Id,ImpactName,ImpactNumber")] Impact impact)
 {
     if (ModelState.IsValid)
     {
         try
         {
             impactRepo.InsertImpact(impact);
             impactRepo.Save();
             this.AddToastMessage("Impacts", "Impact created successfully!", ToastType.Success);
             return(RedirectToAction("Index"));
         }
         catch (DbUpdateException sqlExc)
         {
             var sqlException = sqlExc.GetBaseException() as SqlException;
             if (sqlException != null)
             {
                 logger.Error(sqlExc.ToString());
                 this.AddToastMessage("Impacts", "This impact already exists, please verify.", ToastType.Error);
             }
             else
             {
                 throw;
             }
         }
     }
     return(RedirectToAction("Index"));
 }
    private void HandleCollision(Hashtable payload)
    {
        Collision collision = (Collision)payload.GetAs<Collision>("collision");
        foreach( ContactPoint contact in collision.contacts ){
          //Register impact
          Impact impact = new Impact();

          impact.thisGameObject   = gameObject;
          impact.otherGameObject  = collision.gameObject;
          impact.relativeVelocity = collision.relativeVelocity;
          impact.normal           = contact.normal;
          impact.point            = contact.point;
          impact.thisCollider     = contact.thisCollider;
          impact.otherCollider    = contact.otherCollider;

          impacts.Add(impact.otherGameObject, impact);
          impacts.Add(impact.otherCollider, impact);
          impacts.Add(collision.rigidbody, impact);

          //Update OnGround
          float oldDot = Vector3.Dot(groundNormal, Physics.gravity.normalized);
          float newDot = Vector3.Dot(contact.normal, Physics.gravity.normalized);
          if(newDot > oldDot)
        groundNormal = contact.normal;
        }
    }
Ejemplo n.º 18
0
        public bool RunImpact(GameObject character, GameObject obj)
        {
            Character ch = (Character)character;

            // Specific Impact Types
            if (obj is Enemy)
            {
                return(((Enemy)obj).RunCharacterImpact(ch));
            }
            if (obj is Item)
            {
                return(this.CharHitsItem(ch, (Item)obj));
            }
            if (obj is Platform)
            {
                return(this.CharHitsPlatform(ch, (Platform)obj));
            }
            if (obj is Projectile)
            {
                return(this.CharHitsProjectile(ch, (Projectile)obj));
            }
            if (obj is Block)
            {
                return(this.CharHitsBlock(ch, (Block)obj));
            }

            DirCardinal dir = CollideDetect.GetDirectionOfCollision(ch, obj);

            // Standard Collision
            return(Impact.StandardImpact(ch, obj, dir));
        }
Ejemplo n.º 19
0
 private void ImpactOccurred(Impact impact)
 {
     if (MainCharacter.Current != null && impact.ThingHit == MainCharacter.Current)
     {
         MainCharacter.Current.EatenByZombie.Fire();
     }
 }
Ejemplo n.º 20
0
        public override bool RunCharacterImpact(Character character)
        {
            DirCardinal dir = CollideDetect.GetDirectionOfCollision(character, this);

            if (dir == DirCardinal.Down && this.subType == (byte)GhostSubType.Hat)
            {
                ActionMap.Jump.StartAction(character, 2, 0, 4, true);
            }
            else
            {
                if (this.subType != (byte)GhostSubType.Hide)
                {
                    if (this.subType == (byte)GhostSubType.Hat && this.posY - character.posY > 25)
                    {
                        return(false);
                    }
                    character.wounds.ReceiveWoundDamage(DamageStrength.Standard);
                }
            }

            if (this.subType == (byte)GhostSubType.Slimer)
            {
                return(Impact.StandardImpact(character, this, dir));
            }

            return(false);
        }
Ejemplo n.º 21
0
 public ActionResult Edit([Bind(Include = "Id,ImpactName,ImpactNumber")] Impact impact)
 {
     if (ModelState.IsValid)
     {
         try
         {
             impactRepo.UpdateImpact(impact);
             impactRepo.Save();
             this.AddToastMessage("Impacts", "Impact edited successfully!", ToastType.Success);
             return(Json(new { success = true }));
         }
         catch (DbUpdateException sqlExc)
         {
             var sqlException = sqlExc.GetBaseException() as SqlException;
             if (sqlException != null)
             {
                 logger.Error(sqlExc.ToString());
                 this.AddToastMessage("Impacts", "This impact already exists, please verify.", ToastType.Error);
             }
             else
             {
                 throw;
             }
         }
     }
     return(PartialView("PartialImpacts/_editImpact", impact));
 }
Ejemplo n.º 22
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Value")][FromBody] Impact impact)
        {
            if (id != impact.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(impact);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ImpactExists(impact.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(Json(impact));
        }
Ejemplo n.º 23
0
    public bool Push(Impact pImpact, SPELL_EVENT_ID nID)
    {
        if ((pImpact == null) || (nID >= SPELL_EVENT_ID.SPELL_EVENT_ID_NUMBER) || (nID <= SPELL_EVENT_ID.SPELL_EVENT_ID_INVALID))
        {
            LogManager.LogAssert(null);
        }

        if (m_FreeCache.Count > 0)
        {
            SPELL_EVENT pRet = m_FreeCache[0];
            m_FreeCache.RemoveAt(0);

            pRet.m_pImpact  = pImpact;
            pRet.m_nEventID = nID;
            m_UseList[nID].Add(pRet);
        }
        else
        {
            if (!m_UseList.ContainsKey(nID))
            {
                m_UseList.Add(nID, new List <SPELL_EVENT>());
            }
            SPELL_EVENT pEvent = new SPELL_EVENT();
            pEvent.m_pImpact  = pImpact;
            pEvent.m_nEventID = nID;
            m_UseList[nID].Add(pEvent);
        }

        return(true);
    }
Ejemplo n.º 24
0
            public static Impact Free(Impact impact)
            {
                _actives.Remove(impact);
                _avails.Add(impact);

                return(null);
            }
Ejemplo n.º 25
0
 public void Die()
 {
     if (lastHit.swing)
     {
         dead = true;
     }
     lastHit = null;
 }
Ejemplo n.º 26
0
    public void addImpact(Vector3 direction = new Vector3(), float force = 0)
    {
        Impact inp = new Impact();

        inp.direction = direction.normalized;
        inp.force     = force;
        impacts.Add(inp);
    }
        private void SectorOnContactPoint(int itemId, MyEntity other, ref MyPhysics.MyContactPointEvent e)
        {
            // if item is already disabled: puff
            // We get multiple contact points so this is for that
            if (m_sector.DataView.Items[itemId].ModelIndex < 0)
            {
                return;
            }

            var vel = Math.Abs(e.ContactPointEvent.SeparatingVelocity);

            if (other == null || other.Physics == null || other is MyFloatingObject)
            {
                return;
            }

            if (other is IMyHandheldGunObject <MyDeviceBase> )
            {
                return;
            }

            // Prevent debris from breaking trees.
            // Debris flies in unpredictable ways and this could cause out of sync tree destruction which would is bad.
            if (other.Physics.RigidBody != null && other.Physics.RigidBody.Layer == MyPhysics.CollisionLayers.DebrisCollisionLayer)
            {
                return;
            }

            // On objects held in manipulation tool, Havok returns high velocities, after this contact is fired by contraint solver.
            // Therefore we disable damage from objects connected by constraint to character
            if (MyManipulationTool.IsEntityManipulated(other))
            {
                return;
            }

            float otherMass = MyDestructionHelper.MassFromHavok(other.Physics.Mass);

            double impactEnergy = vel * vel * otherMass;

            // TODO: per item max impact energy
            if (impactEnergy > ItemResilience(itemId))
            {
                var normal = e.ContactPointEvent.ContactPoint.Normal;

                impactEnergy = MathHelper.Clamp(impactEnergy, 0, ItemResilience(itemId) * 10);

                Impact impact = new Impact(e.Position, normal, impactEnergy);

                m_sector.RaiseItemEvent(this, itemId, impact);
                DisableItemAndCreateDebris(ref impact, itemId);
            }

            // Meteor destroy always
            if (other is MyMeteor)
            {
                m_sector.EnableItem(itemId, false);
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Hit the specified _object.
        /// </summary>
        /// <param name="_object">Object.</param>
        public virtual void Hit(GameObject _target, Vector3 _point)
        {
            if (_target == null || (!Impact.ImpactBehaviour.AllowOwnImpacts && IsPartOfRoot(_target.transform)))
            {
                return;
            }

            Impact.Hit(_target, _point);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Hit the specified _object.
        /// </summary>
        /// <param name="_object">Object.</param>
        public virtual void Hit(GameObject _target, Vector3 _point)
        {
            if (_target == null || IsPartOfRoot(_target.transform))
            {
                return;
            }

            Impact.Hit(_target, _point);
        }
Ejemplo n.º 30
0
 private void Impact_Invalidated(object sender, InvalidateEventArgs e)
 {
     ThreadHelper.JoinableTaskFactory.Run(
         async() =>
     {
         await this.SwitchToMainThreadAsync();
         UpdateAuthorInfo(Impact.GetSelectedAuthor());
     });
 }
    /// <summary>
    /// Creates a vapour trail to follow the projectil.
    /// </summary>
    /// <returns>The trail.</returns>
    IEnumerator VapourTrail()
    {
        while (true)
        {
            yield return(new WaitForSeconds(0.5f));

            Impact.SpawnHitImpact(462, this.transform.position, 56, 62);
        }
    }
Ejemplo n.º 32
0
  public CompetencyItem(String competencyName, Boolean competencyCorrect,String competencyActual,String competencyExpected,
 double comptencyValue, int competencyConfidence, double oldCompetencyValue, double competencyDelta, EvidenceType competencyType, Impact impact)
  {
      this.competencyName = competencyName;
      
      this.competencyCorrect = competencyCorrect;
      this.competencyActual = competencyActual;
      this.competencyExpected = competencyExpected;
      this.comptencyValue = comptencyValue;
      this.competencyConfidence = competencyConfidence;
      this.oldCompetencyValue = oldCompetencyValue;
      this.competencyDelta = competencyDelta;
      this.competencyType = competencyType;
      this.impact = impact;
  }
Ejemplo n.º 33
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Story"/> class.
        /// </summary>
        /// <param name="project">The project.</param>  
        /// <param name="aangemaaktDoor">The aangemaakt door.</param>
        /// <param name="impact">The impact.</param>
        /// <param name="storyType">Type of the story.</param>
        public Story(Project project, Gebruiker aangemaaktDoor, Impact? impact, StoryType storyType)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project", "Het project mag niet null zijn.");
            }

            if (aangemaaktDoor == null)
            {
                throw new ArgumentNullException("aangemaaktDoor", "De gebruiker die deze story aanmaakt kan niet null zijn.");
            }

            project.VoegStoryToe(this);
            this.aangemaaktDoor = aangemaaktDoor;
            this.impact = impact;
            this.storyType = storyType;
        }
Ejemplo n.º 34
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Story"/> class.
        /// </summary>
        /// <param name="project">The project.</param>  
        /// <param name="createdBy">The user that created this story.</param>
        /// <param name="impact">The impact.</param>
        /// <param name="storyType">Type of the story.</param>
        public Story(Project project, User createdBy, Impact? impact, StoryType storyType)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project", "Project can't be null.");
            }

            if (createdBy == null)
            {
                throw new ArgumentNullException("createdBy", "The user creating this story can't be null.");
            }

            project.AddStory(this);
            this.createdBy = createdBy;
            this.impact = impact;
            this.storyType = storyType;
        }
        private void SectorOnContactPoint(int itemId, MyEntity other, ref MyPhysics.MyContactPointEvent e)
        {
            // if item is already disabled: puff
            // We get multiple contact points so this is for that
            if (m_sector.DataView.Items[itemId].ModelIndex < 0) return;

            var vel = Math.Abs(e.ContactPointEvent.SeparatingVelocity);

            if (other == null || other.Physics == null || other is MyFloatingObject) return;

            if (other is IMyHandheldGunObject<MyDeviceBase>) return;

            // Prevent debris from breaking trees.
            // Debris flies in unpredictable ways and this could cause out of sync tree destruction which would is bad.
            if (other.Physics.RigidBody != null && other.Physics.RigidBody.Layer == MyPhysics.CollisionLayers.DebrisCollisionLayer) return;

            // On objects held in manipulation tool, Havok returns high velocities, after this contact is fired by contraint solver.
            // Therefore we disable damage from objects connected by constraint to character
            if (MyManipulationTool.IsEntityManipulated(other))
                return;

            float otherMass = MyDestructionHelper.MassFromHavok(other.Physics.Mass);

            double impactEnergy = vel * vel * otherMass;

            // TODO: per item max impact energy
            if (impactEnergy > ItemResilience(itemId))
            {
                var normal = e.ContactPointEvent.ContactPoint.Normal;

                impactEnergy = MathHelper.Clamp(impactEnergy, 0, ItemResilience(itemId) * 10);

                Impact impact = new Impact(e.Position, normal, impactEnergy);

                m_sector.RaiseItemEvent(this, itemId, impact);
                DisableItemAndCreateDebris(ref impact, itemId);
            }

            // Meteor destroy always
            if (other is MyMeteor)
                m_sector.EnableItem(itemId, false);
        }
        /// <summary>
        /// Break item at specified id of Environment Sector
        /// </summary>
        /// <param name="itemId"></param>
        /// <param name="hitpos"></param>
        /// <param name="hitnormal"></param>
        /// <param name="impactEnergy"></param>
        public void BreakAt(int itemId, Vector3D hitpos, Vector3D hitnormal, double impactEnergy)
        {
            impactEnergy = MathHelper.Clamp(impactEnergy, 0, ItemResilience(itemId) * 10);

            Impact impact = new Impact(hitpos, hitnormal, impactEnergy);

            m_sector.RaiseItemEvent(this, itemId, impact);
            DisableItemAndCreateDebris(ref impact, itemId);
        }
        private void DisableItemAndCreateDebris(ref Impact imp, int itemId)
        {
            if (m_sector.DataView.Items[itemId].ModelIndex < 0) return;

            // Create particle
            MyParticleEffect effect;
            if (MyParticlesManager.TryCreateParticleEffect((int)MyParticleEffectsIDEnum.DestructionTree, out effect))
            {
                effect.WorldMatrix = MatrixD.CreateTranslation(imp.Position);//, (Vector3D)normal, Vector3D.CalculatePerpendicularVector(normal));
            }

            // Spawn no debris for stuff far away
            if (m_sector.LodLevel <= 1)
            {
                // Spawn debris
                var debris = CreateDebris(itemId);
                if (debris != null)
                {
                    var treeMass = debris.Physics.Mass;

                    const float ENERGY_PRESERVATION = .8f;

                    // Tree final velocity
                    float velTree = (float)Math.Sqrt(imp.Energy / treeMass);
                    float accell = velTree / (MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS * MyFakes.SIMULATION_SPEED) * ENERGY_PRESERVATION;
                    var force = accell * -imp.Normal;

                    var pos = debris.Physics.CenterOfMassWorld + 0.5f * Vector3D.Dot(imp.Position - debris.Physics.CenterOfMassWorld, debris.WorldMatrix.Up) * debris.WorldMatrix.Up;
                    debris.Physics.AddForce(MyPhysicsForceType.APPLY_WORLD_IMPULSE_AND_WORLD_ANGULAR_IMPULSE, force, pos, null);
                    Debug.Assert(debris.GetPhysicsBody().HavokWorld.ActiveRigidBodies.Contains(debris.Physics.RigidBody));
                }
            }

            // Disable item last because debris needs definition and whatnots
            m_sector.EnableItem(itemId, false);
        }