private void OnDeath() { isDying = true; Effect.server.Run(entity.explosionEffect.resourcePath, entity.transform.position, Vector3.up, null, true); List <ServerGib> serverGibs = ServerGib.CreateGibs(entity.servergibs.resourcePath, entity.gameObject, entity.servergibs.Get().GetComponent <ServerGib>()._gibSource, Vector3.zero, 3f); for (int i = 0; i < 12 - entity.maxCratesToSpawn; i++) { BaseEntity fireBall = GameManager.server.CreateEntity(entity.fireBall.resourcePath, entity.transform.position, entity.transform.rotation, true); if (fireBall) { Vector3 onSphere = UnityEngine.Random.onUnitSphere; fireBall.transform.position = (entity.transform.position + new Vector3(0f, 1.5f, 0f)) + (onSphere * UnityEngine.Random.Range(-4f, 4f)); Collider collider = fireBall.GetComponent <Collider>(); fireBall.Spawn(); fireBall.SetVelocity(Vector3.zero + (onSphere * UnityEngine.Random.Range(3, 10))); foreach (ServerGib serverGib in serverGibs) { Physics.IgnoreCollision(collider, serverGib.GetCollider(), true); } } } if (entity != null && !entity.IsDestroyed) { entity.Kill(BaseNetworkable.DestroyMode.Gib); } }
public override void OnKilled(HitInfo info) { if (base.isClient) { base.OnKilled(info); return; } if (explosionEffect.isValid) { Effect.server.Run(explosionEffect.resourcePath, base.transform.position, Vector3.up, null, true); } Vector3 vector = rigidBody.velocity * 0.25f; List <ServerGib> list = null; if (serverGibs.isValid) { GameObject gibSource = serverGibs.Get().GetComponent <ServerGib>()._gibSource; list = ServerGib.CreateGibs(serverGibs.resourcePath, base.gameObject, gibSource, vector, 3f); } Vector3 vector2 = CenterPoint(); if (fireBall.isValid && !InSafeZone()) { for (int i = 0; i < 12; i++) { BaseEntity baseEntity = GameManager.server.CreateEntity(fireBall.resourcePath, vector2, base.transform.rotation); if (!baseEntity) { continue; } float min = 3f; float max = 10f; Vector3 onUnitSphere = Random.onUnitSphere; onUnitSphere.Normalize(); float num = Random.Range(0.5f, 4f); RaycastHit hitInfo; bool num2 = Physics.Raycast(vector2, onUnitSphere, out hitInfo, num, 1218652417); Vector3 position = hitInfo.point; if (!num2) { position = vector2 + onUnitSphere * num; } position -= onUnitSphere * 0.5f; baseEntity.transform.position = position; Collider component = baseEntity.GetComponent <Collider>(); baseEntity.Spawn(); baseEntity.SetVelocity(vector + onUnitSphere * Random.Range(min, max)); if (list == null) { continue; } foreach (ServerGib item in list) { Physics.IgnoreCollision(component, item.GetCollider(), true); } } } base.OnKilled(info); }
public static List <ServerGib> CreateGibs( string entityToCreatePath, GameObject creator, GameObject gibSource, Vector3 inheritVelocity, float spreadVelocity) { List <ServerGib> serverGibList = new List <ServerGib>(); foreach (MeshRenderer componentsInChild in (MeshRenderer[])gibSource.GetComponentsInChildren <MeshRenderer>(true)) { MeshFilter component1 = (MeshFilter)((Component)componentsInChild).GetComponent <MeshFilter>(); Vector3 localPosition1 = ((Component)componentsInChild).get_transform().get_localPosition(); Vector3 normalized = ((Vector3) ref localPosition1).get_normalized(); Matrix4x4 localToWorldMatrix = creator.get_transform().get_localToWorldMatrix(); Vector3 pos = Vector3.op_Addition(((Matrix4x4) ref localToWorldMatrix).MultiplyPoint(((Component)componentsInChild).get_transform().get_localPosition()), Vector3.op_Multiply(normalized, 0.5f)); Quaternion rot = Quaternion.op_Multiply(creator.get_transform().get_rotation(), ((Component)componentsInChild).get_transform().get_localRotation()); BaseEntity entity = GameManager.server.CreateEntity(entityToCreatePath, pos, rot, true); if (Object.op_Implicit((Object)entity)) { ServerGib component2 = (ServerGib)((Component)entity).GetComponent <ServerGib>(); ((Component)component2).get_transform().set_position(pos); ((Component)component2).get_transform().set_rotation(rot); component2._gibName = ((Object)componentsInChild).get_name(); component2.PhysicsInit(component1.get_sharedMesh()); Vector3 localPosition2 = ((Component)componentsInChild).get_transform().get_localPosition(); Vector3 vector3_1 = Vector3.op_Multiply(((Vector3) ref localPosition2).get_normalized(), spreadVelocity); component2.rigidBody.set_velocity(Vector3.op_Addition(inheritVelocity, vector3_1)); Rigidbody rigidBody = component2.rigidBody; Vector3 vector3_2 = Vector3Ex.Range(-1f, 1f); Vector3 vector3_3 = Vector3.op_Multiply(((Vector3) ref vector3_2).get_normalized(), 1f); rigidBody.set_angularVelocity(vector3_3); component2.rigidBody.WakeUp(); component2.Spawn(); serverGibList.Add(component2); } } foreach (ServerGib serverGib1 in serverGibList) { foreach (ServerGib serverGib2 in serverGibList) { if (!Object.op_Equality((Object)serverGib1, (Object)serverGib2)) { Physics.IgnoreCollision((Collider)serverGib2.GetCollider(), (Collider)serverGib1.GetCollider(), true); } } } return(serverGibList); }
public static List <ServerGib> CreateGibs(string entityToCreatePath, GameObject creator, GameObject gibSource, Vector3 inheritVelocity, float spreadVelocity) { List <ServerGib> serverGibs = new List <ServerGib>(); MeshRenderer[] componentsInChildren = gibSource.GetComponentsInChildren <MeshRenderer>(true); for (int i = 0; i < (int)componentsInChildren.Length; i++) { MeshRenderer meshRenderer = componentsInChildren[i]; MeshFilter component = meshRenderer.GetComponent <MeshFilter>(); Vector3 vector3 = meshRenderer.transform.localPosition; Vector3 vector31 = vector3.normalized; Matrix4x4 matrix4x4 = creator.transform.localToWorldMatrix; Vector3 vector32 = matrix4x4.MultiplyPoint(meshRenderer.transform.localPosition) + (vector31 * 0.5f); Quaternion quaternion = creator.transform.rotation * meshRenderer.transform.localRotation; BaseEntity baseEntity = GameManager.server.CreateEntity(entityToCreatePath, vector32, quaternion, true); if (baseEntity) { ServerGib serverGib = baseEntity.GetComponent <ServerGib>(); serverGib.transform.position = vector32; serverGib.transform.rotation = quaternion; serverGib._gibName = meshRenderer.name; serverGib.PhysicsInit(component.sharedMesh); vector3 = meshRenderer.transform.localPosition; Vector3 vector33 = vector3.normalized * spreadVelocity; serverGib.rigidBody.velocity = inheritVelocity + vector33; Rigidbody rigidbody = serverGib.rigidBody; vector3 = Vector3Ex.Range(-1f, 1f); rigidbody.angularVelocity = vector3.normalized * 1f; serverGib.rigidBody.WakeUp(); serverGib.Spawn(); serverGibs.Add(serverGib); } } foreach (ServerGib serverGib1 in serverGibs) { foreach (ServerGib serverGib2 in serverGibs) { if (serverGib1 == serverGib2) { continue; } Physics.IgnoreCollision(serverGib2.GetCollider(), serverGib1.GetCollider(), true); } } return(serverGibs); }
public override void OnKilled(HitInfo info) { if (base.isClient) { base.OnKilled(info); return; } if (this.explosionEffect.isValid) { Effect.server.Run(this.explosionEffect.resourcePath, base.transform.position, Vector3.up, null, true); } Vector3 vector3 = this.rigidBody.velocity * 0.25f; List <ServerGib> serverGibs = null; if (this.serverGibs.isValid) { GameObject component = this.serverGibs.Get().GetComponent <ServerGib>()._gibSource; serverGibs = ServerGib.CreateGibs(this.serverGibs.resourcePath, base.gameObject, component, vector3, 3f); } if (this.fireBall.isValid) { for (int i = 0; i < 12; 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))); if (serverGibs != null) { foreach (ServerGib serverGib in serverGibs) { Physics.IgnoreCollision(collider, serverGib.GetCollider(), true); } } } } } base.OnKilled(info); }
public override void OnKilled(HitInfo info) { if (this.isClient) { base.OnKilled(info); } else { if (this.explosionEffect.isValid) { Effect.server.Run(this.explosionEffect.resourcePath, ((Component)this).get_transform().get_position(), Vector3.get_up(), (Connection)null, true); } Vector3 inheritVelocity = Vector3.op_Multiply(this.rigidBody.get_velocity(), 0.25f); List <ServerGib> serverGibList = (List <ServerGib>)null; if (this.serverGibs.isValid) { serverGibList = ServerGib.CreateGibs(this.serverGibs.resourcePath, ((Component)this).get_gameObject(), ((ServerGib)this.serverGibs.Get().GetComponent <ServerGib>())._gibSource, inheritVelocity, 3f); } if (this.fireBall.isValid) { for (int index = 0; index < 12; ++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)))); if (serverGibList != null) { foreach (ServerGib serverGib in serverGibList) { Physics.IgnoreCollision(component, (Collider)serverGib.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) { 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 (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); }