public override void OnKilled(HitInfo info) { if (base.isClient) { return; } this.CreateExplosionMarker(10f); Effect.server.Run(this.explosionEffect.resourcePath, this.mainTurretEyePos.transform.position, Vector3.up, null, true); Vector3 vector3 = Vector3.zero; GameObject component = this.servergibs.Get().GetComponent <ServerGib>()._gibSource; List <ServerGib> serverGibs = ServerGib.CreateGibs(this.servergibs.resourcePath, base.gameObject, component, vector3, 3f); for (int i = 0; i < 12 - this.maxCratesToSpawn; i++) { BaseEntity baseEntity = GameManager.server.CreateEntity(this.fireBall.resourcePath, base.transform.position, base.transform.rotation, true); if (baseEntity) { float single = 3f; float single1 = 10f; Vector3 vector31 = UnityEngine.Random.onUnitSphere; baseEntity.transform.position = (base.transform.position + new Vector3(0f, 1.5f, 0f)) + (vector31 * UnityEngine.Random.Range(-4f, 4f)); Collider collider = baseEntity.GetComponent <Collider>(); baseEntity.Spawn(); baseEntity.SetVelocity(vector3 + (vector31 * UnityEngine.Random.Range(single, single1))); foreach (ServerGib serverGib in serverGibs) { UnityEngine.Physics.IgnoreCollision(collider, serverGib.GetCollider(), true); } } } for (int j = 0; j < this.maxCratesToSpawn; j++) { Vector3 vector32 = UnityEngine.Random.onUnitSphere; Vector3 vector33 = (base.transform.position + new Vector3(0f, 1.5f, 0f)) + (vector32 * UnityEngine.Random.Range(2f, 3f)); BaseEntity baseEntity1 = GameManager.server.CreateEntity(this.crateToDrop.resourcePath, vector33, Quaternion.LookRotation(vector32), true); baseEntity1.Spawn(); LootContainer lootContainer = baseEntity1 as LootContainer; if (lootContainer) { lootContainer.Invoke(new Action(lootContainer.RemoveMe), 1800f); } Collider component1 = baseEntity1.GetComponent <Collider>(); Rigidbody rigidbody = baseEntity1.gameObject.AddComponent <Rigidbody>(); rigidbody.useGravity = true; rigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic; rigidbody.mass = 2f; rigidbody.interpolation = RigidbodyInterpolation.Interpolate; rigidbody.velocity = vector3 + (vector32 * UnityEngine.Random.Range(1f, 3f)); rigidbody.angularVelocity = Vector3Ex.Range(-1.75f, 1.75f); rigidbody.drag = 0.5f * (rigidbody.mass / 5f); rigidbody.angularDrag = 0.2f * (rigidbody.mass / 5f); GameManager gameManager = GameManager.server; string str = this.fireBall.resourcePath; Vector3 vector34 = new Vector3(); Quaternion quaternion = new Quaternion(); FireBall fireBall = gameManager.CreateEntity(str, vector34, quaternion, true) as FireBall; if (fireBall) { fireBall.SetParent(baseEntity1, false, false); fireBall.Spawn(); fireBall.GetComponent <Rigidbody>().isKinematic = true; fireBall.GetComponent <Collider>().enabled = false; } baseEntity1.SendMessage("SetLockingEnt", fireBall.gameObject, SendMessageOptions.DontRequireReceiver); foreach (ServerGib serverGib1 in serverGibs) { UnityEngine.Physics.IgnoreCollision(component1, serverGib1.GetCollider(), true); } } base.OnKilled(info); }
public override void OnKilled(HitInfo info) { if (this.isClient) { return; } this.CreateExplosionMarker(10f); Effect.server.Run(this.explosionEffect.resourcePath, ((Component)this).get_transform().get_position(), Vector3.get_up(), (Connection)null, true); Vector3 inheritVelocity = Vector3.op_Multiply(Vector3.op_Multiply(this.myAI.GetLastMoveDir(), this.myAI.GetMoveSpeed()), 0.75f); List <ServerGib> gibs = ServerGib.CreateGibs(this.servergibs.resourcePath, ((Component)this).get_gameObject(), ((ServerGib)this.servergibs.Get().GetComponent <ServerGib>())._gibSource, inheritVelocity, 3f); for (int index = 0; index < 12 - this.maxCratesToSpawn; ++index) { BaseEntity entity = GameManager.server.CreateEntity(this.fireBall.resourcePath, ((Component)this).get_transform().get_position(), ((Component)this).get_transform().get_rotation(), true); if (Object.op_Implicit((Object)entity)) { float num1 = 3f; float num2 = 10f; Vector3 onUnitSphere = Random.get_onUnitSphere(); ((Component)entity).get_transform().set_position(Vector3.op_Addition(Vector3.op_Addition(((Component)this).get_transform().get_position(), new Vector3(0.0f, 1.5f, 0.0f)), Vector3.op_Multiply(onUnitSphere, Random.Range(-4f, 4f)))); Collider component = (Collider)((Component)entity).GetComponent <Collider>(); entity.Spawn(); entity.SetVelocity(Vector3.op_Addition(inheritVelocity, Vector3.op_Multiply(onUnitSphere, Random.Range(num1, num2)))); foreach (ServerGib serverGib in gibs) { Physics.IgnoreCollision(component, (Collider)serverGib.GetCollider(), true); } } } for (int index = 0; index < this.maxCratesToSpawn; ++index) { Vector3 onUnitSphere = Random.get_onUnitSphere(); Vector3 pos = Vector3.op_Addition(Vector3.op_Addition(((Component)this).get_transform().get_position(), new Vector3(0.0f, 1.5f, 0.0f)), Vector3.op_Multiply(onUnitSphere, Random.Range(2f, 3f))); BaseEntity entity1 = GameManager.server.CreateEntity(this.crateToDrop.resourcePath, pos, Quaternion.LookRotation(onUnitSphere), true); entity1.Spawn(); LootContainer lootContainer = entity1 as LootContainer; if (Object.op_Implicit((Object)lootContainer)) { lootContainer.Invoke(new Action(lootContainer.RemoveMe), 1800f); } Collider component = (Collider)((Component)entity1).GetComponent <Collider>(); Rigidbody rigidbody = (Rigidbody)((Component)entity1).get_gameObject().AddComponent <Rigidbody>(); rigidbody.set_useGravity(true); rigidbody.set_collisionDetectionMode((CollisionDetectionMode)2); rigidbody.set_mass(2f); rigidbody.set_interpolation((RigidbodyInterpolation)1); rigidbody.set_velocity(Vector3.op_Addition(inheritVelocity, Vector3.op_Multiply(onUnitSphere, Random.Range(1f, 3f)))); rigidbody.set_angularVelocity(Vector3Ex.Range(-1.75f, 1.75f)); rigidbody.set_drag((float)(0.5 * ((double)rigidbody.get_mass() / 5.0))); rigidbody.set_angularDrag((float)(0.200000002980232 * ((double)rigidbody.get_mass() / 5.0))); FireBall entity2 = GameManager.server.CreateEntity(this.fireBall.resourcePath, (Vector3)null, (Quaternion)null, true) as FireBall; if (Object.op_Implicit((Object)entity2)) { entity2.SetParent(entity1, false, false); entity2.Spawn(); ((Rigidbody)((Component)entity2).GetComponent <Rigidbody>()).set_isKinematic(true); ((Collider)((Component)entity2).GetComponent <Collider>()).set_enabled(false); } ((Component)entity1).SendMessage("SetLockingEnt", (object)((Component)entity2).get_gameObject(), (SendMessageOptions)1); foreach (ServerGib serverGib in gibs) { Physics.IgnoreCollision(component, (Collider)serverGib.GetCollider(), true); } } base.OnKilled(info); }
public override void OnKilled(HitInfo info) { if (base.isClient || Interface.CallHook("OnEntityDestroy", this) != null) { return; } CreateExplosionMarker(10f); Effect.server.Run(explosionEffect.resourcePath, mainTurretEyePos.transform.position, Vector3.up, null, true); Vector3 zero = Vector3.zero; GameObject gibSource = servergibs.Get().GetComponent <ServerGib>()._gibSource; List <ServerGib> list = ServerGib.CreateGibs(servergibs.resourcePath, base.gameObject, gibSource, zero, 3f); for (int i = 0; i < 12 - maxCratesToSpawn; i++) { BaseEntity baseEntity = GameManager.server.CreateEntity(this.fireBall.resourcePath, base.transform.position, base.transform.rotation); if (!baseEntity) { continue; } float min = 3f; float max = 10f; Vector3 onUnitSphere = UnityEngine.Random.onUnitSphere; baseEntity.transform.position = base.transform.position + new Vector3(0f, 1.5f, 0f) + onUnitSphere * UnityEngine.Random.Range(-4f, 4f); Collider component = baseEntity.GetComponent <Collider>(); baseEntity.Spawn(); baseEntity.SetVelocity(zero + onUnitSphere * UnityEngine.Random.Range(min, max)); foreach (ServerGib item in list) { UnityEngine.Physics.IgnoreCollision(component, item.GetCollider(), true); } } for (int j = 0; j < maxCratesToSpawn; j++) { Vector3 onUnitSphere2 = UnityEngine.Random.onUnitSphere; onUnitSphere2.y = 0f; onUnitSphere2.Normalize(); Vector3 pos = base.transform.position + new Vector3(0f, 1.5f, 0f) + onUnitSphere2 * UnityEngine.Random.Range(2f, 3f); BaseEntity baseEntity2 = GameManager.server.CreateEntity(crateToDrop.resourcePath, pos, Quaternion.LookRotation(onUnitSphere2)); baseEntity2.Spawn(); LootContainer lootContainer = baseEntity2 as LootContainer; if ((bool)lootContainer) { lootContainer.Invoke(lootContainer.RemoveMe, 1800f); } Collider component2 = baseEntity2.GetComponent <Collider>(); Rigidbody rigidbody = baseEntity2.gameObject.AddComponent <Rigidbody>(); rigidbody.useGravity = true; rigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic; rigidbody.mass = 2f; rigidbody.interpolation = RigidbodyInterpolation.Interpolate; rigidbody.velocity = zero + onUnitSphere2 * UnityEngine.Random.Range(1f, 3f); rigidbody.angularVelocity = Vector3Ex.Range(-1.75f, 1.75f); rigidbody.drag = 0.5f * (rigidbody.mass / 5f); rigidbody.angularDrag = 0.2f * (rigidbody.mass / 5f); FireBall fireBall = GameManager.server.CreateEntity(this.fireBall.resourcePath) as FireBall; if ((bool)fireBall) { fireBall.SetParent(baseEntity2); fireBall.Spawn(); fireBall.GetComponent <Rigidbody>().isKinematic = true; fireBall.GetComponent <Collider>().enabled = false; } baseEntity2.SendMessage("SetLockingEnt", fireBall.gameObject, SendMessageOptions.DontRequireReceiver); foreach (ServerGib item2 in list) { UnityEngine.Physics.IgnoreCollision(component2, item2.GetCollider(), true); } } base.OnKilled(info); }