public void ServerFireRocketLauncher( Server server, PlayerObjectComponent shootingPlayerObjectComponent, Ray shotRay ) { var rocketState = new RocketState { Id = server.GenerateNetworkId(), RigidBodyState = new RigidBodyState { Position = shotRay.origin + shotRay.direction, EulerAngles = Quaternion.LookRotation(shotRay.direction, Vector3.up).eulerAngles, Velocity = OsFps.RocketSpeed * shotRay.direction, AngularVelocity = Vector3.zero }, ShooterPlayerId = shootingPlayerObjectComponent.State.Id }; var rocket = RocketSystem.Instance.SpawnLocalRocketObject(rocketState); // Make grenade ignore collisions with thrower. GameObjectExtensions.IgnoreCollisionsRecursive(rocket, shootingPlayerObjectComponent.gameObject); }
public void ServerPlayerThrowGrenade(Server server, PlayerObjectComponent playerObjectComponent) { var playerObjectState = playerObjectComponent.State; if (!playerObjectState.CanThrowGrenade) { return; } var throwRay = GetShotRay(playerObjectComponent); throwRay.origin += (0.5f * throwRay.direction); var currentGrenadeSlot = playerObjectState.GrenadeSlots[playerObjectState.CurrentGrenadeSlotIndex]; var grenadeState = new GrenadeState { Id = server.GenerateNetworkId(), Type = currentGrenadeSlot.GrenadeType, IsActive = true, TimeUntilDetonation = null, RigidBodyState = new RigidBodyState { Position = throwRay.origin, EulerAngles = Quaternion.LookRotation(throwRay.direction, Vector3.up).eulerAngles, Velocity = OsFps.GrenadeThrowSpeed * throwRay.direction, AngularVelocity = Vector3.zero }, ThrowerPlayerId = playerObjectState.Id }; var grenadeObject = GrenadeSpawnerSystem.Instance.SpawnLocalGrenadeObject(grenadeState); // Make grenade ignore collisions with thrower. GameObjectExtensions.IgnoreCollisionsRecursive(grenadeObject, playerObjectComponent.gameObject); currentGrenadeSlot.GrenadeCount--; playerObjectState.TimeUntilCanThrowGrenade = OsFps.GrenadeThrowInterval; }