public void RpcFireAtTarget(uint attackerEntityID, uint targetEntityID, short weaponID, bool rotateToTarget) { Weapon weapon = ObjectDatabase.GetWeapon(weaponID); if (weapon) { Entity targetEntity = ObjectDatabase.GetEntity(targetEntityID); Entity attackerEntity = ObjectDatabase.GetEntity(attackerEntityID); if (!targetEntity) { return; } attackerEntity.SetTrigger(weapon.animationTrigger); attackerEntity.BlockMovement(weapon.cantMoveTime); if (rotateToTarget) { RotateTowards(attackerEntity.transform, targetEntity.transform.position); } GameObject bullet = Instantiate(weapon.bulletPrefab, attackerEntity.transform.position, Quaternion.identity); BulletController bulletController = bullet.GetComponent <BulletController>(); bulletController.ClientSetTarget(targetEntity.transform, weapon.bulletSpeed); } }
public void ServerFireAtTarget(uint attackerEntityID, uint targetEntityID, short weaponID, bool rotateToTarget = true) { Weapon weapon = ObjectDatabase.GetWeapon(weaponID); if (weapon) { Entity targetEntity = ObjectDatabase.GetEntity(targetEntityID); Entity attackerEntity = ObjectDatabase.GetEntity(attackerEntityID); if (!targetEntity || !attackerEntity) { return; } // bullet RpcFireAtTarget(attackerEntityID, targetEntityID, weaponID, rotateToTarget); GameObject bullet = Instantiate(weapon.bulletPrefab, attackerEntity.transform.position, Quaternion.identity); BulletController bulletController = bullet.GetComponent <BulletController>(); bulletController.ServerSetTarget(targetEntity.transform, weapon.bulletSpeed, weapon.Damage, attackerEntityID, targetEntityID); } }