public void Execute(Entity _, int index, [ReadOnly] ref PlayerActorArray playerActorArray, [ReadOnly, ChangedFilter] ref PlayerShipMoveInputNetMessage moveInput) { if (playerActorArray.shipEntity == Entity.Null) { return; } if (shipDisableMoveInputFromEntity.Exists(playerActorArray.shipEntity)) { return; } //moveInput { moveInputCommandBuffer.SetComponent(playerActorArray.shipEntity, moveInput.shipMoveInput); } }
public void Execute(Entity _, int index, [ReadOnly] ref PlayerActorArray playerActorArray, [ChangedFilter] ref PlayerShipFireInputNetMessage fireInput) { if (playerActorArray.shipEntity == Entity.Null) { return; } if (shipDisableFireInputFromEntity.Exists(playerActorArray.shipEntity)) { return; } var fireAction = fireInput.fireAction; if (fireAction == FireAction.none) { return; } fireInput.fireAction = FireAction.none; var weaponEntity = Entity.Null; var weaponInput = new WeaponInput { fireType = FireType.Fire, firePosition = new float3(fireInput.firePosition.x, 0f, fireInput.firePosition.y) }; if (fireAction >= FireAction.fireSlotIndex0 && fireAction < FireAction.__fireSlotIndexEnd) { var weaponIndex = (int)fireAction; weaponIndex -= (int)FireAction.__fireSlotIndexBegin; weaponEntity = playerActorArray.GetWeaponEntity(weaponIndex); } else if (fireAction >= FireAction.uninstallSlotIndex0 && fireAction < FireAction.__uninstallSlotIndexEnd) { var weaponIndex = (int)fireAction; weaponIndex -= (int)FireAction.__uninstallSlotIndexBegin; weaponEntity = playerActorArray.GetWeaponEntity(weaponIndex); weaponInput.fireType = FireType.Uninstall; } else if (fireAction >= FireAction.uninstallAssistSlotIndex0 && fireAction < FireAction.__uninstallAssistSlotIndexEnd) { var weaponIndex = (int)fireAction; weaponIndex -= (int)FireAction.__uninstallAssistSlotIndexBegin; weaponEntity = playerActorArray.GetAssistWeaponEntity(weaponIndex); weaponInput.fireType = FireType.Uninstall; } else if (fireAction == FireAction.shield) { weaponEntity = playerActorArray.curShieldWeaponEntity; } else if (fireAction == FireAction.mainFire)//中键 发射主炮 { weaponEntity = getMainSlotWeaponEntity(playerActorArray); } /*else if (fireAction == FireAction.mouseButton2)//右键 发射远离鼠标一侧的侧面炮火 发送方向取反射角度 * { * var shipPosition = translationFromEntity[playerActorArray.shipEntity].Value; * var shipRotation = rotationFromEntity[playerActorArray.shipEntity].Value; * var fireDirection = firePosition - shipPosition; * fireDirection = math.reflect(-fireDirection, math.forward(shipRotation.value)); * firePosition = shipPosition + fireDirection; * * weaponEntity = getWeaponEntity(playerActorArray, firePosition); * }*/ else if (fireAction == FireAction.autoFire)//右键 发射靠近鼠标一侧的侧面炮火 { weaponEntity = getWeaponEntity(playerActorArray, weaponInput.firePosition); } else { #if ENABLE_UNITY_COLLECTIONS_CHECKS throw new System.IndexOutOfRangeException(); #endif } // if (weaponEntity != Entity.Null) { weaponInputCommandBuffer.SetComponent(weaponEntity, weaponInput); } }