public void OnPreTileCollision(SpeculativeRigidbody myRigidbody, PixelCollider myPixelCollider, PhysicsEngine.Tile tile, PixelCollider tilePixelCollider) { if (myRigidbody.projectile != null && myRigidbody.sprite != null && this.m_owner.PlayerHasActiveSynergy("#BE_SERIOUS")) { if (!this.m_owner.IsInCombat || this.smarterMinions.Count >= 4) { return; } AIActor orLoadByGuid = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5"); IntVector2?nearestAvailableCell = null; if (this.m_owner.CurrentRoom != null) { nearestAvailableCell = this.m_owner.CurrentRoom.GetNearestAvailableCell(myRigidbody.projectile.sprite.WorldCenter, new IntVector2?(orLoadByGuid.Clearance), new CellTypes?(CellTypes.FLOOR), false, null); } Vector3 vector = nearestAvailableCell != null ? (nearestAvailableCell.Value.ToVector2()).ToVector3ZUp(0f) : myRigidbody.projectile.sprite.WorldCenter.ToVector3ZUp(0f); GameObject enemyObj = UnityEngine.Object.Instantiate <GameObject>(orLoadByGuid.gameObject, vector, Quaternion.identity); CompanionController orAddComponent = enemyObj.GetOrAddComponent <CompanionController>(); orAddComponent.companionID = CompanionController.CompanionIdentifier.NONE; orAddComponent.Initialize(this.m_owner); orAddComponent.behaviorSpeculator.MovementBehaviors.Add(new CompanionFollowPlayerBehavior()); AIActor aiactor = enemyObj.GetComponent <AIActor>(); aiactor.HitByEnemyBullets = true; aiactor.healthHaver.ModifyDamage += this.ModifyDamageForCompanions; aiactor.StartCoroutine(this.InvisibleCoroutine(aiactor)); aiactor.procedurallyOutlined = false; aiactor.CorpseObject = null; aiactor.ImmuneToAllEffects = true; aiactor.SetIsFlying(true, "I'm a bullet too!"); SmarterDumbEnemyBehavior smartBehavior = aiactor.gameObject.AddComponent <SmarterDumbEnemyBehavior>(); smartBehavior.layer = myRigidbody.projectile.gameObject.layer; smartBehavior.collection = myRigidbody.projectile.sprite.Collection; smartBehavior.spriteId = myRigidbody.projectile.sprite.spriteId; foreach (AIBulletBank.Entry entry in orAddComponent.bulletBank.Bullets) { if (aiactor.IsBlackPhantom) { entry.BulletObject.GetComponent <Projectile>().baseData.damage = 15; } else { entry.BulletObject.GetComponent <Projectile>().baseData.damage = 10; } } foreach (AttackBehaviorBase behavior in aiactor.behaviorSpeculator.AttackBehaviors) { if ((behavior as ShootGunBehavior) != null) { if (aiactor.IsBlackPhantom) { aiactor.aiShooter.GetBulletEntry((behavior as ShootGunBehavior).OverrideBulletName).ProjectileData.damage = 15; } else { aiactor.aiShooter.GetBulletEntry((behavior as ShootGunBehavior).OverrideBulletName).ProjectileData.damage = 10; } } } this.smarterMinions.Add(aiactor); } else if (myRigidbody.projectile != null && myRigidbody.sprite != null) { AIActor aiactor = AIActor.Spawn(EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5"), myRigidbody.projectile.sprite.WorldCenter, myRigidbody.transform.position.GetAbsoluteRoom(), true, AIActor.AwakenAnimationType.Default, true); GameObject gameObject = new GameObject("suck image"); gameObject.layer = myRigidbody.projectile.gameObject.layer; tk2dSprite tk2dSprite = gameObject.AddComponent <tk2dSprite>(); gameObject.transform.parent = SpawnManager.Instance.Projectiles; gameObject.transform.position = aiactor.sprite.WorldCenter; tk2dSprite.SetSprite(myRigidbody.projectile.sprite.Collection, myRigidbody.projectile.sprite.spriteId); tk2dSprite.transform.parent = aiactor.transform; aiactor.sprite.renderer.enabled = false; aiactor.procedurallyOutlined = false; aiactor.CanTargetEnemies = true; aiactor.CanTargetPlayers = false; aiactor.CorpseObject = null; aiactor.SetIsFlying(true, "I'm a bullet too!"); aiactor.specRigidbody.AddCollisionLayerIgnoreOverride(CollisionMask.LayerToMask(CollisionLayer.PlayerHitBox, CollisionLayer.PlayerCollider)); if (aiactor.IgnoreForRoomClear) { aiactor.IgnoreForRoomClear = false; if (aiactor.ParentRoom != null) { aiactor.ParentRoom.DeregisterEnemy(aiactor); } } DumbEnemyBehavior dumbEnemyBehavior = aiactor.gameObject.AddComponent <DumbEnemyBehavior>(); if (myRigidbody.projectile.GetComponent <NewUsesProjectileSynergyController>() != null) { dumbEnemyBehavior.sourceAmmoType = myRigidbody.projectile.GetComponent <NewUsesProjectileSynergyController>().ammoType; dumbEnemyBehavior.customAmmoType = myRigidbody.projectile.GetComponent <NewUsesProjectileSynergyController>().customAmmoType; dumbEnemyBehavior.usesNewUsesSynergy = true; } myRigidbody.projectile.DieInAir(); } }
private void onhit(SpeculativeRigidbody myrigidbody, PixelCollider mypixelcollider, PhysicsEngine.Tile tile, PixelCollider tilepixelcollider) { // myrigidbody.projectile.ForceDestruction(); }
public void OnCollision(SpeculativeRigidbody myRigidbody, PixelCollider myPixelCollider, PhysicsEngine.Tile tile, PixelCollider tilePixelCollider) { if (myRigidbody.projectile != null) { Projectile proj = myRigidbody.projectile; RoomHandler room; Vector2 vector; if (proj.sprite != null) { vector = proj.sprite.WorldCenter; } else if (proj.specRigidbody != null) { vector = proj.specRigidbody.UnitCenter; } else { vector = proj.transform.position.XY(); } room = vector.GetAbsoluteRoom(); if (room != null) { float num = -1f; AIActor actor = room.GetNearestEnemy(vector, out num, true, false); if (actor != null) { Vector2 vector2 = actor.CenterPosition - vector; proj.SendInDirection(vector2, false, true); proj.specRigidbody.OnPreTileCollision -= new SpeculativeRigidbody.OnPreTileCollisionDelegate(this.OnCollision); PhysicsEngine.SkipCollision = true; } } } }
public void HandleHitTile(SpeculativeRigidbody myRigidbody, PixelCollider myPixelCollider, PhysicsEngine.Tile tile, PixelCollider tilePixelCollider) { if (myRigidbody && myRigidbody.healthHaver) { AIActor aiActor = myRigidbody.aiActor; myRigidbody.OnPreRigidbodyCollision -= new SpeculativeRigidbody.OnPreRigidbodyCollisionDelegate(this.HandleHitEnemyHitEnemy); myRigidbody.OnPreTileCollision -= new SpeculativeRigidbody.OnPreTileCollisionDelegate(this.HandleHitTile); if (aiActor.IsNormalEnemy && aiActor.healthHaver) { aiActor.healthHaver.ApplyDamage(30, myRigidbody.Velocity, "Kinetic Power", CoreDamageTypes.None, DamageCategory.Normal, false, null, false); } } }